Unable to set up NFS on EC2 instances launched using Ansible

124 views
Skip to first unread message

Luke Valenta

unread,
Jul 6, 2015, 6:00:03 PM7/6/15
to ansible...@googlegroups.com
Hi,

I am unable to get NFS configured correctly on EC2 instances launched via the 'ec2' module in Ansible. When I launch instances using the exact same AMI from the AWS EC2 console, NFS works without a hitch.

First I'll describe my setup, and then how to reproduce the problem. I'm running Ansible from a Mac OSX Yosemite version 10.10.3.

    $ ansible --version
        ansible 1.9.2

I was also able to reproduce the problem from a machine running Debian 8.1 with Ansible version 1.9.

This is the ansible playbook I'm using to launch 2 ec2 instances.

    $ cat test-nfs.yml
        - hosts: localhost
          tasks:
           - ec2:
              key_name: my_key
              aws_region: us-east-1
              zone: us-east-1c
              image: ami-d05e75b8
              vpc_subnet_id: subnet-cba9efbc
              instance_type: t2.micro
              exact_count: 2
              count_tag:
                Name: nfs-test
              instance_tags:
                Name: nfs-test
              assign_public_ip: yes
              wait: yes

Launch two instances.

    <command machine>$ ansible-playbook -i ./ec2.py test-nfs.yml

Then, SSH into the first instance and set up NFS.

    <command machine>$ ssh ubuntu@<nfs-server ip>
    <nfs-server>$ sudo mkdir -m 777 /test
    <nfs-server>$ sudo apt-get install nfs-kernel-server
    <nfs-server>$ sudo cat "/test    *(rw,async,no_subtree_check)" >> /etc/exports
    <nfs-server>$ sudo service nfs-kernel-server restart

Attempt to mount NFS on the second instance.

    <nfs-client>$ sudo mkdir -m 777 /test
    <nfs-client>$ sudo apt-get install nfs-common
    <nfs-client>$ sudo mount <nfs-server ip>:/test /test

The last step (mounting /test) hangs and times out if the instances were launched using the ansible ec2 module, but completes almost instantly when the instance are launched from the AWS EC2 console or using the AWS CLI.

    $ aws ec2 run-instances --image-id ami-d05e75b8 --count 1 --instance-type t2.micro --key-name test --security-group-ids sg-8fd0f7eb --subnet-id subnet-cba9efbc

Any help would be greatly appreciated. I can provide additional information about the setup if requested.

Luke Valenta

unread,
Jul 6, 2015, 8:23:24 PM7/6/15
to ansible...@googlegroups.com
Bug solved. I was not specifying the correct security group. I had confused ansible groups with ec2 security groups in my code.
Reply all
Reply to author
Forward
0 new messages