--- - hosts: centos8 become: true vars: sudoers: ansible tasks: - name: add several users to the system user: name: "{{ item.name }}" comment: "{{ item.fullname }}" uid: "{{ item.uid }}" groups: "{{ item.groups }}" state: present with_items: - { name: bofh, fullname: "Bastard Operator from Hell", uid: 1020, groups: "wheel, users" } - { name: ruben, fullname: "Ruben Nausch", uid: 1010, groups: wheel } - { name: ansible, fullname: "Ansible Systemuser", uid: 2003, groups: wheel } - name: Initial password generation for each user shell: usermod -p $(echo '{{ item.secret }}' | openssl passwd -1 -stdin) {{ item.name }} with_items: - { name: bofh, secret: "/ImTAxBwi++W2Y26195+Q72GbH73i/zQyaq12wsx" } - { name: ruben, secret: "lop5YtypT+E6qhOjpZEoAlnyiLH7HlIF1k212qyo" } - { name: ansible, secret: "X4z3AEx6WZ2+DDzvuzjx0mBERQ-o03f12qwPOSyx" } - name: Set authorized keys for each user authorized_key: user: "{{ item.name }}" state: present key: "{{ lookup('file', '/home/django/ansible/authkeys/{{ item.name }}.pub') }}" with_items: - {name: bofh } - {name: ruben } - {name: ansible } - include_tasks: 02_passwd_sudo_wheel.yml ...