---

- name: "Verify Evolinux sudoers file presence (jessie)"
  ansible.builtin.template:
    src: sudoers_jessie.j2
    dest: /etc/sudoers.d/evolinux
    force: false
    mode: "0440"
    validate: '/usr/sbin/visudo -cf %s'
  register: copy_sudoers_evolinux

- name: "Add user in sudoers file for '{{ user.name }}' (jessie)"
  ansible.builtin.replace:
    dest: /etc/sudoers.d/evolinux
    regexp: '^(User_Alias\s+ADMINS\s+=((?!{{ user.name }}).)*)$'
    replace: '\1,{{ user.name }}'
    validate: '/usr/sbin/visudo -cf %s'
  when: copy_sudoers_evolinux is not changed
