Skip to content

Instantly share code, notes, and snippets.

@z3cka
Last active June 15, 2017 00:12
Show Gist options
  • Save z3cka/ba9c2034ff705b52282b814e66bb8c38 to your computer and use it in GitHub Desktop.
Save z3cka/ba9c2034ff705b52282b814e66bb8c38 to your computer and use it in GitHub Desktop.
# do:
- name: Create user, ansible, with a key & wheel
user:
name: ansible
shell: /bin/bash
groups: wheel
# don't:
- name: Allow the ansible user to sudo to root by adding it to the wheel group in /etc/group
lineinfile:
path: /etc/group
backup: yes
# match 'wheel:x:10:' not followed by 'ansible'
regexp: '(wheel:x:10:(?!ansible))(.*)'
# insert 'ansible' into line
# example:
# before: wheel:x:10:cgrzecka
# after: wheel:x:10:ansible,cgrzecka
line: '\1ansible,\2'
backrefs: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment