Compare commits

...

6 commits

Author SHA1 Message Date
1d54043b8e
add role tag to msmtp role
All checks were successful
/ Ansible Lint (push) Successful in 2m38s
/ Ansible Lint (pull_request) Successful in 2m38s
2026-05-01 00:33:14 +02:00
9ec04e162f
add role tag to ansible_pull role 2026-05-01 00:33:14 +02:00
94b3df0981
add role tag to infrastructure_authorized_keys role 2026-05-01 00:33:14 +02:00
f27a7ee00b
add role tag to base_config role 2026-05-01 00:33:14 +02:00
e4722257b9
add role tag to certbot role 2026-05-01 00:33:14 +02:00
296214db55
add role tag to docker_compose role 2026-05-01 00:33:14 +02:00
13 changed files with 68 additions and 0 deletions

View file

@ -1,6 +1,9 @@
---
- name: ensure dependencies are installed - name: ensure dependencies are installed
tags: [ "ansible_pull" ]
block: block:
- name: ensure apt dependencies are installed - name: ensure apt dependencies are installed
tags: [ "ansible_pull" ]
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- python3-pip - python3-pip
@ -10,12 +13,14 @@
become: true become: true
- name: ensure SOPS is installed - name: ensure SOPS is installed
tags: [ "ansible_pull" ]
ansible.builtin.include_role: ansible.builtin.include_role:
name: community.sops.install name: community.sops.install
# https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip # https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip
# https://www.redhat.com/en/blog/python-venv-ansible # https://www.redhat.com/en/blog/python-venv-ansible
- name: ensure Ansible installation exists - name: ensure Ansible installation exists
tags: [ "ansible_pull" ]
ansible.builtin.pip: ansible.builtin.pip:
name: name:
- ansible - ansible
@ -25,6 +30,7 @@
become: true become: true
- name: ensure ansible-pull-failure-notify script installation exists - name: ensure ansible-pull-failure-notify script installation exists
tags: [ "ansible_pull" ]
ansible.builtin.template: ansible.builtin.template:
src: ansible-pull-failure-notify.sh.j2 src: ansible-pull-failure-notify.sh.j2
dest: /usr/local/sbin/ansible-pull-failure-notify.sh dest: /usr/local/sbin/ansible-pull-failure-notify.sh
@ -34,6 +40,7 @@
become: true become: true
- name: ensure secrets directory exists - name: ensure secrets directory exists
tags: [ "ansible_pull" ]
ansible.builtin.file: ansible.builtin.file:
path: /etc/ansible_pull_secrets path: /etc/ansible_pull_secrets
state: directory state: directory
@ -43,6 +50,7 @@
become: true become: true
- name: ensure age private key is deployed - name: ensure age private key is deployed
tags: [ "ansible_pull" ]
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ ansible_pull__age_private_key }}" content: "{{ ansible_pull__age_private_key }}"
dest: /etc/ansible_pull_secrets/age_private_key dest: /etc/ansible_pull_secrets/age_private_key
@ -52,6 +60,7 @@
become: true become: true
- name: ensure systemd services exists - name: ensure systemd services exists
tags: [ "ansible_pull" ]
ansible.builtin.template: ansible.builtin.template:
src: "{{ item }}.j2" src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}" dest: "/etc/systemd/system/{{ item }}"
@ -66,6 +75,7 @@
- systemd daemon reload - systemd daemon reload
- name: ensure systemd timer exists - name: ensure systemd timer exists
tags: [ "ansible_pull" ]
ansible.builtin.template: ansible.builtin.template:
src: ansible-pull.timer.j2 src: ansible-pull.timer.j2
dest: /etc/systemd/system/ansible-pull.timer dest: /etc/systemd/system/ansible-pull.timer
@ -77,6 +87,7 @@
- systemd daemon reload - systemd daemon reload
- name: ensure systemd timer is started and enabled - name: ensure systemd timer is started and enabled
tags: [ "ansible_pull" ]
ansible.builtin.systemd_service: ansible.builtin.systemd_service:
name: ansible-pull.timer name: ansible-pull.timer
state: started state: started

View file

