Reputation: 809
What does the mount
module do exactly?
I have the following two steps in shell
:
vi /etc/fstab
#edit an already existing entry in the file. The path of this entry is: /
mount -o remount /
I would like to perform these tasks on numerous machines thus I would like to use Ansible for the job. However I'm not sure Ansible performs the second step. Based on he documentation the mount
module is rather an fstab
editor. Or am I wrong?
While testing I saw that Ansible in fact edited fstab
as I wanted, but I'm not sure if it did a remount
to "activate" the changes. Ansible code:
- name: Add userquota to fstab
mount:
path: /
state: present
opts: errors=remount-ro,usrquota,grpquota
fstype: ext4
src: LABEL=cloudimg-rootfs
Is it enough in it self or do I need to perform he following step, too? Or does he previous step contains this command? Is it redundant or not?
- name: Remount root filesystem
shell: mount -o remount /
Upvotes: 2
Views: 14483
Reputation: 47
Just change "state: present" to "state: mounted" and modify the name:
- name: Add userquota to fstab and remount /
mount:
path: /
state: mounted
opts: errors=remount-ro,usrquota,grpquota
fstype: ext4
src: LABEL=cloudimg-rootfs
Upvotes: 1
Reputation: 68024
Q: "What does the mount module do exactly?"
A: Quoting from mount. Parameter state:
Q: "Based on the documentation the mount module is rather an fstab editor. Or am I wrong?"
A: Yes. You're wrong.
Q: "Ansible in fact edited fstab as I wanted, but I'm not sure if it did a remount to "activate" the changes. Do I need to perform
shell: mount -o remount /
? Or does the previous step contains this command? Is it redundant or not?
A: Yes. It is redundant. No. You don't have to remount the entry. When state: mounted
, the entry has already been mounted, and the fstab entry hasn't changed then there is no reason to remount the entry. If the entry hasn't been mounted yet then state: mounted
will mount it.
Upvotes: 5