Skip to content

Instantly share code, notes, and snippets.

@influx6
Forked from Kickimanjaro/mount-devpts.yaml
Created April 17, 2022 00:29
Show Gist options
  • Save influx6/0bb9e3211dd647726218b62bdf2d77f4 to your computer and use it in GitHub Desktop.
Save influx6/0bb9e3211dd647726218b62bdf2d77f4 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
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment