2024-04-01 10:40:20 +02:00

22 lines
656 B
YAML

# tasks file for create_admin_user
- name Add the user with a specific uid and a primary group of "admin"
ansible.builtin.user:
name: "{{ item.name }}"
comment: "{{ item.comment }}"
uid: "{{ item.uid }}"
loop: "{{ admin }}"
- name: Setup authorized key
ansible.posix.authorized_key
user: "{{ item.name }}"
key: "{{ lookup('file', 'pud_key/{{ item.name }}.pub') }}"
loop: "{{ admin }}"
- name: Update sudoers file and validate
ansible.builtin.lineinfile:
dest: /etc/sudoers
insertafter: EOF
line: "{{ item.name }} ALL=(ALL) NOPASSWD: ALL"
regexp: "^{{ item.name }} .*"
state: present
loop: "{{ admin }}"