--- - block: - name: Create common groups group: name: "{{ item }}" state: present loop: "{{ users_default_groups }}" - name: Create common users user: name: "{{ item.name }}" groups: "{{ item.groups | default([]) | join(',') or omit }}" append: yes password: "{{ item.password | default(omit) | password_hash('sha512',65534 | random(seed=inventory_hostname) | string) }}" shell: "{{ item.shell | default('/bin/bash') }}" loop: "{{ users_default_users }}" loop_control: label: "{{ item.name }}" become: True become_user: root