# ansible autofs mount

**URL:** <https://forum.ansible.com/t/ansible-autofs-mount/28272>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 6, 2018, 7:04pm UTC](https://forum.ansible.com/t/ansible-autofs-mount/28272 "2018-08-06T19:04:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prasanth\_G](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@Prasanth\_G](https://forum.ansible.com/u/Prasanth_G)\
**Post date:** [August 6, 2018, 7:04pm UTC](https://forum.ansible.com/t/ansible-autofs-mount/28272/1 "2018-08-06T19:04:46Z")

</div>

Dear All.  
I am working on a project where we have a scenario in which we have to mount an NFS file system when each time system boots up ( we spin up using AWS/GITLAB CI/CD approach) so each time when i run the pipleline i get new instance with new Private ip, but my NFS( EFS in aws) will remain same and the mount point also.

Environment is as below :

infrastructure is build in AWS via terraform  
configuration management we are using Ansible.

Situation is like this below :

We have to deploy a software which is loaded in S3 bucket , when the gitlab runner build the AMI we mount the NFS file system using normal way of mouting using the ansible and download the binaries in the file system . Once its extracted file system will umount and AWS ami creation will start.

In the deployment phase i have to mount the file system so that RDS can access will start provisioning the application environment , i think the best option is autofs instead of confd ( any suggessions are welcome) but if i use ansible for autofs how i can go for configuration ? i just need to mount the file system during the system boot itself thats it .

Thanks  
CK

---

<div class="post-metadata">

**Author:** ![Prasanth\_G](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@Prasanth\_G](https://forum.ansible.com/u/Prasanth_G)\
**Post date:** [August 7, 2018, 6:10am UTC](https://forum.ansible.com/t/ansible-autofs-mount/28272/2 "2018-08-07T06:10:03Z")

</div>

Dear All.  
Any suggestions ?

Thanks

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [August 7, 2018, 6:17am UTC](https://forum.ansible.com/t/ansible-autofs-mount/28272/3 "2018-08-07T06:17:41Z")

</div>

Is this at first boot only, or at every boot?

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [August 7, 2018, 7:05am UTC](https://forum.ansible.com/t/ansible-autofs-mount/28272/4 "2018-08-07T07:05:19Z")

</div>

Assuming your AMI as the plumbing to mount NFS, mount it in the userdata script, do your load, then unmount it.

Our userdata variable in Ansible for new instances looks like this (non-EFS stuff removed):

user\_data: |  
#cloud-config  
runcmd:

- file\_system\_id=“{{ efs.efs.file\_system\_id }}”
- efs\_directory=“/mnt/efs”

[… other stuff …]

- mkdir -p ${efs\_directory}
- echo “${file\_system\_id}😕 ${efs\_directory} efs defaults,\_netdev 0 0” \>\> /etc/fstab
- mount -a -t efs defaults  
[… copy some stuff off EFS …]  
[… other stuff …]
