--- - name: Load variables include_vars: "{{ ansible_os_family|lower }}.yml" - name: Linux | Set bash path for Linux hosts ansible.builtin.set_fact: bash_path: /bin/bash - name: All hosts | Create the users ansible.builtin.user: name: "{{ item.name }}" home: /home/{{ item.name }} shell: '{{ bash_path }}' groups: sudo append: true state: present with_items: "{{ user_details }}" - name: All hosts | Set up home directory permissions for users ansible.builtin.file: path: /home/{{ item.name }} owner: "{{ item.name }}" state: directory mode: 0700 with_items: "{{ user_details }}" - name: All hosts | Set up ssh directory for users ansible.builtin.file: path: /home/{{ item.name }}/.ssh owner: "{{ item.name }}" state: directory mode: 0700 with_items: "{{ user_details }}" #- name: All hosts | Add ssh keys for allowing connections # ansible.builtin.template: # src: authorized_keys # dest: /home/vinishor/.ssh/authorized_keys # owner: vinishor # mode: 0600 - name: Linux | Correct sudoers file permissions for ansible user ansible.builtin.file: path: "/etc/sudoers.d/ansible" owner: root group: root mode: 0640 - name: Linux | Define MOTD file ansible.builtin.shell: cmd: figlet -t {{ inventory_hostname_short | quote }} > /etc/motd