init commit

This commit is contained in:
2025-07-21 14:26:07 -05:00
commit 6a683a7a38
25 changed files with 635 additions and 0 deletions

35
playbooks/create-user.yml Normal file
View File

@@ -0,0 +1,35 @@
---
- name: Create a user with SSH access and optional groups
hosts: all
become: true
gather_facts: false
vars:
username: "{{ username }}"
authorized_key: "{{ authorized_key }}"
extra_groups: "{{ extra_groups | default('') }}"
extra_groups_list: "{{ extra_groups.split(',') | map('trim') | list if extra_groups else [] }}"
default_shell: "{{ default_shell | default('/bin/bash') }}"
tasks:
- name: Ensure each extra group exists
ansible.builtin.group:
name: "{{ item }}"
state: present
loop: "{{ extra_groups_list }}"
when: extra_groups_list | length > 0
- name: Ensure user account exists
ansible.builtin.user:
name: "{{ username }}"
shell: "{{ default_shell }}"
groups: "{{ extra_groups_list }}"
append: true
create_home: true
state: present
- name: Set authorized SSH key
ansible.builtin.authorized_key:
user: "{{ username }}"
key: "{{ authorized_key }}"
state: present