Hi all!

I just spent a few hours trying to get mount to work like I wanted it to. I 
am not mounting anything special, I just want to add the "acl" option to 
whatever disk is mounted at "/". This means that I do not know what the 
source is.

I got some help in #ansible on how to get the source. With a little help, I 
expanded that to being able to extract pass, dump, and options as well. It 
turns out I need *all* of these otherwise the mount module will use the 
defaults.

For example, if I want to set passno to 1 and dump was previously set to 2 
it will be reset dump to the default value of 0. This is not very ideal.

My full final solution was:


- shell: "grep ' / ' /etc/mtab | awk '{print $1}'"
  register: root_device

- shell: "grep ' / ' /etc/mtab | awk '{print $3}'"
  register: root_fstype

- shell: "OPTS=$(grep ' / ' /etc/mtab | awk '{print $4}'); if ! $( echo 
\"$OPTS\" | tr ',' \"\n\" | grep -qx 'acl' ); then OPTS=$OPTS,acl; fi; echo 
$OPTS"
  register: root_options

- shell: "grep ' / ' /etc/mtab | awk '{print $5}'"
  register: root_dump

- shell: "grep ' / ' /etc/mtab | awk '{print $6}'"
  register: root_pass

- mount: name=/ src={{ root_device.stdout }} fstype={{ root_fstype.stdout 
}} state=mounted opts={{ root_options.stdout }} dump={{ root_dump.stdout }} 
passno={{ root_pass.stdout }}


This works well but I end up getting a bunch of change/update requests 
every time since the shell tasks always have to run even if nothing 
actually changes.

Here are my questions:

1) Could mount be updated to read in existing values and populate defaults 
based on those rather than the current hardcoded defaults?

2) Could mount be smart enough to accept either a name or a source and 
guess the rest based on that? Ideally I want to just update the information 
for whatever is mounted at "/" since I might not know what the source was 
if I have several machines.

3) Is there an easier way to do what I'm doing without making any other 
changes? Seems like this is something that should be doable already so 
maybe I'm just missing something.

4) If I wanted to try and implement this, would it be better to try and 
implement it as another module? I'm thinking maybe "mount_option: name=/ 
state=present value=acl" to add an option or "mount_option: 
source=/dev/sdb2 state=missing value=rw" to remove an option.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4590c93d-6c10-4231-867b-b1bcd53bd538%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to