56 lines
1.4 KiB
YAML
Raw Permalink Normal View History

2025-01-07 22:17:39 +00:00
---
- 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 }}
2025-01-14 21:30:56 +01:00
uid: "{{ item.uid }}"
2025-01-07 22:17:39 +00:00
shell: '{{ bash_path }}'
groups: sudo
append: true
state: present
with_items: "{{ user_details }}"
2025-01-14 21:30:56 +01:00
- name: All hosts | Create the groups
ansible.builtin.group:
name: "{{ item.name }}"
gid: "{{ item.uid }}"
state: present
with_items: "{{ user_details }}"
2025-01-07 22:17:39 +00:00
- name: All hosts | Set up home directory permissions for users
ansible.builtin.file:
path: /home/{{ item.name }}
owner: "{{ item.name }}"
group: "{{ item.name }}"
2025-01-07 22:17:39 +00:00
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 }}"
2025-01-07 22:17:39 +00:00
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