@ -1,10 +1,12 @@
# Ensure the ssh module is disabled, so a cloud-init config change doesn't regenerate the host keys for no reason. # Ensure the ssh module is disabled, so a cloud-init config change doesn't regenerate the host keys for no reason.
- name: check if cloud-init config file exists - name: check if cloud-init config file exists
tags: [ "base_config" ]
ansible.builtin.stat: ansible.builtin.stat:
path: /etc/cloud/cloud.cfg path: /etc/cloud/cloud.cfg
register: base_config__stat_cloud_cfg register: base_config__stat_cloud_cfg
- name: ensure the cloud-init ssh module is disabled - name: ensure the cloud-init ssh module is disabled
tags: [ "base_config" ]
ansible.builtin.replace: ansible.builtin.replace:
path: /etc/cloud/cloud.cfg path: /etc/cloud/cloud.cfg
regexp: " - ssh$" regexp: " - ssh$"
@ -14,6 +16,7 @@
# Ensure a base set of admin tools is installed. # Ensure a base set of admin tools is installed.
- name: ensure a base set of admin tools is installed - name: ensure a base set of admin tools is installed
tags: [ "base_config" ]
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- vim - vim

View file

@ -1,11 +1,15 @@
---
- name: ensure certbot installation - name: ensure certbot installation
tags: [ "certbot" ]
ansible.builtin.import_tasks: ansible.builtin.import_tasks:
file: main/install.yaml file: main/install.yaml
- name: ensure new cert commands - name: ensure new cert commands
tags: [ "certbot" ]
ansible.builtin.import_tasks: ansible.builtin.import_tasks:
file: main/new_cert_commands.yaml file: main/new_cert_commands.yaml
- name: ensure certificates - name: ensure certificates
tags: [ "certbot" ]
ansible.builtin.import_tasks: ansible.builtin.import_tasks:
file: main/certs.yaml file: main/certs.yaml

View file

@ -1,4 +1,6 @@
---
- name: get expiry date before - name: get expiry date before
tags: [ "certbot" ]
ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item.commonName }}/fullchain.pem ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item.commonName }}/fullchain.pem
ignore_errors: true ignore_errors: true
become: true become: true
@ -6,6 +8,7 @@
register: certbot__cert_expiry_before register: certbot__cert_expiry_before
- name: ensure directory for cert configs exists - name: ensure directory for cert configs exists
tags: [ "certbot" ]
ansible.builtin.file: ansible.builtin.file:
path: "/etc/ansible_certbot/cert_configs/" path: "/etc/ansible_certbot/cert_configs/"
state: directory state: directory
@ -15,6 +18,7 @@
become: true become: true
- name: ensure cert config is stored - name: ensure cert config is stored
tags: [ "certbot" ]
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ cert_config_defaults[item.challengeType] | combine(item, recursive=True) | ansible.builtin.to_nice_json }}" content: "{{ cert_config_defaults[item.challengeType] | combine(item, recursive=True) | ansible.builtin.to_nice_json }}"
dest: "/etc/ansible_certbot/cert_configs/{{ item.commonName }}.json" dest: "/etc/ansible_certbot/cert_configs/{{ item.commonName }}.json"
@ -30,17 +34,20 @@
# # https://eff-certbot.readthedocs.io/en/stable/using.html#manual # # https://eff-certbot.readthedocs.io/en/stable/using.html#manual
- name: obtain the certificate using certbot and the manual auth hook - name: obtain the certificate using certbot and the manual auth hook
tags: [ "certbot" ]
ansible.builtin.command: /usr/bin/certbot certonly --keep-until-expiring --agree-tos --non-interactive --email "{{ certbot__acme_account_email_address }}" --no-eff-email --manual --preferred-challenge dns --manual-auth-hook "/usr/local/lib/ansible_certbot/manual_auth_scripts/{{ item.challengeType }}.sh" -d "{{ item.commonName }}" ansible.builtin.command: /usr/bin/certbot certonly --keep-until-expiring --agree-tos --non-interactive --email "{{ certbot__acme_account_email_address }}" --no-eff-email --manual --preferred-challenge dns --manual-auth-hook "/usr/local/lib/ansible_certbot/manual_auth_scripts/{{ item.challengeType }}.sh" -d "{{ item.commonName }}"
become: true become: true
changed_when: false changed_when: false
- name: get expiry date after - name: get expiry date after
tags: [ "certbot" ]
ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item.commonName }}/fullchain.pem ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item.commonName }}/fullchain.pem
become: true become: true
changed_when: false changed_when: false
register: certbot__cert_expiry_after register: certbot__cert_expiry_after
- name: potentially report changed - name: potentially report changed
tags: [ "certbot" ]
ansible.builtin.debug: ansible.builtin.debug:
msg: "If this reports changed, then the certificate expiry date and therefore the certificate changed." msg: "If this reports changed, then the certificate expiry date and therefore the certificate changed."
changed_when: certbot__cert_expiry_before.stdout != certbot__cert_expiry_after.stdout changed_when: certbot__cert_expiry_before.stdout != certbot__cert_expiry_after.stdout

View file

@ -1,14 +1,18 @@
---
- name: obtain http-01 challenge certificates - name: obtain http-01 challenge certificates
tags: [ "certbot" ]
loop: "{{ certbot__certificate_domains }}" loop: "{{ certbot__certificate_domains }}"
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: main/http_01_cert.yaml file: main/http_01_cert.yaml
- name: validate certs config - name: validate certs config
tags: [ "certbot" ]
loop: "{{ certbot__certs }}" loop: "{{ certbot__certs }}"
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: main/validate_cert.yaml file: main/validate_cert.yaml
- name: obtain certs - name: obtain certs
tags: [ "certbot" ]
loop: "{{ certbot__certs }}" loop: "{{ certbot__certs }}"
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: main/cert.yaml file: main/cert.yaml

View file

@ -1,4 +1,6 @@
---
- name: get expiry date before - name: get expiry date before
tags: [ "certbot" ]
ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item }}/fullchain.pem ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item }}/fullchain.pem
ignore_errors: true ignore_errors: true
become: true become: true
@ -6,11 +8,13 @@
register: certbot__cert_expiry_before register: certbot__cert_expiry_before
- name: obtain the certificate using certbot - name: obtain the certificate using certbot
tags: [ "certbot" ]
ansible.builtin.command: /usr/bin/certbot certonly --keep-until-expiring --agree-tos --non-interactive --email "{{ certbot__acme_account_email_address }}" --no-eff-email --standalone --http-01-port "{{ certbot__http_01_port }}" -d "{{ item }}" ansible.builtin.command: /usr/bin/certbot certonly --keep-until-expiring --agree-tos --non-interactive --email "{{ certbot__acme_account_email_address }}" --no-eff-email --standalone --http-01-port "{{ certbot__http_01_port }}" -d "{{ item }}"
become: true become: true
changed_when: false changed_when: false
- name: get expiry date after - name: get expiry date after
tags: [ "certbot" ]
ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item }}/fullchain.pem ansible.builtin.command: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/{{ item }}/fullchain.pem
become: true become: true
changed_when: false changed_when: false

View file

@ -1,4 +1,6 @@
---
- name: ensure relevant packages are installed - name: ensure relevant packages are installed
tags: [ "certbot" ]
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- openssl - openssl
@ -8,8 +10,10 @@
become: true become: true
- name: ensure manual auth scripts are deployed - name: ensure manual auth scripts are deployed
tags: [ "certbot" ]
block: block:
- name: ensure manual auth scripts directory exists - name: ensure manual auth scripts directory exists
tags: [ "certbot" ]
ansible.builtin.file: ansible.builtin.file:
path: "/usr/local/lib/ansible_certbot/manual_auth_scripts" path: "/usr/local/lib/ansible_certbot/manual_auth_scripts"
state: directory state: directory
@ -19,6 +23,7 @@
become: true become: true
- name: ensure manual auth scripts are deployed - name: ensure manual auth scripts are deployed
tags: [ "certbot" ]
ansible.builtin.copy: ansible.builtin.copy:
src: "manual_auth_scripts/{{ item }}.sh" src: "manual_auth_scripts/{{ item }}.sh"
dest: "/usr/local/lib/ansible_certbot/manual_auth_scripts/{{ item }}.sh" dest: "/usr/local/lib/ansible_certbot/manual_auth_scripts/{{ item }}.sh"

View file

@ -1,4 +1,6 @@
---
- name: ensure existence of renewal deploy hooks directory - name: ensure existence of renewal deploy hooks directory
tags: [ "certbot" ]
ansible.builtin.file: ansible.builtin.file:
path: /etc/letsencrypt/renewal-hooks/deploy path: /etc/letsencrypt/renewal-hooks/deploy
state: directory state: directory
@ -8,6 +10,7 @@
become: true become: true
- name: ensure renewal deploy hook commands - name: ensure renewal deploy hook commands
tags: [ "certbot" ]
ansible.builtin.template: ansible.builtin.template:
src: renewal_deploy_hook_commands.sh.j2 src: renewal_deploy_hook_commands.sh.j2
dest: /etc/letsencrypt/renewal-hooks/deploy/ansible_commands.sh dest: /etc/letsencrypt/renewal-hooks/deploy/ansible_commands.sh

View file

@ -1,11 +1,15 @@
---
- name: validate dns-01-acme-dns challenge type config - name: validate dns-01-acme-dns challenge type config
tags: [ "certbot" ]
when: item.challengeType == "dns-01-acme-dns" when: item.challengeType == "dns-01-acme-dns"
block: block:
- name: assert dns_01_acme_dns config exists - name: assert dns_01_acme_dns config exists
tags: [ "certbot" ]
ansible.builtin.assert: ansible.builtin.assert:
that: item.dns_01_acme_dns is defined that: item.dns_01_acme_dns is defined
- name: assert dns_01_acme_dns config is valid - name: assert dns_01_acme_dns config is valid
tags: [ "certbot" ]
ansible.builtin.validate_argument_spec: ansible.builtin.validate_argument_spec:
argument_spec: "{{ required_data }}" argument_spec: "{{ required_data }}"
provided_arguments: provided_arguments:

View file

@ -1,10 +1,13 @@
---
- name: docker compose down - name: docker compose down
tags: [ "docker_compose" ]
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: /ansible_docker_compose project_src: /ansible_docker_compose
state: absent state: absent
become: true become: true
- name: docker compose restart - name: docker compose restart
tags: [ "docker_compose" ]
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: /ansible_docker_compose project_src: /ansible_docker_compose
state: restarted state: restarted

View file

