Skip to content

Instantly share code, notes, and snippets.

@Kickimanjaro
Last active April 17, 2022 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Kickimanjaro/0cea025219007b507de724a3e3a30909 to your computer and use it in GitHub Desktop.
Save Kickimanjaro/0cea025219007b507de724a3e3a30909 to your computer and use it in GitHub Desktop.
I am having trouble making the mount command here idempotent. I think it should work the way I've written it, but it isn't.
---
# I want to verify that /dev/pts is mounted, and if not, mount it.
# Manually, this is simply: mount devpts /dev/pts -t devpts
# I want the resulting playbook to be idempotent and support the --check flag
- hosts: test
remote_user: testroot
tasks:
# The simple "command" way to do this.
- name: mount devpts with command module (this is idempotent thanks to the creates bit but command does not support --check)
command: "mount devpts /dev/pts -t devpts"
args:
creates: /dev/pts/ptmx
# The better way to do this, with the "mount" module.
- name: mount devpts with mount module (not idempotent, --check says changed every time)
mount:
path: /dev/pts
src: devpts # I think this could be the issue but unsure how to best do this
fstype: devpts
state: present
...
@Kickimanjaro
Copy link
Author

The second option using the mount module appears to be idempotent only after the first run where it makes the mount... weird.

@Kickimanjaro
Copy link
Author

Some folks in the ansible IRC explained that this is because mount mostly/only cares about fstab and that I should be looking at udev instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment