feat: Set up timezone and users and groups on system host

This commit is contained in:
Marty Oehme 2025-11-19 14:35:30 +01:00
parent b493485b90
commit 2fc23d9774
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 38 additions and 0 deletions

View file

@ -1,4 +1,17 @@
---
system_timezone: "Europe/Berlin"
system_users:
- name: marty
groups:
- marty
- data
- incus-admin
- name: data
groups:
- data
create_home: false
shell: /sbin/nologin
system_authorized_keys:
- "{{ lookup('file', '~/.ssh/keys/bob.pub') }}"

View file

@ -36,6 +36,31 @@
- packages
become: true
- name: Set correct timezone
community.general.timezone:
name: "{{ system_timezone }}"
when: "system_timezone"
become: true
- name: Create necessary groups
ansible.builtin.group:
name: "{{ item }}"
state: present
loop: "{{ system_users | map(attribute='groups') | flatten | unique }}"
when: "system_users"
become: true
- name: Set up system users
ansible.builtin.user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
append: "{{ item.append | default(true) }}"
create_home: "{{ item.create_home | default(false) }}"
shell: "{{ item.shell | default('/bin/bash') }}"
loop: "{{ system_users }}"
when: "system_users"
become: true
- name: Add authorized SSH keys
ansible.posix.authorized_key:
user: marty # FIXME: don't hardoce user