ansible.posix
ansible.posix copied to clipboard
Change of mount opts doesn't work as expected
SUMMARY
ISSUE TYPE
- Bug Report
COMPONENT NAME
ansible.posix.mount
ANSIBLE VERSION
ansible [core 2.12.5]
config file = /home/jerome/.ansible.cfg
configured module search path = ['/home/jerome/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jerome/.local/lib/python3.9/site-packages/ansible
ansible collection location = /home/jerome/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jerome/.local/bin/ansible
python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
jinja version = 3.0.3
libyaml = True
COLLECTION VERSION
CONFIGURATION
HOST_KEY_CHECKING(/home/jerome/.ansible.cfg) = False
INTERPRETER_PYTHON(/home/jerome/.ansible.cfg) = /usr/bin/python3
MAX_FILE_SIZE_FOR_DIFF(/home/jerome/.ansible.cfg) = 999999999
RETRY_FILES_ENABLED(/home/jerome/.ansible.cfg) = False
OS / ENVIRONMENT
Client : Ubuntu 21.10 Host : Ubuntu 20.04
STEPS TO REPRODUCE
I've got the following initial configuration in my playbook :
- name: Mount & Configure /my/path
mount:
path: /my/path
src: 1.2.3.4:/myhost/mydir
fstype: nfs
opts: "rw,_netdev,mountproto=tcpn"
state: mounted
execution of the mount command on the host give the following line :
1.2.3.4:/myhost/mydir on /my/path type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=1.2.3.4,mountvers=3,mountport=1050,mountproto=tcp,local_lock=none,addr=1.2.3.4,_netdev)
I want to enable nfs no cache, I edit the mount task in my playbook adding nocp on opts parameter:
- name: Mount & Configure /my/path
mount:
path: /my/path
src: 1.2.3.4:/myhost/mydir
fstype: nfs
opts: "rw,_netdev,mountproto=tcpn,noac"
state: mounted
I execute my playbook, and all work as expected :
- the task "Mount & Configure /my/path" is in the state CHANGED
- on the host we can find the following line in /etc/fstab :
1.2.3.4:/myhost/mydir /my/path nfs rw,_netdev,mountproto=tcp 0 0
- we can also find the following line while executing "mount" command :
1.2.3.4:/myhost/mydir on /my/path type nfs (rw,relatime,sync,vers=3,rsize=131072,wsize=131072,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noac,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=1.2.3.4,mountvers=3,mountport=1050,mountproto=tcp,local_lock=none,addr=1.2.3.4,_netdev)
Then, I want to enable back the nfs cache. I edit the mount task in my playbook removing the nocp at the of the line of opts parameter:
- name: Mount & Configure /my/path
mount:
path: /my/path
src: 1.2.3.4:/myhost/mydir
fstype: nfs
opts: "rw,_netdev,mountproto=tcpn"
state: mounted
I execute my playbook :
- the task "Mount & Configure /my/path" is in the state CHANGED
- on the host, we can find the following line in /etc/fstab
1.2.3.4:/myhost/mydir /my/path nfs rw,_netdev,mountproto=tcp 0 0
EXPECTED RESULTS
If I execute "mount" in the bash prompt on the host, I expect to see the following line with no mention about the noac option :
1.2.3.4:/myhost/mydir on /my/path type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=1.2.3.4,mountvers=3,mountport=1050,mountproto=tcp,local_lock=none,addr=1.2.3.4,_netdev)
ACTUAL RESULTS
If I execute "mount" in the bash prompt on the host, it displays the following line :
1.2.3.4:/myhost/mydir on /my/path type nfs (rw,relatime,sync,vers=3,rsize=131072,wsize=131072,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noac,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=1.2.3.4,mountvers=3,mountport=1050,mountproto=tcp,local_lock=none,addr=1.2.3.4,_netdev)
We can see that the noac option is still effective on the host.