Last active
April 17, 2022 00:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# 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 | |
... |
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
The second option using the mount module appears to be idempotent only after the first run where it makes the mount... weird.