- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| defaults | ||
| handlers | ||
| meta | ||
| playbooks | ||
| tasks | ||
| templates | ||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
Base
Configures basic host settings: timezone, locale, hostname, local users, packages, NTP servers, Docker daemon options, and the systemd journal size. Installs qemu-guest-agent on KVM guests.
Requirements
- Debian/Ubuntu host.
ansible.posixcollection whenbasic_setup_usersentries definessh_authorized_keys.
The role installs apt, systemd, locales, and the NTP daemon it uses: systemd-timesyncd on VMs and bare metal, chrony on Proxmox hosts. NTP is skipped inside containers.
Platforms
- Proxmox host: configures the existing
chrony. - Debian VM on Proxmox: installs and configures
systemd-timesyncd, and installsqemu-guest-agent. - LXC/container: skips NTP; time comes from the host.
Variables
| Variable | Default | Description |
|---|---|---|
basic_setup_timezone |
Europe/Berlin |
Timezone set with timedatectl. null leaves it untouched. |
basic_setup_hostname |
{{ inventory_hostname }} |
Hostname to set. null leaves it untouched. |
basic_setup_packages |
[] |
Packages installed with apt before anything else. |
basic_setup_users |
[] |
Local users to create. See Users. |
basic_setup_ntp_servers |
[0.at.pool.ntp.org, 1.at.pool.ntp.org] |
NTP servers for the host's time daemon. |
basic_setup_ntp_fallback_servers |
[0.europe.pool.ntp.org, 0.pool.ntp.org] |
Fallback NTP servers. |
basic_setup_journald_system_max_use |
2G |
Cap for the systemd journal, via /etc/systemd/journald.conf.d/z-custom.conf. null removes the drop-in. |
basic_setup_locale |
English messages, German formats | Locale variables written to /etc/locale.conf and /etc/default/locale. |
basic_setup_manage_docker |
true |
Manage /etc/docker/daemon.json when Docker is installed. |
basic_setup_docker_daemon_options |
basic_setup_docker_daemon_options_defaults |
Docker daemon options written as daemon.json. Override with combine to keep the defaults. |
Usage
Minimal:
- hosts: servers
roles:
- base
Users, packages, and a different timezone:
basic_setup_timezone: Europe/Berlin
basic_setup_packages:
- htop
- vim
basic_setup_users:
- name: conrad
sudo: true
ssh_authorized_keys:
- "{{ lookup('file', '~/.ssh/id_ed25519.pub') }}"
Sudo
sudo: true installs sudo, adds the user to the sudo group, and writes /etc/sudoers.d/<name>:
<name> ALL=(ALL) NOPASSWD: ALL
The file is validated with visudo before it is installed. Removing sudo from an entry does not remove an existing sudoers file.
APT maintenance
The role runs apt with update_cache, upgrade: dist, autoremove, and autoclean on every run.
playbooks/apt.yml is standalone and is not called by the role. It only updates the cache and upgrades packages, without the role's other tasks:
ansible-playbook playbooks/apt.yml
Users
Each entry is passed to ansible.builtin.user and optionally ansible.posix.authorized_key:
| Key | Default | Description |
|---|---|---|
name |
required | Username. |
groups |
unset | Groups to add the user to. |
sudo |
false |
Install sudo, add to the sudo group, grant passwordless sudo. |
append |
true |
Append to the groups instead of replacing them. |
shell |
/bin/bash |
Login shell. |
password |
unset | Pre-hashed password, e.g. from password_hash. |
uid, home |
unset | Explicit UID or home directory. |
create_home |
true |
Create the home directory. |
system |
false |
Create as a system account. |
ssh_authorized_keys |
unset | Public keys installed in ~/.ssh/authorized_keys. |
Removing an entry from basic_setup_users does not delete the account.
Automation user
Create the account used by Ansible with sudo and its key:
basic_setup_users:
- name: ansible
sudo: true
ssh_authorized_keys:
- "{{ lookup('file', '~/.ssh/ansible.pub') }}"
SSH daemon policy (PermitRootLogin, password authentication) belongs to the devsec role, not this one.
Locale
Default: German date, number, currency, and paper formats with English messages. This uses systemd's documented split:
basic_setup_locale:
LANG: de_DE.UTF-8
LC_MESSAGES: en_US.UTF-8
Only these two locales are generated. The role enables them in /etc/locale.gen, runs locale-gen, and writes /etc/locale.conf and /etc/default/locale.
Override without losing the defaults:
basic_setup_locale: >-
{{ basic_setup_locale_defaults
| combine({'LC_MESSAGES': 'de_DE.UTF-8'}) }}
Existing sessions and running services keep their old locale; log in again or restart them.
Docker
When basic_setup_manage_docker is true and /usr/bin/dockerd exists, the role writes /etc/docker/daemon.json and restarts Docker when the file changes.
The default config keeps the json-file driver because the alloy role reads Docker's JSON logs. It caps each log at 50 MB, keeps 5 files, compresses them, and enables live-restore. Existing containers keep their old log options until recreated. The first live-restore rollout still restarts containers once.
Per-host daemon extras combine the defaults instead of replacing them:
basic_setup_docker_daemon_options: >-
{{ basic_setup_docker_daemon_options_defaults
| combine({'data-root': '/data/docker'}) }}
Other daemon settings worth considering per host:
default-address-poolsto avoid overlap with LAN, VPN, or Proxmox networks.default-ulimitsfor high-connection proxies.data-rooton a dedicated disk.registry-mirrorsfor a local pull-through cache.userland-proxy: falseonly when hairpin NAT is known to work.no-new-privileges,userns-remap, and seccomp profiles are hardening decisions; leave them to the devsec role.
NTP
On VMs and bare metal, servers are written to /etc/systemd/timesyncd.conf.d/ntp.conf as NTP= and FallbackNTP=.
On Proxmox hosts, both lists are written as server ... iburst entries to /etc/chrony/conf.d/basic-setup.conf. Chrony has no separate fallback directive; it picks among all reachable sources.
Containers skip NTP; time comes from the host. Override the defaults per host or group:
basic_setup_ntp_servers:
- time.cloudflare.com
basic_setup_ntp_fallback_servers:
- 0.pool.ntp.org
Journald
basic_setup_journald_system_max_use caps how much disk space the journal may use. Without it, journald defaults to roughly 10% of the containing filesystem. Every host ships its container logs through the journal (see the alloy role), so a small disk needs an explicit cap.
QEMU guest agent
On Proxmox KVM guests (ansible_facts["virtualization_role"] == "guest" and ansible_facts["virtualization_type"] == "kvm"), the role installs qemu-guest-agent and enables and starts its service.