Week 11 practice
This practice will hone your system automation skills with ansible.
If you are using terraform to create your machines, they need to be able to speak NFS to each other so you will need to open the security group to udp and tcp 2049. (Change your terraform file)
Tasks
- Create an ansible inventory file that has at least 3 ubuntu machines in it. Put one of your machines in a group called
nfsserver
. The other 2 can be in a group calledclients
. - Create a playbook that will automate the creation of an NFS share:
In particular, it should do the following:
* Make sure that nfs-kernel-server
is installed on the NFS server machine. (the one in the nfsserver
group). You likely will have to update packages to install this.
* should automatically create a /ansible_shares/fruit
directory on your nfs server.
* Make sure that the correct lines appear in /etc/exports
on your nfs server using the lineinfile
module.
+ The line that should appear should look like this: /ansible_shares/fruit *(rw,sync,no_subtree_check)
* Restart the nfs service
* make sure nfs-common
is installed on the client machines.
* Connect to each of your client machines and mount the export to /nfs_share/fruits
. You will probably also have to have ansible create that directory. Look for the mount module. The remote machine will be the ip of your nfs server
. The remote share is /ansible_shares_fruit
.
To verify that everything is working and that the new share is mounted, you can manually do a df
on the client machines after your playbook has executed.
If you get stuck, I have recreated the server one here. Here is my inventory file.
You run the playbook like ansible-playbook -i inventory soln.yml -K
.
Last Updated 02/07/2025