---

# Sudo tasks

- name : Create include directories for sudo
  file :
    path : "/etc/sudoers.d/{{ item }}"
    state : directory
    group : root
    owner : root
    mode  : "0700"
  with_items : "{{ account_management_sudo_directories }}"


- name : Add include rules for new sudo directories
  lineinfile :
    dest : "/etc/sudoers"
    line : "#includedir /etc/sudoers.d/{{ item }}"
  with_items : "{{ account_management_sudo_directories }}"


- name  : Add sudo rules for groups and users
  template :
    src    : "{{ role_path }}/templates/sudoers_rules.j2"
    dest   : "/etc/sudoers.d/{{ item.sudo_sub_dir }}/{{ item.name }}"
  with_items :
    - "{{ account_management_groups }}"
    - "{{ account_management_users }}"

---

# Sudo tasks

- name : Create include directories for sudo
  file :
    path : "/etc/sudoers.d/{{ item }}"
    state : directory
    group : root
    owner : root
    mode  : "0755"
  with_items : "{{ account_management_sudo_directories }}"


- name : Add include rules for new sudo directories
  lineinfile :
    dest : "/etc/sudoers"
    line : "#includedir /etc/sudoers.d/{{ item }}"
  with_items : "{{ account_management_sudo_directories }}"


- name  : Add sudo rules for groups and users
  template :
    src    : "{{ role_path }}/templates/sudoers_rules.j2"
    dest   : "/etc/sudoers.d/{{ item.sudo_sub_dir }}/{{ item.name }}"
  with_items :
    - "{{ account_management_groups }}"
    - "{{ account_management_users }}"

Update permission for sudoers.d subdirectories
Update permission for sudoers.d subdirectories