Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sudo: properly allow wheel group to use sudo via visudo #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion roles/sudo/files/wheel_group

This file was deleted.

25 changes: 15 additions & 10 deletions roles/sudo/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@
with_dict: '{{ users }}'
when: '"admin" in item.value.groups'

- name: enable sudoers.d support
- name: allow wheel group to use sudo
lineinfile:
path: /etc/sudoers
line: '#includedir /etc/sudoers.d'
dest: /etc/sudoers
state: present
regexp: '^%wheel ALL=\(ALL\) ALL'
insertafter: '^# %wheel ALL=\(ALL\) ALL'
line: '%wheel ALL=(ALL) ALL'
validate: 'visudo -cf %s'

- name: install sudo rule
copy:
src: wheel_group
dest: /etc/sudoers.d/wheel_group
mode: 0644
owner: root
group: root
- name: secure path to protect against attacks
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/bin"'
insertafter: '^# Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"'
line: 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/bin"'
validate: 'visudo -cf %s'