@ -1,4 +1,6 @@
---
- name: make sure the `/ansible_docker_compose` directory exists - name: make sure the `/ansible_docker_compose` directory exists
tags: [ "docker_compose" ]
ansible.builtin.file: ansible.builtin.file:
path: /ansible_docker_compose path: /ansible_docker_compose
state: directory state: directory
@ -8,6 +10,7 @@
become: true become: true
- name: deploy the Compose file - name: deploy the Compose file
tags: [ "docker_compose" ]
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ docker_compose__compose_file_content }}" content: "{{ docker_compose__compose_file_content }}"
dest: /ansible_docker_compose/compose.yaml dest: /ansible_docker_compose/compose.yaml
@ -18,6 +21,7 @@
notify: docker compose down notify: docker compose down
- name: deploy the .env file - name: deploy the .env file
tags: [ "docker_compose" ]
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ docker_compose__env_file_content }}" content: "{{ docker_compose__env_file_content }}"
dest: /ansible_docker_compose/.env dest: /ansible_docker_compose/.env
@ -29,6 +33,7 @@
notify: docker compose down notify: docker compose down
- name: make sure the `/ansible_docker_compose/configs` directory exists - name: make sure the `/ansible_docker_compose/configs` directory exists
tags: [ "docker_compose" ]
ansible.builtin.file: ansible.builtin.file:
path: /ansible_docker_compose/configs path: /ansible_docker_compose/configs
state: directory state: directory
@ -38,10 +43,12 @@
become: true become: true
- name: set `docker_compose__config_files_to_exist` fact initially to an empty list - name: set `docker_compose__config_files_to_exist` fact initially to an empty list
tags: [ "docker_compose" ]
ansible.builtin.set_fact: ansible.builtin.set_fact:
docker_compose__config_files_to_exist: [ ] docker_compose__config_files_to_exist: [ ]
- name: add names from `docker_compose__configuration_files` to `docker_compose__config_files_to_exist` fact - name: add names from `docker_compose__configuration_files` to `docker_compose__config_files_to_exist` fact
tags: [ "docker_compose" ]
ansible.builtin.set_fact: ansible.builtin.set_fact:
docker_compose__config_files_to_exist: "{{ docker_compose__config_files_to_exist + [ item.name ] }}" # noqa: jinja[spacing] docker_compose__config_files_to_exist: "{{ docker_compose__config_files_to_exist + [ item.name ] }}" # noqa: jinja[spacing]
loop: "{{ docker_compose__configuration_files }}" loop: "{{ docker_compose__configuration_files }}"
@ -49,6 +56,7 @@
label: "{{ item.name }}" label: "{{ item.name }}"
- name: find configuration files to remove - name: find configuration files to remove
tags: [ "docker_compose" ]
ansible.builtin.find: ansible.builtin.find:
paths: /ansible_docker_compose/configs/ paths: /ansible_docker_compose/configs/
recurse: false recurse: false
@ -56,6 +64,7 @@
register: docker_compose__config_files_to_remove register: docker_compose__config_files_to_remove
- name: remove all configuration files, which should be removed - name: remove all configuration files, which should be removed
tags: [ "docker_compose" ]
ansible.builtin.file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: absent state: absent
@ -64,6 +73,7 @@
notify: docker compose restart notify: docker compose restart
- name: make sure all given configuration files are deployed - name: make sure all given configuration files are deployed
tags: [ "docker_compose" ]
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ item.content }}" content: "{{ item.content }}"
dest: "/ansible_docker_compose/configs/{{ item.name }}" dest: "/ansible_docker_compose/configs/{{ item.name }}"
@ -77,6 +87,7 @@
notify: docker compose restart notify: docker compose restart
- name: Sync files - name: Sync files
tags: [ "docker_compose" ]
ansible.posix.synchronize: ansible.posix.synchronize:
src: "{{ docker_compose__files }}/" src: "{{ docker_compose__files }}/"
dest: "/ansible_docker_compose/files" dest: "/ansible_docker_compose/files"
@ -88,9 +99,11 @@
when: docker_compose__files != "" when: docker_compose__files != ""
- name: Flush handlers to make "docker compose down" and "docker compose restart" handlers run now - name: Flush handlers to make "docker compose down" and "docker compose restart" handlers run now
tags: [ "docker_compose" ]
ansible.builtin.meta: flush_handlers ansible.builtin.meta: flush_handlers
- name: docker compose up - name: docker compose up
tags: [ "docker_compose" ]
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: /ansible_docker_compose project_src: /ansible_docker_compose
state: present state: present
@ -100,12 +113,14 @@
become: true become: true
- name: Make sure anacron is installed - name: Make sure anacron is installed
tags: [ "docker_compose" ]
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: anacron name: anacron
state: present state: present
- name: ensure automatic update cron job is present - name: ensure automatic update cron job is present
tags: [ "docker_compose" ]
become: true become: true
ansible.builtin.cron: ansible.builtin.cron:
name: 'ansible docker compose auto update' name: 'ansible docker compose auto update'

View file

@ -1,4 +1,6 @@
---
- name: deploy infrastructure authorized keys - name: deploy infrastructure authorized keys
tags: [ "infrastructure_authorized_keys" ]
ansible.posix.authorized_key: ansible.posix.authorized_key:
state: present state: present
user: chaos user: chaos

View file

@ -1,10 +1,13 @@
---
- name: ensure msmtp is installed - name: ensure msmtp is installed
tags: [ "msmtp" ]
ansible.builtin.apt: ansible.builtin.apt:
name: msmtp name: msmtp
state: present state: present
become: true become: true
- name: ensure msmtp config for root user - name: ensure msmtp config for root user
tags: [ "msmtp" ]
ansible.builtin.template: ansible.builtin.template:
src: msmtprc.j2 src: msmtprc.j2
dest: /root/.msmtprc dest: /root/.msmtprc