Skip to content

Instantly share code, notes, and snippets.

@karayok
Created February 19, 2018 03:29
Show Gist options
  • Save karayok/a0f0a13be38ae0382f4dd23b1c2816b1 to your computer and use it in GitHub Desktop.
Save karayok/a0f0a13be38ae0382f4dd23b1c2816b1 to your computer and use it in GitHub Desktop.
Ansible role to add sudoers
# role/user/tasks/main.yml
- name: Add sudoers settings
become: yes
template:
dest: '/etc/sudoers.d/bar'
src: 'sudoers-myapp'
mode: 0440
tags: user-group
- name: Restart sshd
service:
name: ssh
state: restarted
tags: user-group
# role/user/templates/sudoers-myapp
Cmnd_Alias MY_APP = /bin/systemctl start myappd.service , /bin/systemctl stop myappd.service , /bin/systemctl status myappd.service
bar ALL = (root) NOPASSWD:/bin/su, MY_APP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment