56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
---
|
|
|
|
- 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 }}
|
|
uid: "{{ item.uid }}"
|
|
shell: '{{ bash_path }}'
|
|
groups: sudo
|
|
append: true
|
|
state: present
|
|
with_items: "{{ user_details }}"
|
|
|
|
- name: All hosts | Create the groups
|
|
ansible.builtin.group:
|
|
name: "{{ item.name }}"
|
|
gid: "{{ item.uid }}"
|
|
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 }}"
|
|
group: "{{ 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 }}"
|
|
group: "{{ item.name }}"
|
|
state: directory
|
|
mode: 0700
|
|
with_items: "{{ user_details }}"
|
|
|
|
- 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
|