# Unable to set up NFS on EC2 instances launched using Ansible

**URL:** <https://forum.ansible.com/t/unable-to-set-up-nfs-on-ec2-instances-launched-using-ansible/18695>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [July 6, 2015, 9:02pm UTC](https://forum.ansible.com/t/unable-to-set-up-nfs-on-ec2-instances-launched-using-ansible/18695 "2015-07-06T21:02:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke\_Valenta](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Luke\_Valenta](https://forum.ansible.com/u/Luke_Valenta)\
**Post date:** [July 6, 2015, 9:02pm UTC](https://forum.ansible.com/t/unable-to-set-up-nfs-on-ec2-instances-launched-using-ansible/18695/1 "2015-07-06T21:02:56Z")

</div>

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.

$ ansible-playbook -i ./ec2.py test-nfs.yml

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

$ ssh ubuntu@  
$ sudo mkdir -m 777 /test  
$ sudo apt-get install nfs-kernel-server  
$ sudo cat “/test \*(rw,async,no\_subtree\_check)” \>\> /etc/exports  
$ sudo service nfs-kernel-server restart

Attempt to mount NFS on the second instance.

$ sudo mkdir -m 777 /test  
$ sudo apt-get install nfs-common  
$ sudo mount :/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.

---

<div class="post-metadata">

**Author:** ![Luke\_Valenta](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Luke\_Valenta](https://forum.ansible.com/u/Luke_Valenta)\
**Post date:** [July 7, 2015, 12:23am UTC](https://forum.ansible.com/t/unable-to-set-up-nfs-on-ec2-instances-launched-using-ansible/18695/2 "2015-07-07T00:23:24Z")

</div>

Bug solved. I was not specifying the correct security group. I had confused ansible groups with ec2 security groups in my code.
