Author SHA1 Message Date
kris a1ef6e76a5 Migrate Gitea to rootless Podman / SELinux
- Front git-over-SSH with host sshd and live key lookup
- Build and load custom SELinux policies oci_log and gitea_ssh
2026-09-01 01:42:33 -04:00
kris 601a889172 Fix forward-ssh.sh shebang 2026-08-23 02:37:03 -04:00
kris ccd04de8be Follow Ruby constant conventions for playbook var 2026-05-16 10:08:31 -04:00
kris 42fb86f5b1 Fix restart list to only include changed projects 2026-04-10 21:29:06 -04:00
kris 19a65cb742 Add zrepl role 2026-02-25 22:36:37 -05:00
kris 7404bab63f Set SSH UFW rule via role default 2026-02-24 00:50:20 -05:00
kris 929d549217 Enable SELinux deployment in dev config 2026-02-24 00:18:34 -05:00
kris 2bd80bcfed Simplify libvirt role configuration 2026-02-08 13:43:05 -05:00
kris 46e289d249 Add podman_compose tag for deployments 2026-02-02 23:47:53 -05:00
kris e7dd861d7a Add SELinux certbot_acmesh bool for Certbot DNS-01 2026-01-25 15:59:36 -05:00
kris cb828bdf53 Fix SELinux context for Cloudflare API files 2026-01-25 15:27:12 -05:00
kris 213e7ed175 Fix podman SSH key paths and add registry support
- Configure SELinux to permit nginx network connections
2026-01-25 13:01:29 -05:00
kris e2e5fdcd67 Add WireGuard routing and Podman playbook 2026-01-15 00:47:04 -05:00
kris 39e8f78adf Add SELinux support to the base role 2026-01-13 01:07:29 -05:00
kris ac33f8bf7d Optional IPv6 in nginx confs 2026-01-10 10:48:29 -05:00
kris d3a6b22199 Fix ansible-lint warnings in base and proxy roles 2026-01-10 10:36:08 -05:00
kris a3f723885d Prefix base role variables 2025-12-31 19:11:58 -05:00
kris 2298ca008e Add users tag to user management tasks 2025-11-26 20:07:28 -05:00
kris c713317e49 Add cron job deployment to base role 2025-11-24 16:35:11 -05:00
kris e5541315ec Implement Git-based script deployment system 2025-11-24 15:13:58 -05:00
kris 00814cd6b5 Implement Podman-based Docker Compose projects 2025-11-17 22:15:26 -05:00
kris 6c3aa6d257 Fix boolean defaults in Ansible conditionals 2025-11-07 21:48:21 -05:00
kris 337aa57c6f Add docker tag to compose deployment tasks 2025-11-07 21:22:49 -05:00
kris d954c64e23 Add Podman deployment configuration 2025-08-07 00:24:58 -04:00
kris ccf6b10a0e Add GPG key and reorganize dockerbox configuration
- Add new primary GPG key in dev config for compose repos
- Slight reorganization of the dockerbox production playbook
- Remove group management in the docker role
- Move HSTS inside the location block
- Add git ignore entry for .ansible files
- Add X-Forwarded-Proto proxy header
2025-03-26 22:07:06 -04:00
kris bd8eca0466 Remove redundant group management for Docker users
- Minor formatting updated
2025-01-19 17:48:45 -05:00
kris 56c3721a5e Add flexible home and group controls for users 2025-01-19 16:28:54 -05:00
kris 77c9b12186 Add multi-domain support for Jellyfin
- Allow Jellyfin to operate on multiple domains via Host rule config
- Move Cloudflare API tokens from Ansible inventory to manual file
- Minor formatting
2024-12-29 02:22:46 -05:00
kris 3102c621f0 Add optional IP restriction for nginx site configs 2024-10-19 21:08:15 -04:00
kris e3f03edf3f Use file-based preshared keys for WireGuard
- Include proxy role in standard Docker playbook
2024-10-13 22:27:27 -04:00
kris f481a965dd Update Samba and WireGuard configuration
- Adjust Samba config file permissions to 644
- Introduce PresharedKey option in WireGuard config template
2024-09-10 22:35:20 -04:00
kris a0aa289c05 Restrict GitHub Actions to a dedicated branch
- The Vagrant testing setup on macos-latest is broken
- Temporary measure until fixed or abandoned
2024-09-10 22:11:31 -04:00
63 changed files with 1491 additions and 241 deletions
+3 -2
View File
@@ -3,8 +3,9 @@ name: homelab-ci
on:
push:
branches:
- main
- testing
- github_actions
# - main
# - testing
jobs:
homelab-ci:
+2 -1
View File
@@ -1,4 +1,5 @@
.ansible*
/environments/
.playbook
.vagrant*
.vscode
/environments/
Vendored
+5 -5
View File
@@ -9,16 +9,16 @@ if File.exist?(settings_path)
settings = YAML.load_file(settings_path)
end
VAGRANT_BOX = settings['VAGRANT_BOX'] || 'debian/bookworm64'
VAGRANT_BOX = settings['VAGRANT_BOX'] || 'krislamo.org/debian13'
VAGRANT_CPUS = settings['VAGRANT_CPUS'] || 2
VAGRANT_MEM = settings['VAGRANT_MEM'] || 2048
SSH_FORWARD = settings['SSH_FORWARD'] || false
# Default to shell environment variable: PLAYBOOK (priority #1)
PLAYBOOK=ENV["PLAYBOOK"]
if !PLAYBOOK || PLAYBOOK.empty?
playbook=ENV["PLAYBOOK"]
if !playbook || playbook.empty?
# PLAYBOOK setting in .vagrant.yml (priority #2)
PLAYBOOK = settings['PLAYBOOK'] || 'default'
playbook = settings['PLAYBOOK'] || 'default'
end
Vagrant.configure("2") do |config|
@@ -42,7 +42,7 @@ Vagrant.configure("2") do |config|
config.vm.provision "ansible" do |ansible|
ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles"
ansible.compatibility_mode = "2.0"
ansible.playbook = "dev/" + PLAYBOOK + ".yml"
ansible.playbook = "dev/" + playbook + ".yml"
ansible.raw_arguments = ["--diff"]
end
end
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# docker
docker_users:
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# Import my GPG key for git signature verification
root_gpgkeys:
+6 -2
View File
@@ -1,11 +1,15 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# Import my GPG key for git signature verification
root_gpgkeys:
- name: kris@lamoureux.io
id: 42A3A92C5DA0F3E5F71A3710105B748C1362EB96
# Older key, but still in use
- name: kris@lamoureux.io
id: FBF673CEEC030F8AECA814E73EDA9C3441EDA925
server: keyserver.ubuntu.com
# proxy
proxy:
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
users:
git:
+2 -2
View File
@@ -1,8 +1,8 @@
debian_version: 10.5.0
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# libvirt
libvirt_users: vagrant
+2 -2
View File
@@ -1,8 +1,8 @@
base_domain: local.krislamo.org
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
users:
jellyfin:
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# minecraft
# Agree to EULA to start service in Vagrant
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# docker
docker_users:
+60
View File
@@ -0,0 +1,60 @@
##############
#### base ####
##############
selinux:
state: enforcing
base_allow_reboot: true
base_manage_network: false
root_gpgkeys:
- id: 42A3A92C5DA0F3E5F71A3710105B748C1362EB96
scripts:
trusted_keys:
- id: 42A3A92C5DA0F3E5F71A3710105B748C1362EB96
repos:
- name: dotfiles
url: https://github.com/krislamo/dotfiles
version: 999d745710b9db500e82d1a0d0107ac5d623a669
scripts:
- src: gotify/.local/bin/gotify
dest: /usr/local/bin/gotify
################
#### proxy #####
################
proxy:
servers:
- domain: music.local.krislamo.org
proxy_pass: http://127.0.0.1:4533
################
#### podman ####
################
podman_label:
- path: /home/vagrant/navidrome
label: system_u:object_r:container_file_t:s0
owner: vagrant
group: vagrant
podman_compose:
vagrant:
root: /opt/oci
trusted_keys:
- id: 42A3A92C5DA0F3E5F71A3710105B748C1362EB96
compose:
- name: navidrome
url: https://github.com/krislamo/navidrome
version: 305f92cff143c0d497d21277145f605d9da830de
enabled: true
accept_newhostkey: true # Consider verifying manually instead
env:
VERSION: latest
BASEURL: https://music.local.krislamo.org
MUSIC: /home/vagrant/navidrome
LASTFM_ENABLED: "false"
LASTFM_APIKEY: "n/a"
LASTFM_SECRET: "n/a"
+2 -2
View File
@@ -1,8 +1,8 @@
base_domain: local.krislamo.org
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
users:
git:
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
#mail:
# host: smtp.gmail.com
+2 -2
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# UniFi version
unifi_version: 6.1.71
+68
View File
@@ -0,0 +1,68 @@
##############
#### base ####
##############
base_allow_reboot: true
base_manage_network: false
selinux:
state: enforcing
permissive_domains:
# logind drops its D-Bus connection under enforcing on trixie and never
# reconnects; pidfs/refpolicy gap. https://trello.com/c/x49s4EdL
- systemd_logind_t
users:
git:
uid: 1001
gid: 1001
home: true
system: true
root_gpgkeys:
- name: kris@lamoureux.io
id: 42A3A92C5DA0F3E5F71A3710105B748C1362EB96
###############
#### proxy ####
###############
base_domain: local.krislamo.org
proxy:
servers:
- domain: "git.{{ base_domain }}"
proxy_pass: "http://127.0.0.1:3000"
################
#### podman ####
################
podman_compose:
git:
root: /opt/oci
trusted_keys:
- id: 42A3A92C5DA0F3E5F71A3710105B748C1362EB96
compose:
- name: gitea
url: https://github.com/krislamo/gitea
version: 84e5880484e803fdcf53c7f70b699988d28021d0
enabled: true
env:
DATA: "{{ gitea_data }}"
SSH_DIR: "{{ gitea_data }}/git/.ssh"
USER_UID: "{{ gitea_uid }}"
USER_GID: "{{ gitea_uid }}"
SE_LEVEL: "{{ gitea_se_level }}"
DOMAIN: "git.{{ base_domain }}"
PROXY_TRUSTED_PROXIES: "{{ gitea_trusted_proxies }}"
DB_HOST: "{{ gitea.DB_HOST }}"
DB_NAME: "{{ gitea.DB_NAME }}"
DB_USER: "{{ gitea.DB_USER }}"
DB_PASSWD: "{{ gitea.DB_PASSWD }}"
###############
#### gitea ####
###############
gitea:
DB_HOST: host.containers.internal
DB_NAME: gitea
DB_USER: gitea
DB_PASSWD: password
+2 -3
View File
@@ -1,6 +1,6 @@
# base
allow_reboot: false
manage_network: false
base_allow_reboot: false
base_manage_network: false
# docker
docker_users:
@@ -22,7 +22,6 @@ wordpress_multisite: true
# database settings
wordpress_dbversion: latest
wordpress_dbpass: password
# multisite (enable in admin panel then uncomment)
#wordpress_rule: "Host(`{{ wordpress_domain }}`) ||
# Host(`site1.{{ wordpress_domain }}`) ||
+9
View File
@@ -0,0 +1,9 @@
- name: Install Podman server
hosts: all
become: true
vars_files:
- host_vars/podman.yml
roles:
- base
- proxy
- podman
+11
View File
@@ -0,0 +1,11 @@
- name: Install VPS Server
hosts: all
become: true
vars_files:
- host_vars/vps.yml
roles:
- base
- proxy
- mariadb
- podman
- gitea
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Finds the SSH private key under ./.vagrant and connects to
# the Vagrant box, port forwarding localhost ports: 8443, 443, 80, 22
+1
View File
@@ -4,4 +4,5 @@
roles:
- base
- jenkins
- proxy
- docker
+3 -3
View File
@@ -3,9 +3,9 @@
become: true
roles:
- base
- jenkins
- docker
- mariadb
- traefik
- nextcloud
- jenkins
- prometheus
- nginx
- proxy
+7
View File
@@ -0,0 +1,7 @@
- name: Install Podman server
hosts: "{{ PLAYBOOK_HOST | default('none') }}"
become: true
roles:
- base
- proxy
- podman
+10 -6
View File
@@ -1,10 +1,10 @@
allow_reboot: true
manage_firewall: true
manage_network: false
network_type: static
locale_default: en_US.UTF-8
base_allow_reboot: true
base_manage_firewall: true
base_manage_network: false
base_network_type: static
base_locale_default: en_US.UTF-8
packages:
base_packages:
- apache2-utils
- cryptsetup
- curl
@@ -20,3 +20,7 @@ packages:
- tree
- vim
- wget
base_scripts: /srv/.scripts
base_ssh_ufw_rule: limit
+3 -1
View File
@@ -3,11 +3,13 @@
msg: "Reboot initiated by Ansible"
connect_timeout: 5
listen: reboot_host
when: allow_reboot
when: base_allow_reboot
- name: Reconfigure locales
ansible.builtin.command: dpkg-reconfigure -f noninteractive locales
changed_when: false
listen: reconfigure_locales
when: not ansible_check_mode
- name: Restart WireGuard
ansible.builtin.service:
+13 -2
View File
@@ -8,6 +8,17 @@
name: fail2ban
state: present
- name: Ensure Fail2ban's log file is correctly labelled
ansible.builtin.file:
path: /var/log/fail2ban.log
state: touch
mode: "0640"
access_time: preserve
modification_time: preserve
setype: fail2ban_log_t
when: selinux is defined and selinux is not false
notify: restart_fail2ban
- name: Deny incoming traffic by default
community.general.ufw:
default: deny
@@ -18,10 +29,10 @@
default: allow
direction: outgoing
- name: Allow OpenSSH with rate limiting
- name: "{{ base_ssh_ufw_rule | capitalize }} OpenSSH"
community.general.ufw:
name: ssh
rule: limit
rule: "{{ base_ssh_ufw_rule | default('limit') }}"
- name: Remove Fail2ban defaults-debian.conf
ansible.builtin.file:
+2 -2
View File
@@ -9,12 +9,12 @@
- name: Import Firewall tasks
ansible.builtin.import_tasks: firewall.yml
tags: firewall
when: manage_firewall
when: base_manage_firewall
- name: Import Network tasks
ansible.builtin.import_tasks: network.yml
tags: network
when: manage_network
when: base_manage_network
- name: Import Mail tasks
ansible.builtin.import_tasks: mail.yml
+2 -2
View File
@@ -26,7 +26,7 @@
ansible.builtin.template:
src: smb.conf.j2
dest: /etc/samba/smb.conf
mode: "700"
mode: "644"
notify: restart_samba
- name: Start smbd and enable on boot
@@ -43,4 +43,4 @@
from: "{{ item }}"
state: enabled
loop: "{{ samba.firewall }}"
when: manage_firewall
when: base_manage_firewall
+160 -7
View File
@@ -1,16 +1,68 @@
- name: Install useful software
ansible.builtin.apt:
name: "{{ packages }}"
name: "{{ base_packages }}"
state: present
update_cache: true
- name: Get the default policy and basic SELinux utilities
ansible.builtin.apt:
name: ["selinux-basics", "selinux-policy-default", "auditd"]
state: present
when: selinux is defined and selinux is not false
- name: Configure SELinux
ansible.posix.selinux:
state: "{{ selinux.state | default('permissive') }}"
policy: "{{ selinux.policy | default('default') }}"
when: selinux is defined and selinux is not false
- name: Set SELinux permissive domains
community.general.selinux_permissive:
domain: "{{ item }}"
permissive: true
loop: "{{ selinux.permissive_domains | default([]) }}"
when: selinux is defined and selinux is not false
- name: Check for GRUB
ansible.builtin.stat:
path: /etc/default/grub
register: grub_config
when: selinux is defined and selinux is not false
- name: Check if SELinux is already activated in GRUB
ansible.builtin.command: grep -q 'security=selinux' /etc/default/grub
register: selinux_grub
changed_when: false
failed_when: false
when:
- selinux is defined
- selinux is not false
- grub_config.stat.exists
- name: Activate SELinux
ansible.builtin.command: selinux-activate
changed_when: true
when:
- selinux is defined
- selinux is not false
- grub_config.stat.exists
- selinux_grub.rc != 0
register: selinux_activated
- name: Reboot after SELinux activation
ansible.builtin.reboot:
when:
- selinux_activated is changed
- base_allow_reboot
- name: Install GPG
ansible.builtin.apt:
name: gpg
state: present
- name: Check for existing GPG keys
ansible.builtin.command: "gpg --list-keys {{ item.id }} 2>/dev/null"
ansible.builtin.command: >-
gpg --list-keys {{ item.id }} 2>/dev/null
register: gpg_check
loop: "{{ root_gpgkeys }}"
failed_when: false
@@ -18,8 +70,9 @@
when: root_gpgkeys is defined
- name: Import GPG keys
ansible.builtin.command:
"gpg --keyserver {{ item.item.server | default('keys.openpgp.org') }} --recv-key {{ item.item.id }}"
ansible.builtin.command: >-
gpg --keyserver {{ item.item.server | default('keys.openpgp.org') }}
--recv-key {{ item.item.id }}
register: gpg_check_import
loop: "{{ gpg_check.results }}"
loop_control:
@@ -33,7 +86,85 @@
loop: "{{ gpg_check_import.results }}"
loop_control:
label: "{{ item.item.item }}"
when: root_gpgkeys is defined and (not item.skipped | default(false)) and ('imported' not in item.stderr)
when:
- root_gpgkeys is defined
- not item.skipped | default(false)
- "'imported' not in item.stderr"
- name: Create scripts directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "700"
owner: root
group: root
loop:
- "{{ base_scripts }}"
- "{{ base_scripts }}/.keys"
when: scripts is defined
- name: Generate OpenSSH deploy keys for script clones
community.crypto.openssh_keypair:
path: "{{ base_scripts }}/.keys/id_ed25519"
type: ed25519
comment: "{{ ansible_facts['hostname'] }}-deploy-key"
mode: "400"
state: present
when: scripts is defined
- name: Check for git installation
ansible.builtin.apt:
name: git
state: present
when: scripts is defined
- name: Clone external scripts projects
ansible.builtin.git:
repo: "{{ item.url }}"
dest: "{{ base_scripts }}/{{ item.name }}"
version: "{{ item.version }}"
accept_newhostkey: "{{ item.accept_newhostkey | default(false) }}"
gpg_allowlist: >-
{{ (item.trusted_keys | default(scripts.trusted_keys) | default([]))
| map(attribute='id')
| list }}
verify_commit: >-
{{ true if
((item.trusted_keys | default(scripts.trusted_keys)) is defined
and (item.trusted_keys | default(scripts.trusted_keys)))
else false }}
key_file: "{{ base_scripts }}/.keys/id_ed25519"
loop: "{{ scripts.repos }}"
loop_control:
label: "{{ item.url }}"
when: scripts is defined
tags: scripts
- name: Synchronize scripts
ansible.posix.synchronize:
src: "{{ base_scripts }}/{{ item.0.name }}/{{ item.1.src }}"
dest: "{{ item.1.dest }}"
delegate_to: "{{ inventory_hostname }}"
loop: "{{ scripts.repos | default([]) | subelements('scripts') }}"
loop_control:
label: "{{ item.0.name }}: {{ item.1.src }}"
when: scripts is defined and scripts | length > 0
tags: scripts
- name: Deploy cron jobs
ansible.builtin.cron:
name: "{{ item.name }}"
job: "{{ item.job }}"
user: "{{ item.user | default('root') }}"
minute: "{{ item.minute | default('*') }}"
hour: "{{ item.hour | default('*') }}"
day: "{{ item.day | default('*') }}"
month: "{{ item.month | default('*') }}"
weekday: "{{ item.weekday | default('*') }}"
state: "{{ item.state | default('present') }}"
disabled: "{{ item.disabled | default(false) }}"
loop: "{{ cron }}"
when: cron is defined and cron | length > 0
- name: Install NTPsec
ansible.builtin.apt:
@@ -47,7 +178,7 @@
- name: Generate locale
community.general.locale_gen:
name: "{{ locale_default }}"
name: "{{ base_locale_default }}"
state: present
notify: reconfigure_locales
@@ -55,7 +186,7 @@
ansible.builtin.lineinfile:
path: /etc/default/locale
regexp: "^LANG="
line: "LANG={{ locale_default }}"
line: "LANG={{ base_locale_default }}"
- name: Manage root authorized_keys
ansible.builtin.template:
@@ -63,6 +194,7 @@
dest: /root/.ssh/authorized_keys
mode: "400"
when: authorized_keys is defined
tags: users
- name: Create system user groups
ansible.builtin.group:
@@ -73,6 +205,7 @@
loop_control:
label: "{{ item.key }}"
when: users is defined
tags: users
- name: Create system users
ansible.builtin.user:
@@ -80,13 +213,32 @@
state: present
uid: "{{ item.value.uid }}"
group: "{{ item.value.gid }}"
groups: "{{ item.value.groups | default([]) }}"
shell: "{{ item.value.shell | default('/bin/bash') }}"
create_home: "{{ item.value.home | default(false) }}"
home: "{{ item.value.homedir | default('/home/' + item.key) }}"
system: "{{ item.value.system | default(false) }}"
loop: "{{ users | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: users is defined
tags: users
- name: Create Ansible's temporary remote directory for users
ansible.builtin.file:
path: >-
{{ item.value.homedir | default('/home/' + item.key) }}/.ansible/tmp
state: directory
mode: "700"
owner: "{{ item.key }}"
group: "{{ item.value.gid }}"
loop: "{{ users | dict2items }}"
loop_control:
label: "{{ item.key }}"
when:
- users is defined
- item.value.tmp | default(true)
tags: users
- name: Set authorized_keys for system users
ansible.posix.authorized_key:
@@ -97,6 +249,7 @@
loop_control:
label: "{{ item.key }}"
when: users is defined and item.value.key is defined
tags: users
- name: Manage filesystem mounts
ansible.posix.mount:
+22
View File
@@ -18,6 +18,28 @@
src: /etc/wireguard/privatekey
register: wgkey
- name: Check if WireGuard preshared key file exists
ansible.builtin.stat:
path: /etc/wireguard/presharedkey-{{ item.name }}
loop: "{{ wireguard.peers }}"
loop_control:
label: "{{ item.name }}"
register: presharedkey_files
- name: Grab WireGuard preshared key for configuration
ansible.builtin.slurp:
src: /etc/wireguard/presharedkey-{{ item.item.name }}
register: wgshared
loop: "{{ presharedkey_files.results }}"
loop_control:
label: "{{ item.item.name }}"
when: item.stat.exists
- name: Grab WireGuard private key for configuration
ansible.builtin.slurp:
src: /etc/wireguard/privatekey
register: wgkey
- name: Install WireGuard configuration
ansible.builtin.template:
src: wireguard.j2
+1 -1
View File
@@ -1,7 +1,7 @@
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = {{ ansible_hostname }}
netbios name = {{ ansible_facts['hostname'] }}
security = user
map to guest = bad user
dns proxy = no
+32 -1
View File
@@ -1,13 +1,44 @@
[Interface]
# {{ ansible_managed }}
[Interface] # {{ ansible_facts['hostname'] }}
PrivateKey = {{ wgkey['content'] | b64decode | trim }}
Address = {{ wireguard.address }}
{% if wireguard.listenport is defined %}
ListenPort = {{ wireguard.listenport }}
{% endif %}
{%- if wireguard.table is defined %}
Table = {{ wireguard.table }}
{% endif -%}
{%- if wireguard.postup is defined %}
PostUp = {{ wireguard.postup }}
{% endif -%}
{%- if wireguard.predown is defined %}
PreDown = {{ wireguard.predown }}
{% endif %}
{% for peer in wireguard.peers %}
{% if peer.name is defined %}
[Peer] # {{ peer.name }}
{% else %}
[Peer]
{% endif %}
PublicKey = {{ peer.publickey }}
{% if peer.presharedkey is defined %}
PresharedKey = {{ peer.presharedkey }}
{% else %}
{% set preshared_key = (
wgshared.results
| selectattr('item.item.name', 'equalto', peer.name)
| first
).content
| default(none)
%}
{% if preshared_key is not none %}
PresharedKey = {{ preshared_key | b64decode | trim }}
{% endif %}
{% endif %}
{% if peer.endpoint is defined %}
Endpoint = {{ peer.endpoint }}
{% endif %}
+14 -12
View File
@@ -24,15 +24,21 @@
- name: Install/uninstall Docker from Debian repositories
ansible.builtin.apt:
name: ['docker.io', 'docker-compose', 'containerd', 'runc']
name: ["docker.io", "docker-compose", "containerd", "runc"]
state: "{{ 'absent' if docker_official else 'present' }}"
autoremove: true
update_cache: true
- name: Install/uninstall Docker from Docker repositories
ansible.builtin.apt:
name: ['docker-ce', 'docker-ce-cli', 'containerd.io',
'docker-buildx-plugin', 'docker-compose-plugin']
name:
[
"docker-ce",
"docker-ce-cli",
"containerd.io",
"docker-buildx-plugin",
"docker-compose-plugin",
]
state: "{{ 'present' if docker_official else 'absent' }}"
autoremove: true
update_cache: true
@@ -71,7 +77,7 @@
community.crypto.openssh_keypair:
path: "{{ docker_repos_keys }}/id_{{ docker_repos_keytype }}"
type: "{{ docker_repos_keytype }}"
comment: "{{ ansible_hostname }}-deploy-key"
comment: "{{ ansible_facts['hostname'] }}-deploy-key"
mode: "400"
state: present
when: docker_compose_deploy is defined
@@ -95,6 +101,7 @@
loop_control:
label: "{{ item.url }}"
when: docker_compose_deploy is defined
tags: docker
- name: Create directories for docker-compose projects using the systemd service
ansible.builtin.file:
@@ -105,6 +112,7 @@
loop_control:
label: "{{ item.name }}"
when: docker_compose_deploy is defined
tags: docker
- name: Synchronize docker-compose.yml
ansible.posix.synchronize:
@@ -119,6 +127,7 @@
loop_control:
label: "{{ item.name }}"
when: docker_compose_deploy is defined and docker_compose_deploy | length > 0
tags: docker
- name: Set environment variables for docker-compose projects
ansible.builtin.template:
@@ -134,14 +143,7 @@
loop_control:
label: "{{ item.name }}"
when: docker_compose_deploy is defined and item.env is defined
- name: Add users to docker group
ansible.builtin.user:
name: "{{ item }}"
groups: docker
append: true
loop: "{{ docker_users }}"
when: docker_users is defined
tags: docker
- name: Start Docker and enable on boot
ansible.builtin.service:
+8 -3
View File
@@ -1,6 +1,6 @@
# container settings
gitea_name: gitea
gitea_sshport: "222"
gitea_sshport: "2222"
gitea_webport: "3000"
gitea_ssh: "127.0.0.1:{{ gitea_sshport }}"
gitea_web: "127.0.0.1:{{ gitea_webport }}"
@@ -16,7 +16,12 @@ gitea_dbuser: "{{ gitea_name }}"
# proxy settings
gitea_proxy_limit: "1"
gitea_trusted_proxies: "172.16.0.0/12"
gitea_trusted_proxies: "10.89.0.0/16"
# host
gitea_root: "{{ docker_compose_root }}/{{ gitea_name }}"
gitea_root: "{{ podman_compose.git.root }}/{{ gitea_name }}"
gitea_logs: "{{ podman_log_root }}/{{ gitea_name }}"
gitea_data: /srv/gitea
gitea_se_level: "s0:c22,c222"
gitea_uid: 1000
gitea_oci_uid: "{{ podman_subuid_base['git'] | int + gitea_uid | int - 1 }}"
+9
View File
@@ -0,0 +1,9 @@
module gitea_ssh 1.0;
require {
type sshd_t;
type ssh_exec_t;
class file { getattr read open map execute execute_no_trans };
}
allow sshd_t ssh_exec_t:file { getattr read open map execute execute_no_trans };
+5 -5
View File
@@ -1,5 +1,5 @@
- name: Restart Gitea
ansible.builtin.service:
name: "{{ docker_compose_service }}@{{ gitea_name }}"
state: restarted
listen: restart_gitea
- name: Reload ssh
ansible.builtin.systemd_service:
name: ssh
state: reloaded
listen: restart_ssh
+159 -22
View File
@@ -13,7 +13,7 @@
community.mysql.mysql_user:
name: "{{ gitea.DB_USER }}"
password: "{{ gitea.DB_PASSWD }}"
host: '%'
host: "%"
state: present
priv: "{{ gitea.DB_NAME }}.*:ALL"
login_unix_socket: /var/run/mysqld/mysqld.sock
@@ -21,35 +21,36 @@
- name: Create git's .ssh directory
ansible.builtin.file:
path: /home/git/.ssh
owner: git
group: git
mode: "700"
state: directory
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('ssh_home_t', omit) }}
- name: Generate git's SSH keys
community.crypto.openssh_keypair:
path: /home/git/.ssh/id_rsa
owner: git
group: git
mode: "600"
register: gitea_keypair
- name: Label git's SSH keys for sshd access
ansible.builtin.file:
path: "/home/git/.ssh/{{ item }}"
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('ssh_home_t', omit) }}
loop:
- id_rsa
- id_rsa.pub
- name: Find git's public SSH key
ansible.builtin.slurp:
src: /home/git/.ssh/id_rsa.pub
register: git_rsapub
- name: Get stats on git's authorized_keys file
ansible.builtin.stat:
path: /home/git/.ssh/authorized_keys
register: git_authkeys
- name: Create git's authorized_keys file
ansible.builtin.file:
path: /home/git/.ssh/authorized_keys
mode: "600"
state: touch
when: not git_authkeys.stat.exists
- name: Add git's public SSH key to authorized_keys
ansible.builtin.lineinfile:
path: /home/git/.ssh/authorized_keys
regex: "^ssh-rsa"
line: "{{ git_rsapub['content'] | b64decode }}"
register: gitea_rsapub
- name: Create Gitea host script for SSH
ansible.builtin.template:
@@ -57,11 +58,147 @@
dest: /usr/local/bin/gitea
mode: "755"
- name: Install Gitea SSH SELinux policy source
ansible.builtin.copy:
src: gitea_ssh.te
dest: "{{ podman_selinux_dir }}/gitea_ssh.te"
owner: root
group: root
mode: "0644"
register: gitea_selinux_src
when: selinux is defined and selinux is not false
- name: Clear stale Gitea SSH SELinux artifacts
ansible.builtin.file:
path: "{{ podman_selinux_dir }}/gitea_ssh.{{ item }}"
state: absent
loop: [mod, pp]
when:
- selinux is defined and selinux is not false
- gitea_selinux_src is changed
- name: Compile Gitea SSH SELinux policy module
ansible.builtin.command:
cmd: >-
checkmodule -M -m -o {{ podman_selinux_dir }}/gitea_ssh.mod
{{ podman_selinux_dir }}/gitea_ssh.te
creates: "{{ podman_selinux_dir }}/gitea_ssh.mod"
when: selinux is defined and selinux is not false
- name: Package Gitea SSH SELinux policy module
ansible.builtin.command:
cmd: >-
semodule_package -o {{ podman_selinux_dir }}/gitea_ssh.pp
-m {{ podman_selinux_dir }}/gitea_ssh.mod
creates: "{{ podman_selinux_dir }}/gitea_ssh.pp"
when: selinux is defined and selinux is not false
- name: List loaded SELinux policy modules for Gitea
ansible.builtin.command:
cmd: semodule -l
register: gitea_semodule_list
changed_when: false
when: selinux is defined and selinux is not false
- name: Load Gitea SSH SELinux policy module
ansible.builtin.command:
cmd: semodule -i {{ podman_selinux_dir }}/gitea_ssh.pp
register: gitea_semodule
changed_when: gitea_semodule.rc == 0
when:
- selinux is defined and selinux is not false
- gitea_selinux_src is changed or "gitea_ssh" not in gitea_semodule_list.stdout_lines
- name: Configure sshd for Gitea AuthorizedKeysCommand
ansible.builtin.template:
src: gitea_sshd.conf.j2
dest: /etc/ssh/sshd_config.d/gitea.conf
owner: root
group: root
mode: "0644"
validate: /usr/sbin/sshd -t -f %s
notify: restart_ssh
- name: Set SELinux context on Gitea's data directory
community.general.sefcontext:
target: "{{ gitea_data }}(/.*)?"
setype: container_file_t
selevel: "{{ gitea_se_level }}"
state: present
when: selinux is defined and selinux is not false
- name: Create Gitea's data directory
ansible.builtin.file:
path: "{{ gitea_data }}"
state: directory
owner: "{{ gitea_oci_uid }}"
group: "{{ gitea_oci_uid }}"
mode: "0750"
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('container_file_t', omit) }}
selevel: "{{ gitea_se_level }}"
- name: Create Gitea's container-side SSH directories
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
owner: "{{ gitea_oci_uid }}"
group: "{{ gitea_oci_uid }}"
mode: "{{ item.mode }}"
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('container_file_t', omit) }}
selevel: "{{ gitea_se_level }}"
loop:
- { path: "{{ gitea_data }}/git", mode: "0755" }
- { path: "{{ gitea_data }}/git/.ssh", mode: "0700" }
- name: Authorise git's public SSH key inside the container
ansible.builtin.copy:
content: "{{ gitea_rsapub['content'] | b64decode }}"
dest: "{{ gitea_data }}/git/.ssh/authorized_keys"
owner: "{{ gitea_oci_uid }}"
group: "{{ gitea_oci_uid }}"
mode: "0600"
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('container_file_t', omit) }}
selevel: "{{ gitea_se_level }}"
- name: Set SELinux context on Gitea's logging directory
community.general.sefcontext:
target: "{{ gitea_logs }}(/.*)?"
setype: oci_log_t
selevel: "{{ gitea_se_level }}"
state: present
when: selinux is defined and selinux is not false
- name: Create Gitea's logging directory
ansible.builtin.file:
name: /var/log/gitea
name: "{{ gitea_logs }}"
state: directory
mode: "755"
owner: "{{ gitea_oci_uid }}"
group: "{{ gitea_oci_uid }}"
mode: "0755"
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('oci_log_t', omit) }}
selevel: "{{ gitea_se_level }}"
- name: Create Gitea's log file for Fail2ban
ansible.builtin.file:
path: /var/log/oci/gitea/gitea.log
state: touch
owner: "{{ gitea_oci_uid }}"
group: "{{ gitea_oci_uid }}"
mode: "0640"
modification_time: preserve
access_time: preserve
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('oci_log_t', omit) }}
selevel: "{{ gitea_se_level }}"
- name: Install Gitea's Fail2ban filter
ansible.builtin.template:
-19
View File
@@ -1,19 +0,0 @@
# {{ ansible_managed }}
gitea_version={{ gitea_version }}
gitea_name={{ gitea_name }}
gitea_domain={{ gitea_domain }}
gitea_rooturl={{ gitea_rooturl }}
gitea_web={{ gitea_web }}
gitea_ssh={{ gitea_ssh }}
gitea_dbtype={{ gitea_dbtype }}
gitea_dbhost={{ gitea_dbhost }}
gitea_dbname={{ gitea_dbname }}
gitea_dbuser={{ gitea_dbuser }}
gitea_dbpass={{ gitea_dbpass }}
gitea_proxy_limit={{ gitea_proxy_limit }}
gitea_trusted_proxies={{ gitea_trusted_proxies }}
{% if not gitea_signup %}
gitea_disable_registration=true
{% else %}
gitea_disable_registration=false
{% endif %}
@@ -1,36 +0,0 @@
version: '3.7'
services:
gitea:
image: "gitea/gitea:${gitea_version}"
container_name: "${gitea_name}"
ports:
- "${gitea_ssh}:22"
- "${gitea_web}:3000"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- USER_UID={{ getent_passwd.git[1] }}
- USER_GID={{ getent_group.git[1] }}
- GITEA__log__MODE=file
- GITEA__server__ROOT_URL=${gitea_rooturl}
- GITEA__server__DOMAIN=${gitea_domain}
- GITEA__server__SSH_DOMAIN=${gitea_domain}
- GITEA__database__DB_TYPE=${gitea_dbtype}
- GITEA__database__HOST=${gitea_dbhost}
- GITEA__database__NAME=${gitea_dbname}
- GITEA__database__USER=${gitea_dbuser}
- GITEA__database__PASSWD=${gitea_dbpass}
- GITEA__security__INSTALL_LOCK=true
- GITEA__security__REVERSE_PROXY_LIMIT=${gitea_proxy_limit}
- GITEA__security__REVERSE_PROXY_TRUSTED_PROXIES=${gitea_trusted_proxies}
- GITEA__service__DISABLE_REGISTRATION=${gitea_disable_registration}
volumes:
- {{ gitea_volume }}:/data
- /home/git/.ssh:/data/git/.ssh
- /var/log/gitea:/data/gitea/log
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
volumes:
{{ gitea_volume }}:
+1 -10
View File
@@ -2,17 +2,8 @@
[gitea]
enabled = true
filter = gitea
logpath = /var/log/gitea/gitea.log
logpath = {{ gitea_logs }}/gitea.log
maxretry = 10
findtime = 3600
bantime = 900
action = iptables-allports
[gitea-docker]
enabled = true
filter = gitea
logpath = /var/log/gitea/gitea.log
maxretry = 10
findtime = 3600
bantime = 900
action = iptables-allports[chain="FORWARD"]
+3
View File
@@ -0,0 +1,3 @@
# {{ ansible_managed }}
AuthorizedKeysCommand /usr/local/bin/gitea keys -e git -u %u -t %t -k %k
AuthorizedKeysCommandUser git
@@ -15,7 +15,7 @@ services:
networks:
- traefik
labels:
- "traefik.http.routers.{{ jellyfin_router }}.rule=Host(`{{ jellyfin_domain }}`)"
- "traefik.http.routers.{{ jellyfin_router }}.rule=Host({{ jellyfin_domains }})"
{% if traefik_http_only %}
- "traefik.http.routers.{{ jellyfin_router }}.entrypoints=web"
{% else %}
+4 -31
View File
@@ -1,40 +1,13 @@
- name: Install QEMU/KVM
- name: Install QEMU/KVM and libvirt
ansible.builtin.apt:
name: qemu-kvm
state: present
- name: Install Libvirt
ansible.builtin.apt:
name: ["libvirt-clients", "libvirt-daemon-system"]
name: ["qemu-system", "libvirt-clients", "libvirt-daemon-system"]
install_recommends: false
state: present
- name: Add users to libvirt group
ansible.builtin.user:
name: "{{ item }}"
groups: libvirt
append: yes
append: true
with_items: "{{ libvirt_users }}"
when: libvirt_users is defined
- name: Check for NODOWNLOAD file
ansible.builtin.stat:
path: /var/lib/libvirt/images/NODOWNLOAD
register: NODOWNLOAD
- name: Download GNU/Linux ISOs
ansible.builtin.get_url:
url: "{{ item.url }}"
dest: /var/lib/libvirt/images
checksum: "{{ item.hash }}"
owner: libvirt-qemu
group: libvirt-qemu
loop: "{{ libvirt_isos }}"
register: download_isos
when: libvirt_isos is defined and NODOWNLOAD.stat.exists == false
# Prevent downloaded ISOs from being rehashed every run
- name: Create NODOWNLOAD file
ansible.builtin.file:
path: /var/lib/libvirt/images/NODOWNLOAD
state: touch
when: download_isos.changed
+13 -1
View File
@@ -16,10 +16,22 @@
regex: "^bind-address"
line: "bind-address = {{ ansible_facts.docker0.ipv4.address }}"
notify: restart_mariadb
when: ansible_facts['docker0'] is defined
- name: Change the bind-address for rootless containers
ansible.builtin.lineinfile:
path: /etc/mysql/mariadb.conf.d/50-server.cnf
regexp: "^bind-address"
line: "bind-address = 0.0.0.0"
notify: restart_mariadb
when:
- ansible_facts['docker0'] is not defined
- podman_compose is defined
- name: Flush handlers to ensure MariaDB restarts immediately
ansible.builtin.meta: flush_handlers
tags: restart_mariadb
when: ansible_facts['docker0'] is defined or podman_compose is defined
- name: Allow database connections from Docker
community.general.ufw:
@@ -27,4 +39,4 @@
port: "3306"
proto: tcp
src: "{{ item }}"
loop: "{{ mariadb_trust | default(['172.16.0.0/12']) }}"
loop: "{{ mariadb_trust | default(['169.254.0.0/16']) }}"
+1 -1
View File
@@ -23,7 +23,7 @@
name: "{{ docker_compose_service }}@{{ nextcloud_name }}"
state: started
enabled: true
when: nextcloud.ENABLE | default('false')
when: nextcloud.ENABLE | default(false)
- name: Grab Nextcloud container information
community.general.docker_container_info:
+6
View File
@@ -0,0 +1,6 @@
# Default configuration for podman role
podman_log_root: /var/log/oci
podman_nodocker: false
podman_repos_keytype: ed25519
podman_selinux_dir: /usr/share/selinux
podman_ssh_key_path: "{{ ansible_user_dir }}/.ssh"
+22
View File
@@ -0,0 +1,22 @@
# shellcheck shell=sh
: "${UID:=$(id -u)}"
if [ "$UID" -ne 0 ]; then
if [ -z "$XDG_RUNTIME_DIR" ] && [ -d "/run/user/$UID" ]; then
XDG_RUNTIME_DIR="/run/user/$UID"
export XDG_RUNTIME_DIR
fi
PODMAN_SOCKET="$XDG_RUNTIME_DIR/podman/podman.sock"
if [ -S "$PODMAN_SOCKET" ]; then
DOCKER_HOST="unix://$PODMAN_SOCKET"
export DOCKER_HOST
fi
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
if [ -S "$XDG_RUNTIME_DIR/bus" ]; then
DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
export DBUS_SESSION_BUS_ADDRESS
fi
fi
fi
+19
View File
@@ -0,0 +1,19 @@
module oci_log 1.0;
require {
type container_t;
type fail2ban_t;
attribute logfile;
attribute file_type;
attribute non_security_file_type;
class dir { add_name search watch write };
class file { append create getattr open watch };
}
type oci_log_t;
typeattribute oci_log_t file_type, non_security_file_type, logfile;
allow container_t oci_log_t:dir { add_name search write };
allow container_t oci_log_t:file { append create getattr open };
allow fail2ban_t oci_log_t:dir watch;
allow fail2ban_t oci_log_t:file watch;
+33
View File
@@ -0,0 +1,33 @@
- name: Reload systemd manager configuration for all podman users
ansible.builtin.systemd:
daemon_reload: true
scope: user
become: true
become_user: "{{ item }}"
loop: "{{ podman_compose.keys() | list }}"
listen: podman_compose_systemd
- name: Restart docker compose (podman) services
ansible.builtin.systemd:
state: restarted
name: "compose@{{ item.service }}"
scope: user
become: true
become_user: "{{ item.user }}"
loop: "{{ podman_compose_restart_list | default([]) | unique }}"
when: podman_compose_restart_list is defined
listen: podman_compose_restart
- name: Start docker compose (podman) services and enable on boot
ansible.builtin.systemd:
name: "compose@{{ item.service }}"
state: started
enabled: true
scope: user
become: true
become_user: "{{ item.user }}"
loop: "{{ podman_compose_enable_list | default([]) }}"
loop_control:
label: "{{ item.user }}/{{ item.service }}"
when: item.enabled is defined and item.enabled is true
listen: podman_compose_enable
+233
View File
@@ -0,0 +1,233 @@
- name: Get user info for podman compose user
ansible.builtin.getent:
database: passwd
key: "{{ podman_user }}"
register: podman_user_info
tags: podman_compose
- name: Set user-specific variables
ansible.builtin.set_fact:
podman_rootdir: "{{ podman_compose_config.root }}"
podman_userid: "{{ podman_user_info.ansible_facts.getent_passwd[podman_user][1] }}"
podman_homedir: "{{ podman_user_info.ansible_facts.getent_passwd[podman_user][4] }}"
podman_project: "{{ podman_compose_config.compose }}"
podman_repos: "{{ podman_compose_config.root }}/.compose_repos"
tags: podman_compose
- name: Create docker compose (podman) root directory for user
ansible.builtin.file:
path: "{{ podman_rootdir }}"
state: directory
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0700"
- name: Create user systemd directory
ansible.builtin.file:
path: "/home/{{ podman_user }}/.config/systemd/user"
state: directory
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0755"
- name: Install docker compose (podman) systemd service for user
ansible.builtin.template:
src: compose.service.j2
dest: "/home/{{ podman_user }}/.config/systemd/user/compose@.service"
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0644"
notify: podman_compose_systemd
- name: Create directories for cloning docker compose (podman) repositories
ansible.builtin.file:
path: "{{ repo_dir }}"
state: directory
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0700"
loop:
- "{{ podman_repos }}"
loop_control:
loop_var: repo_dir
when:
- podman_project is defined
- podman_project | length > 0
tags: podman_compose
- name: Create .ssh directory for podman compose user
ansible.builtin.file:
path: "{{ podman_homedir }}/.ssh"
state: directory
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0700"
when:
- podman_project is defined
- podman_project | length > 0
tags: podman_compose
- name: Generate OpenSSH deploy keys for docker compose (podman) clones
community.crypto.openssh_keypair:
path: "{{ podman_homedir }}/.ssh/podman-id_{{ podman_repos_keytype }}"
type: "{{ podman_repos_keytype }}"
comment: "{{ ansible_facts['hostname'] }}-{{ podman_user }}-deploy-key"
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0600"
state: present
when: podman_project is defined
tags: podman_compose
- name: Import trusted GPG keys for docker compose (podman) projects
ansible.builtin.command:
cmd: "gpg --keyserver {{ key.keyserver | default('keys.openpgp.org') }} --recv-key {{ key.id }}"
become: true
become_user: "{{ podman_user }}"
loop: "{{ podman_compose_config.trusted_keys }}"
loop_control:
loop_var: key
label: "{{ key.id }}"
changed_when: false
when: podman_compose_config.trusted_keys is defined
tags: podman_compose
- name: Clone external docker compose (podman) projects
ansible.builtin.git:
repo: "{{ project.url }}"
dest: "{{ podman_repos }}/{{ project.name }}"
version: "{{ project.version }}"
accept_newhostkey: "{{ project.accept_newhostkey | default(false) }}"
gpg_allowlist: "{{ (project.trusted_keys |
default(podman_compose_config.trusted_keys | default([]))) |
map(attribute='id') | list }}"
verify_commit: >-
{{
true if
(project.trusted_keys is defined and project.trusted_keys) or
(
podman_compose_config.trusted_keys is defined and
podman_compose_config.trusted_keys
)
else false
}}
key_file: "{{ podman_homedir }}/.ssh/podman-id_{{ podman_repos_keytype }}"
become: true
become_user: "{{ podman_user }}"
loop: "{{ podman_project }}"
loop_control:
loop_var: project
label: "{{ project.url }}"
when:
- podman_project is defined
- podman_project | length > 0
tags: podman_compose
- name: Create directories for docker compose (podman) projects
ansible.builtin.file:
path: "{{ podman_rootdir }}/{{ project.name }}"
state: directory
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0700"
loop: "{{ podman_project }}"
loop_control:
loop_var: project
label: "{{ project.name }}"
when:
- podman_project is defined
- podman_project | length > 0
tags: podman_compose
- name: Synchronize docker-compose.yml
ansible.posix.synchronize:
# noqa jinja[spacing]
src: >-
{{ podman_repos }}/{{ project.name }}/
{{- project.path | default('docker-compose.yml') }}
dest: "{{ podman_rootdir }}/{{ project.name }}/docker-compose.yml"
owner: false
group: false
delegate_to: "{{ inventory_hostname }}"
register: podman_compose_update
notify:
- podman_compose_restart
- podman_compose_enable
loop: "{{ podman_project | default([]) }}"
loop_control:
loop_var: project
label: "{{ project.name }}"
when:
- podman_project is defined
- podman_project | length > 0
tags: podman_compose
- name: Update list of compose projects updated
ansible.builtin.set_fact:
podman_compose_restart_list:
"{{ (podman_compose_restart_list | default([])) +
[{'user': podman_user, 'service': item.project.name}] }}"
loop: "{{ podman_compose_update.results }}"
loop_control:
label: "{{ podman_user }}/{{ item.project.name }}"
when: item.changed | default(false)
tags: podman_compose
- name: Fix ownership of synchronized compose files
ansible.builtin.file:
path: "{{ podman_rootdir }}/{{ project.name }}/docker-compose.yml"
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0664"
loop: "{{ podman_project | default([]) }}"
loop_control:
loop_var: project
label: "{{ project.name }}"
when:
- podman_project is defined
- podman_project | length > 0
tags: podman_compose
- name: Set environment variables for docker compose (podman) projects
ansible.builtin.template:
src: compose-env.j2
dest: "{{ podman_rootdir }}/{{ project.name }}/.env"
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: "0600"
register: podman_compose_env_update
notify:
- podman_compose_restart
- podman_compose_enable
no_log: true
loop: "{{ podman_project }}"
loop_control:
loop_var: project
label: "{{ project.name }}"
when: podman_project is defined and project.env is defined
tags: podman_compose
- name: Update list of compose projects who updated their .env
ansible.builtin.set_fact:
# noqa jinja[spacing]
podman_compose_restart_list: "{{
(podman_compose_restart_list | default([]))
+ ([{'user': podman_user,'service': item.project.name}]
if {'user': podman_user, 'service': item.project.name}
not in (podman_compose_restart_list | default([]))
else [])
}}"
loop: "{{ podman_compose_env_update.results }}"
loop_control:
label: "{{ podman_user }}/{{ item.project.name }}"
when: item.changed | default(false)
tags: podman_compose
- name: Update list of enabled compose projects
ansible.builtin.set_fact:
podman_compose_enable_list: >-
{{ (podman_compose_enable_list | default([]))
+ [{'user': podman_user, 'service': project.name}] }}
when: project.enabled | default(false)
notify: podman_compose_enable
tags: podman_compose
+20
View File
@@ -0,0 +1,20 @@
- name: "Get UID for {{ podman_user.key }}"
ansible.builtin.getent:
database: passwd
key: "{{ podman_user.key }}"
- name: Login to private Podman registry via Docker CLI
community.docker.docker_login:
registry_url: "{{ registry.key }}"
username: "{{ registry.value.username }}"
password: "{{ registry.value.password }}"
docker_host: "unix:///run/user/{{ podman_uid }}/podman/podman.sock"
vars:
podman_uid: "{{ ansible_facts.getent_passwd[podman_user.key][1] }}"
loop: "{{ podman_user.value | dict2items }}"
loop_control:
loop_var: registry
label: "{{ podman_user.key }} => {{ registry.key }}"
become: true
become_user: "{{ podman_user.key }}"
no_log: true
+323
View File
@@ -0,0 +1,323 @@
- name: Install Podman with Docker CLI tools
ansible.builtin.apt:
name: ["podman", "docker-cli", "docker-compose"]
state: present
- name: Allow rootless containers to use capabilities in their user namespace
ansible.posix.seboolean:
name: container_use_userns_all_caps
state: true
persistent: true
when: selinux is defined and selinux is not false
- name: Create SELinux policy build directory
ansible.builtin.file:
path: "{{ podman_selinux_dir }}"
state: directory
owner: root
group: root
mode: "0755"
when: selinux is defined and selinux is not false
- name: Install container log SELinux policy source
ansible.builtin.copy:
src: oci_log.te
dest: "{{ podman_selinux_dir }}/oci_log.te"
owner: root
group: root
mode: "0644"
register: podman_selinux_src
when: selinux is defined and selinux is not false
- name: Clear stale container log SELinux artifacts
ansible.builtin.file:
path: "{{ podman_selinux_dir }}/oci_log.{{ item }}"
state: absent
loop: [mod, pp]
when:
- selinux is defined and selinux is not false
- podman_selinux_src is changed
- name: Compile container log SELinux policy module
ansible.builtin.command:
cmd: >-
checkmodule -M -m -o {{ podman_selinux_dir }}/oci_log.mod
{{ podman_selinux_dir }}/oci_log.te
creates: "{{ podman_selinux_dir }}/oci_log.mod"
when: selinux is defined and selinux is not false
- name: Package container log SELinux policy module
ansible.builtin.command:
cmd: >-
semodule_package -o {{ podman_selinux_dir }}/oci_log.pp
-m {{ podman_selinux_dir }}/oci_log.mod
creates: "{{ podman_selinux_dir }}/oci_log.pp"
when: selinux is defined and selinux is not false
- name: List loaded SELinux policy modules
ansible.builtin.command:
cmd: semodule -l
register: podman_semodule_list
changed_when: false
when: selinux is defined and selinux is not false
- name: Load container log SELinux policy module
ansible.builtin.command:
cmd: semodule -i {{ podman_selinux_dir }}/oci_log.pp
register: podman_semodule
changed_when: podman_semodule.rc == 0
when:
- selinux is defined and selinux is not false
- podman_selinux_src is changed or "oci_log" not in podman_semodule_list.stdout_lines
- name: Set SELinux context on container log directory
community.general.sefcontext:
target: "{{ podman_log_root }}(/.*)?"
setype: oci_log_t
state: present
when: selinux is defined and selinux is not false
- name: Create container log directory
ansible.builtin.file:
path: "{{ podman_log_root }}"
state: directory
owner: root
group: root
mode: "0755"
setype: >-
{{ (selinux is defined and selinux is not false)
| ternary('oci_log_t', omit) }}
- name: Install GnuPG tools and trusted CA bundle
ansible.builtin.apt:
name: ["gnupg", "ca-certificates"]
state: present
when: podman_compose is defined
- name: Get podman user info for user namespace configuration
ansible.builtin.getent:
database: passwd
key: "{{ item }}"
loop: "{{ podman_compose.keys() | list }}"
register: user_info
loop_control:
label: "{{ item }}"
when: podman_compose is defined
- name: Set subuid base facts for podman users
ansible.builtin.set_fact:
podman_subuid_base: "{{ podman_subuid_base | default({}) | combine({
item.item: 100000 + ((item.ansible_facts.getent_passwd[item.item][1]
| int - 1000) * 65536) }) }}"
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Configure /etc/subuid for rootless users
ansible.builtin.lineinfile:
path: "/etc/subuid"
line: "{{ item.item }}:{{ podman_subuid_base[item.item] }}:65536"
regexp: "^{{ item.item }}:"
create: true
backup: true
mode: "0644"
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Configure /etc/subgid for rootless users
ansible.builtin.lineinfile:
path: "/etc/subgid"
line: "{{ item.item }}:{{ podman_subuid_base[item.item] }}:65536"
regexp: "^{{ item.item }}:"
create: true
backup: true
mode: "0644"
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Ensure systemd linger directory exists
ansible.builtin.file:
path: /var/lib/systemd/linger
state: directory
owner: root
group: root
mode: "0755"
- name: Enable lingering for podman compose users
ansible.builtin.file:
path: "/var/lib/systemd/linger/{{ item.item }}"
state: touch
owner: root
group: root
mode: "0644"
access_time: preserve
modification_time: preserve
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Start user manager for podman compose users
ansible.builtin.systemd_service:
name: "user@{{ item.ansible_facts.getent_passwd[item.item][1] }}.service"
state: started
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Wait for user runtime directory
ansible.builtin.wait_for:
path: "/run/user/{{ item.ansible_facts.getent_passwd[item.item][1] }}/bus"
timeout: 30
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Start and enable the Podman socket
ansible.builtin.systemd:
name: podman.socket
state: started
enabled: true
scope: user
vars:
uid: "{{ item.ansible_facts.getent_passwd[item.item][1] }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ uid }}"
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ uid }}/bus"
become: true
become_user: "{{ item.item }}"
loop: "{{ user_info.results }}"
loop_control:
label: "{{ item.item }}"
- name: Create global containers config directory
ansible.builtin.file:
path: /etc/containers
state: directory
mode: "0755"
- name: Configure global containers.conf for rootless
ansible.builtin.copy:
content: |
[engine]
cgroup_manager = "cgroupfs"
events_logger = "journald"
runtime = "crun"
dest: /etc/containers/containers.conf
backup: true
mode: "0644"
- name: Configure Docker CLI to use rootless Podman socket
ansible.builtin.copy:
src: files/docker-host.sh
dest: /etc/profile.d/docker-host.sh
owner: root
group: root
mode: "0755"
- name: Install git for repository cloning
ansible.builtin.apt:
name: git
state: present
when: podman_compose is defined
- name: Login to private Podman registries with Docker CLI for each user
ansible.builtin.include_tasks: login.yml
loop: "{{ podman_login | dict2items }}"
loop_control:
loop_var: podman_user
when: podman_login is defined
- name: Stat rootless Podman directory
ansible.builtin.stat:
path: "/home/{{ compose_user.key }}/.local/share/containers"
loop: "{{ podman_compose | dict2items }}"
loop_control:
loop_var: compose_user
label: "{{ compose_user.key }}"
register: podman_user_containers_stat
when:
- podman_compose is defined
- selinux is defined
- selinux is not false
- name: Create rootless Podman directory
ansible.builtin.file:
path: "/home/{{ item.compose_user.key }}/.local/share/containers"
state: directory
owner: "{{ item.compose_user.key }}"
group: "{{ item.compose_user.key }}"
mode: "700"
loop: "{{ podman_user_containers_stat.results }}"
loop_control:
label: "{{ item.compose_user.key }}"
when:
- podman_compose is defined
- selinux is defined
- selinux is not false
- not item.stat.exists
- name: Label rootless Podman directory
ansible.builtin.command: >-
restorecon -Rv /home/{{ item.compose_user.key }}/.local/share/containers
loop: "{{ podman_user_containers_stat.results }}"
loop_control:
label: "/home/{{ item.compose_user.key }}/.local/share/containers"
changed_when: true
when:
- podman_compose is defined
- selinux is defined
- selinux is not false
- not item.stat.exists
- name: Stat Podman label directories
ansible.builtin.stat:
path: "{{ item.path }}"
loop: "{{ podman_label }}"
register: podman_label_stat
loop_control:
label: "{{ item.path }}"
when:
- podman_label is defined
- selinux is defined
- selinux is not false
- name: Create Podman label directories
ansible.builtin.file:
path: "{{ item.item.path }}"
owner: "{{ item.item.owner | default(omit) }}"
group: "{{ item.item.group | default(omit) }}"
mode: "{{ item.item.mode | default('700') }}"
state: directory
loop: "{{ podman_label_stat.results }}"
loop_control:
label: "{{ item.item.path }}"
when:
- podman_label is defined
- selinux is defined
- selinux is not false
- not item.stat.exists
- name: Set labels on Podman label directories
ansible.builtin.command: "chcon {{ item.item.label }} {{ item.item.path }}"
loop: "{{ podman_label_stat.results }}"
changed_when: true
loop_control:
label: "{{ item.item.path }} => {{ item.item.label }}"
when:
- podman_label is defined
- selinux is defined
- selinux is not false
- not item.stat.exists
- name: Deploy Podman compose projects for each user
ansible.builtin.include_tasks: deploy.yml
vars:
podman_user: "{{ compose_user.key }}"
podman_compose_config: "{{ compose_user.value }}"
loop: "{{ podman_compose | dict2items }}"
loop_control:
loop_var: compose_user
when: podman_compose is defined
tags: podman_compose
+10
View File
@@ -0,0 +1,10 @@
# {{ ansible_managed }}
{% if project.env is defined %}
{% for key, value in project.env.items() %}
{% if value is boolean %}
{{ key }}={{ value | lower }}
{% else %}
{{ key }}={{ value }}
{% endif %}
{% endfor %}
{% endif %}
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=%i docker compose (podman) service
Requires=podman.socket
After=podman.socket
[Service]
Type=oneshot
RemainAfterExit=true
WorkingDirectory={{ podman_rootdir }}/%i
Environment=DOCKER_HOST=unix://%t/podman/podman.sock
ExecStart=/usr/bin/docker compose up -d --remove-orphans
ExecStop=/usr/bin/docker compose down
[Install]
WantedBy=default.target
+1 -1
View File
@@ -1 +1 @@
cached_dhparams_pem: /vagrant/scratch/dhparams.pem
proxy_cached_dhparams_pem: /vagrant/scratch/dhparams.pem
-10
View File
@@ -1,13 +1,3 @@
- name: Enable nginx sites configuration
ansible.builtin.file:
src: "/etc/nginx/sites-available/{{ item.item.domain }}.conf"
dest: "/etc/nginx/sites-enabled/{{ item.item.domain }}.conf"
state: link
mode: "400"
loop: "{{ nginx_sites.results }}"
when: item.changed
listen: reload_nginx
- name: Reload nginx
ansible.builtin.service:
name: nginx
+66 -24
View File
@@ -10,18 +10,17 @@
state: started
enabled: true
- name: Check for cached dhparams.pem file
- name: Check if environment is vagrant
ansible.builtin.stat:
path: "{{ cached_dhparams_pem }}"
register: dhparams_file
path: /home/vagrant
register: vagrant_home
- name: Copy cached dhparams.pem to /etc/ssl/
ansible.builtin.copy:
src: "{{ cached_dhparams_pem }}"
- name: Download Mozilla's standard DH params (dev only)
ansible.builtin.get_url:
url: https://ssl-config.mozilla.org/ffdhe4096.txt
dest: /etc/ssl/dhparams.pem
mode: "600"
remote_src: true
when: dhparams_file.stat.exists
when: vagrant_home.stat.exists
- name: Generate DH Parameters
community.crypto.openssl_dhparam:
@@ -41,14 +40,26 @@
dest: "/etc/nginx/sites-available/{{ item.domain }}.conf"
mode: "400"
loop: "{{ proxy.servers }}"
loop_control:
label: "{{ item.domain }}"
notify: reload_nginx
- name: Enable nginx sites configuration
ansible.builtin.file:
src: "/etc/nginx/sites-available/{{ item.domain }}.conf"
dest: "/etc/nginx/sites-enabled/{{ item.domain }}.conf"
state: "{{ item.enabled | default(true) | ternary('link', 'absent') }}"
loop: "{{ proxy.servers }}"
loop_control:
label: "{{ item.domain }}"
notify: reload_nginx
register: nginx_sites
- name: Generate self-signed certificate
ansible.builtin.command: 'openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes \
-subj "/C=US/ST=Local/L=Local/O=Org/OU=IT/CN=example.com" \
-keyout /etc/ssl/private/nginx-selfsigned.key \
-out /etc/ssl/certs/nginx-selfsigned.crt'
ansible.builtin.command:
'openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes \
-subj "/C=US/ST=Local/L=Local/O=Org/OU=IT/CN=example.com" \
-keyout /etc/ssl/private/nginx-selfsigned.key \
-out /etc/ssl/certs/nginx-selfsigned.crt'
args:
creates: /etc/ssl/certs/nginx-selfsigned.crt
when: proxy.production is not defined or not proxy.production
@@ -56,15 +67,22 @@
- name: Install LE's certbot
ansible.builtin.apt:
name: ['certbot', 'python3-certbot-dns-cloudflare']
name: ["certbot", "python3-certbot-dns-cloudflare"]
state: present
when: proxy.production is defined and proxy.production
- name: Grab Cloudflare API token for configuration
ansible.builtin.slurp:
src: /etc/letsencrypt/cloudflare-api.key
register: cfapi
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
- name: Install Cloudflare API token
ansible.builtin.template:
src: cloudflare.ini.j2
dest: /root/.cloudflare.ini
dest: /etc/letsencrypt/cloudflare.ini
mode: "400"
diff: false
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
- name: Create nginx post renewal hook directory
@@ -78,25 +96,49 @@
ansible.builtin.copy:
src: reload-nginx.sh
dest: /etc/letsencrypt/renewal-hooks/post/reload-nginx.sh
mode: '0755'
mode: "0755"
when: proxy.production is defined and proxy.production
- name: Enable SELinux bool certbot_acmesh to allow sh access for DNS-01
ansible.posix.seboolean:
name: certbot_acmesh
state: true
persistent: true
when:
- selinux is defined
- selinux is not false
- proxy is defined
- proxy.production is defined
- proxy.production
- proxy.dns_cloudflare is defined
- name: Run Cloudflare DNS-01 challenges on wildcard domains
ansible.builtin.shell: '/usr/bin/certbot certonly \
--non-interactive \
--agree-tos \
--email "{{ proxy.dns_cloudflare.email }}" \
--dns-cloudflare \
--dns-cloudflare-credentials /root/.cloudflare.ini \
-d "*.{{ item }}" \
-d "{{ item }}" \
{{ proxy.dns_cloudflare.opts | default("") }}'
--non-interactive \
--agree-tos \
--email "{{ proxy.dns_cloudflare.email }}" \
--dns-cloudflare \
--dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini \
-d "*.{{ item }}" \
-d "{{ item }}" \
{{ proxy.dns_cloudflare.opts | default("") }}
< /dev/null'
args:
creates: "/etc/letsencrypt/live/{{ item }}/fullchain.pem"
loop: "{{ proxy.dns_cloudflare.wildcard_domains }}"
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
notify: reload_nginx
- name: Enable SELinux bool httpd_can_network_connect to give nginx networking
ansible.posix.seboolean:
name: httpd_can_network_connect
state: true
persistent: true
when:
- selinux is defined
- selinux is not false
- proxy is defined
- name: Add HTTP and HTTPS firewall rule
community.general.ufw:
rule: allow
+1 -1
View File
@@ -1,2 +1,2 @@
# Cloudflare API token used by Certbot
dns_cloudflare_api_token = {{ proxy.dns_cloudflare.api_token }}
dns_cloudflare_api_token = {{ cfapi['content'] | b64decode | trim }}
+15 -4
View File
@@ -1,13 +1,17 @@
server {
listen 80;
{% if proxy.ipv6 is defined and proxy.ipv6 %}
listen [::]:80;
{% endif %}
server_name {{ item.domain }};
return 301 https://{{ item.domain }}$request_uri;
}
server {
listen 443 ssl http2;
{% if proxy.ipv6 is defined and proxy.ipv6 %}
listen [::]:443 ssl http2;
{% endif %}
server_name {{ item.domain }};
access_log /var/log/nginx/{{ item.domain }}.log main;
{% if proxy.production is defined and proxy.production and proxy.dns_cloudflare.wildcard_domains is defined and item.tls.cert is not defined %}
@@ -28,14 +32,20 @@ server {
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
{% endif %}
{% if item.hsts is defined %}
add_header Strict-Transport-Security "max-age={{ item.hsts }}" always;
{% endif %}
{% if item.client_max_body_size is defined %}
client_max_body_size {{ item.client_max_body_size }};
{% endif %}
location / {
{% if item.restrict is defined and item.restrict %}
{% if item.hsts is defined %}
add_header Strict-Transport-Security "max-age={{ item.hsts }}" always;
{% endif %}
{% if item.allowedips is defined %}
{% for ip in item.allowedips %}
allow {{ ip }};
{% endfor %}
deny all;
{% endif %}
{% if item.restrict is defined and item.restrict %}
auth_basic "{{ item.restrict_name | default('Restricted Access') }}";
auth_basic_user_file {{ item.restrict_file | default('/etc/nginx/.htpasswd') }};
proxy_set_header Authorization "";
@@ -43,6 +53,7 @@ server {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass {{ item.proxy_pass }};
{% if item.proxy_ssl_verify is defined and item.proxy_ssl_verify is false %}
proxy_ssl_verify off;
+1 -1
View File
@@ -33,4 +33,4 @@
name: "{{ docker_compose_service }}@{{ traefik_name }}"
state: started
enabled: true
when: traefik.ENABLED | default('false')
when: traefik.ENABLED | default(false)
+1
View File
@@ -0,0 +1 @@
zrepl_pkg_hold: true
+40
View File
@@ -0,0 +1,40 @@
- name: Download zrepl APT signing key
ansible.builtin.get_url:
url: https://zrepl.cschwarz.com/apt/apt-key.asc
dest: /tmp/zrepl-apt-key.asc
mode: "600"
force: true
- name: Get fingerprint of downloaded key
ansible.builtin.shell: |
set -euo pipefail
gpg --with-colons --import-options show-only \
--import /tmp/zrepl-apt-key.asc | awk -F: '$1=="fpr"{print $10; exit}'
args:
executable: /bin/bash
changed_when: false
register: gpg_key_info
- name: Verify key fingerprint matches expected value
ansible.builtin.assert:
that: gpg_key_info.stdout == expected_fingerprint
vars:
expected_fingerprint: "E101418FD3D6FBCB9D65A62D708699FC5F2EBF16"
- name: Dearmor zrepl key into APT keyring
ansible.builtin.command:
cmd: >-
gpg --dearmor --yes --output /usr/share/keyrings/zrepl-archive-keyring.gpg
/tmp/zrepl-apt-key.asc
args:
creates: /usr/share/keyrings/zrepl-archive-keyring.gpg
- name: Add zrepl apt repository
ansible.builtin.apt_repository:
repo: "deb [signed-by={{ zrepl_keyring_path }}] {{ zrepl_url }} {{ zrepl_suite }} main"
filename: zrepl
state: present
vars:
zrepl_keyring_path: /usr/share/keyrings/zrepl-archive-keyring.gpg
zrepl_url: "https://zrepl.cschwarz.com/apt/debian"
zrepl_suite: "{{ ansible_distribution_release }}"
+24
View File
@@ -0,0 +1,24 @@
- name: Install GnuPG
ansible.builtin.apt:
name: gnupg
state: present
update_cache: true
- name: Check if zrepl repo exists
ansible.builtin.stat:
path: /etc/apt/sources.list.d/zrepl.list
register: zrepl_repo_file
- name: Install zrepl repo
ansible.builtin.include_tasks: install.yml
when: not zrepl_repo_file.stat.exists
- name: Install zrepl
ansible.builtin.apt:
name: zrepl
state: present
- name: Set zrepl package hold state
ansible.builtin.dpkg_selections:
name: zrepl
selection: "{{ 'hold' if zrepl_pkg_hold else 'install' }}"