1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_collection_users.git synced 2024-08-16 10:29:50 +02:00
ansible_collection_users/roles/admin/tasks/users.yml

26 lines
872 B
YAML

---
- name: Give admins superpower
become: true
community.general.sudoers:
name: "{{ user.name }}-superpowers"
user: "{{ user.name }}"
state: 'present'
commands: "{{ user.admin_commands | default('ALL') }}"
nopassword: "{{ user.admin_nopassword | default(false) }}"
loop: "{{ _l3d_users__merged_users }}"
loop_control:
label: "user={{ user.name }}"
loop_var: user
when: user.state | default ('present') == 'present' and user.admin | default(false) | bool
- name: Remove superpowers from Users
become: true
community.general.sudoers:
name: "{{ user.name }}-superpowers"
state: 'absent'
user: "{{ user.name }}"
loop: "{{ _l3d_users__merged_users }}"
loop_control:
label: "user={{ user.name }}"
loop_var: user
when: user.state | default ('present') == 'present' and not user.admin | default(false) | bool