Skip to content

Commit

Permalink
Run sudoers related tasks after necessary packages are installed.
Browse files Browse the repository at this point in the history
Otherwise on system without sudo package, playbook run will fail.
  • Loading branch information
hanru committed May 3, 2017
1 parent 1c11027 commit e974a6b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---

# Users
- include: users.yml

# SSH and sudoers
- include: ssh.yml

# System and services
- include: system.yml

# Users and sudoers
- include: users.yml

# UFW basic rules
- include: ufw.yml
when: di_ufw_enabled
20 changes: 0 additions & 20 deletions tasks/ssh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,3 @@
- regexp: '^AllowUsers'
line: 'AllowUsers {{ di_ssh_allow_users }}'
notify: restart ssh

- name: configure password sudoers
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^{{ item }}'
line: '{{ item }} ALL=(ALL) ALL'
validate: 'visudo -cf %s'
with_items: '{{ di_sudoers_password }}'
when: di_sudoers_password | length > 0

- name: configure passwordless sudoers
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^{{ item }}'
line: '{{ item }} ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
with_items: '{{ di_sudoers_passwordless }}'
when: di_sudoers_passwordless | length > 0
20 changes: 20 additions & 0 deletions tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,23 @@
update_password: on_create
with_items: '{{ di_add_users }}'
when: di_add_users | length > 0

- name: configure password sudoers
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^{{ item }}'
line: '{{ item }} ALL=(ALL) ALL'
validate: 'visudo -cf %s'
with_items: '{{ di_sudoers_password }}'
when: di_sudoers_password | length > 0

- name: configure passwordless sudoers
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^{{ item }}'
line: '{{ item }} ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
with_items: '{{ di_sudoers_passwordless }}'
when: di_sudoers_passwordless | length > 0

0 comments on commit e974a6b

Please sign in to comment.