diff --git a/roles/ansible_pull/tasks/main.yaml b/roles/ansible_pull/tasks/main.yaml index e7c614b..040d9c2 100644 --- a/roles/ansible_pull/tasks/main.yaml +++ b/roles/ansible_pull/tasks/main.yaml @@ -1,9 +1,9 @@ --- -- tags: ["ansible_pull"] - name: ensure dependencies are installed +- name: ensure dependencies are installed + tags: [ "ansible_pull" ] block: - - tags: ["ansible_pull"] - name: ensure apt dependencies are installed + - name: ensure apt dependencies are installed + tags: [ "ansible_pull" ] ansible.builtin.apt: name: - python3-pip @@ -12,15 +12,15 @@ state: present become: true - - tags: ["ansible_pull"] - name: ensure SOPS is installed + - name: ensure SOPS is installed + tags: [ "ansible_pull" ] ansible.builtin.include_role: name: community.sops.install # 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 -- tags: ["ansible_pull"] - name: ensure Ansible installation exists +- name: ensure Ansible installation exists + tags: [ "ansible_pull" ] ansible.builtin.pip: name: - ansible @@ -29,8 +29,8 @@ virtualenv: /usr/local/lib/ansible_pull_venv become: true -- tags: ["ansible_pull"] - name: ensure ansible-pull-failure-notify script installation exists +- name: ensure ansible-pull-failure-notify script installation exists + tags: [ "ansible_pull" ] ansible.builtin.template: src: ansible-pull-failure-notify.sh.j2 dest: /usr/local/sbin/ansible-pull-failure-notify.sh @@ -39,8 +39,8 @@ mode: "0755" become: true -- tags: ["ansible_pull"] - name: ensure secrets directory exists +- name: ensure secrets directory exists + tags: [ "ansible_pull" ] ansible.builtin.file: path: /etc/ansible_pull_secrets state: directory @@ -49,8 +49,8 @@ group: "{{ ansible_pull__user }}" become: true -- tags: ["ansible_pull"] - name: ensure age private key is deployed +- name: ensure age private key is deployed + tags: [ "ansible_pull" ] ansible.builtin.copy: content: "{{ ansible_pull__age_private_key }}" dest: /etc/ansible_pull_secrets/age_private_key @@ -59,8 +59,8 @@ group: "{{ ansible_pull__user }}" become: true -- tags: ["ansible_pull"] - name: ensure systemd services exists +- name: ensure systemd services exists + tags: [ "ansible_pull" ] ansible.builtin.template: src: "{{ item }}.j2" dest: "/etc/systemd/system/{{ item }}" @@ -74,8 +74,8 @@ notify: - systemd daemon reload -- tags: ["ansible_pull"] - name: ensure systemd timer exists +- name: ensure systemd timer exists + tags: [ "ansible_pull" ] ansible.builtin.template: src: ansible-pull.timer.j2 dest: /etc/systemd/system/ansible-pull.timer @@ -86,8 +86,8 @@ notify: - systemd daemon reload -- tags: ["ansible_pull"] - name: ensure systemd timer is started and enabled +- name: ensure systemd timer is started and enabled + tags: [ "ansible_pull" ] ansible.builtin.systemd_service: name: ansible-pull.timer state: started diff --git a/roles/base_config/tasks/main.yaml b/roles/base_config/tasks/main.yaml index 8d06303..0837c64 100644 --- a/roles/base_config/tasks/main.yaml +++ b/roles/base_config/tasks/main.yaml @@ -1,12 +1,12 @@ # Ensure the ssh module is disabled, so a cloud-init config change doesn't regenerate the host keys for no reason. -- tags: ["base_config"] - name: check if cloud-init config file exists +- name: check if cloud-init config file exists + tags: [ "base_config" ] ansible.builtin.stat: path: /etc/cloud/cloud.cfg register: base_config__stat_cloud_cfg -- tags: ["base_config"] - name: ensure the cloud-init ssh module is disabled +- name: ensure the cloud-init ssh module is disabled + tags: [ "base_config" ] ansible.builtin.replace: path: /etc/cloud/cloud.cfg regexp: " - ssh$" @@ -15,8 +15,8 @@ when: base_config__stat_cloud_cfg.stat.exists # Ensure a base set of admin tools is installed. -- tags: ["base_config"] - 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: name: - vim diff --git a/roles/certbot/tasks/main.yaml b/roles/certbot/tasks/main.yaml index 55b4127..6b14567 100644 --- a/roles/certbot/tasks/main.yaml +++ b/roles/certbot/tasks/main.yaml @@ -1,15 +1,15 @@ --- -- tags: ["certbot"] - name: ensure certbot installation +- name: ensure certbot installation + tags: [ "certbot" ] ansible.builtin.import_tasks: file: main/install.yaml -- tags: ["certbot"] - name: ensure new cert commands +- name: ensure new cert commands + tags: [ "certbot" ] ansible.builtin.import_tasks: file: main/new_cert_commands.yaml -- tags: ["certbot"] - name: ensure certificates +- name: ensure certificates + tags: [ "certbot" ] ansible.builtin.import_tasks: file: main/certs.yaml diff --git a/roles/certbot/tasks/main/cert.yaml b/roles/certbot/tasks/main/cert.yaml index 609d405..c179dee 100644 --- a/roles/certbot/tasks/main/cert.yaml +++ b/roles/certbot/tasks/main/cert.yaml @@ -1,14 +1,14 @@ --- -- tags: ["certbot", "certbot-cert"] - 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 ignore_errors: true become: true changed_when: false register: certbot__cert_expiry_before -- tags: ["certbot", "certbot-cert"] - name: ensure directory for cert configs exists +- name: ensure directory for cert configs exists + tags: [ "certbot" ] ansible.builtin.file: path: "/etc/ansible_certbot/cert_configs/" state: directory @@ -17,8 +17,8 @@ mode: "0750" become: true -- tags: ["certbot", "certbot-cert"] - name: ensure cert config is stored +- name: ensure cert config is stored + tags: [ "certbot" ] ansible.builtin.copy: content: "{{ cert_config_defaults[item.challengeType] | combine(item, recursive=True) | ansible.builtin.to_nice_json }}" dest: "/etc/ansible_certbot/cert_configs/{{ item.commonName }}.json" @@ -33,21 +33,21 @@ serverUrl: "https://acmedns.hamburg.ccc.de" # # https://eff-certbot.readthedocs.io/en/stable/using.html#manual -- tags: ["certbot", "certbot-cert"] - 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 }}" become: true changed_when: false -- tags: ["certbot", "certbot-cert"] - 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 become: true changed_when: false register: certbot__cert_expiry_after -- tags: ["certbot", "certbot-cert"] - name: potentially report changed +- name: potentially report changed + tags: [ "certbot" ] ansible.builtin.debug: 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 diff --git a/roles/certbot/tasks/main/certs.yaml b/roles/certbot/tasks/main/certs.yaml index 7fe83c6..71a42a5 100644 --- a/roles/certbot/tasks/main/certs.yaml +++ b/roles/certbot/tasks/main/certs.yaml @@ -1,18 +1,18 @@ --- -- tags: ["certbot", "certbot-cert"] - name: obtain http-01 challenge certificates +- name: obtain http-01 challenge certificates + tags: [ "certbot" ] loop: "{{ certbot__certificate_domains }}" ansible.builtin.include_tasks: file: main/http_01_cert.yaml -- tags: ["certbot", "certbot-cert"] - name: validate certs config +- name: validate certs config + tags: [ "certbot" ] loop: "{{ certbot__certs }}" ansible.builtin.include_tasks: file: main/validate_cert.yaml -- tags: ["certbot", "certbot-cert"] - name: obtain certs +- name: obtain certs + tags: [ "certbot" ] loop: "{{ certbot__certs }}" ansible.builtin.include_tasks: file: main/cert.yaml diff --git a/roles/certbot/tasks/main/http_01_cert.yaml b/roles/certbot/tasks/main/http_01_cert.yaml index 1ea7447..a2fb4b6 100644 --- a/roles/certbot/tasks/main/http_01_cert.yaml +++ b/roles/certbot/tasks/main/http_01_cert.yaml @@ -1,20 +1,20 @@ --- -- tags: ["certbot", "certbot-http-01-cert"] - 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 ignore_errors: true become: true changed_when: false register: certbot__cert_expiry_before -- tags: ["certbot", "certbot-http-01-cert"] - 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 }}" become: true changed_when: false -- tags: ["certbot", "certbot-http-01-cert"] - 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 become: true changed_when: false diff --git a/roles/certbot/tasks/main/install.yaml b/roles/certbot/tasks/main/install.yaml index d02a989..14c6430 100644 --- a/roles/certbot/tasks/main/install.yaml +++ b/roles/certbot/tasks/main/install.yaml @@ -1,6 +1,6 @@ --- -- tags: ["certbot", "certbot-install"] - name: ensure relevant packages are installed +- name: ensure relevant packages are installed + tags: [ "certbot" ] ansible.builtin.apt: name: - openssl @@ -9,11 +9,11 @@ state: present become: true -- tags: ["certbot", "certbot-install"] - name: ensure manual auth scripts are deployed +- name: ensure manual auth scripts are deployed + tags: [ "certbot" ] block: - - tags: ["certbot", "certbot-install"] - name: ensure manual auth scripts directory exists + - name: ensure manual auth scripts directory exists + tags: [ "certbot" ] ansible.builtin.file: path: "/usr/local/lib/ansible_certbot/manual_auth_scripts" state: directory @@ -22,8 +22,8 @@ mode: "0755" become: true - - tags: ["certbot", "certbot-install"] - name: ensure manual auth scripts are deployed + - name: ensure manual auth scripts are deployed + tags: [ "certbot" ] ansible.builtin.copy: src: "manual_auth_scripts/{{ item }}.sh" dest: "/usr/local/lib/ansible_certbot/manual_auth_scripts/{{ item }}.sh" diff --git a/roles/certbot/tasks/main/new_cert_commands.yaml b/roles/certbot/tasks/main/new_cert_commands.yaml index 18f4993..70c003b 100644 --- a/roles/certbot/tasks/main/new_cert_commands.yaml +++ b/roles/certbot/tasks/main/new_cert_commands.yaml @@ -1,6 +1,6 @@ --- -- tags: ["certbot", "certbot-new_cert_commands"] - name: ensure existence of renewal deploy hooks directory +- name: ensure existence of renewal deploy hooks directory + tags: [ "certbot" ] ansible.builtin.file: path: /etc/letsencrypt/renewal-hooks/deploy state: directory @@ -9,8 +9,8 @@ mode: "0755" become: true -- tags: ["certbot", "certbot-new_cert_commands"] - name: ensure renewal deploy hook commands +- name: ensure renewal deploy hook commands + tags: [ "certbot" ] ansible.builtin.template: src: renewal_deploy_hook_commands.sh.j2 dest: /etc/letsencrypt/renewal-hooks/deploy/ansible_commands.sh diff --git a/roles/certbot/tasks/main/validate_cert.yaml b/roles/certbot/tasks/main/validate_cert.yaml index cdf08f5..c8e9dfb 100644 --- a/roles/certbot/tasks/main/validate_cert.yaml +++ b/roles/certbot/tasks/main/validate_cert.yaml @@ -1,15 +1,15 @@ --- -- tags: ["certbot", "certbot-validate_cert"] - 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" block: - - tags: ["certbot", "certbot-validate_cert"] - name: assert dns_01_acme_dns config exists + - name: assert dns_01_acme_dns config exists + tags: [ "certbot" ] ansible.builtin.assert: that: item.dns_01_acme_dns is defined - - tags: ["certbot", "certbot-validate_cert"] - 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: argument_spec: "{{ required_data }}" provided_arguments: diff --git a/roles/docker_compose/handlers/main.yaml b/roles/docker_compose/handlers/main.yaml index a4abcba..8885171 100644 --- a/roles/docker_compose/handlers/main.yaml +++ b/roles/docker_compose/handlers/main.yaml @@ -1,13 +1,13 @@ --- -- tags: ["docker_compose"] - name: docker compose down +- name: docker compose down + tags: [ "docker_compose" ] community.docker.docker_compose_v2: project_src: /ansible_docker_compose state: absent become: true -- tags: ["docker_compose"] - name: docker compose restart +- name: docker compose restart + tags: [ "docker_compose" ] community.docker.docker_compose_v2: project_src: /ansible_docker_compose state: restarted diff --git a/roles/docker_compose/tasks/main.yaml b/roles/docker_compose/tasks/main.yaml index a3952e8..17e65a3 100644 --- a/roles/docker_compose/tasks/main.yaml +++ b/roles/docker_compose/tasks/main.yaml @@ -1,6 +1,6 @@ --- -- tags: ["docker_compose"] - name: make sure the `/ansible_docker_compose` directory exists +- name: make sure the `/ansible_docker_compose` directory exists + tags: [ "docker_compose" ] ansible.builtin.file: path: /ansible_docker_compose state: directory @@ -9,8 +9,8 @@ group: root become: true -- tags: ["docker_compose"] - name: deploy the Compose file +- name: deploy the Compose file + tags: [ "docker_compose" ] ansible.builtin.copy: content: "{{ docker_compose__compose_file_content }}" dest: /ansible_docker_compose/compose.yaml @@ -20,8 +20,8 @@ become: true notify: docker compose down -- tags: ["docker_compose"] - name: deploy the .env file +- name: deploy the .env file + tags: [ "docker_compose" ] ansible.builtin.copy: content: "{{ docker_compose__env_file_content }}" dest: /ansible_docker_compose/.env @@ -32,8 +32,8 @@ when: docker_compose__env_file_content is defined notify: docker compose down -- tags: ["docker_compose"] - 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: path: /ansible_docker_compose/configs state: directory @@ -42,29 +42,29 @@ group: root become: true -- tags: ["docker_compose"] - 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: docker_compose__config_files_to_exist: [ ] -- tags: ["docker_compose"] - 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: docker_compose__config_files_to_exist: "{{ docker_compose__config_files_to_exist + [ item.name ] }}" # noqa: jinja[spacing] loop: "{{ docker_compose__configuration_files }}" loop_control: label: "{{ item.name }}" -- tags: ["docker_compose"] - name: find configuration files to remove +- name: find configuration files to remove + tags: [ "docker_compose" ] ansible.builtin.find: paths: /ansible_docker_compose/configs/ recurse: false excludes: "{{ docker_compose__config_files_to_exist }}" register: docker_compose__config_files_to_remove -- tags: ["docker_compose"] - name: remove all configuration files, which should be removed +- name: remove all configuration files, which should be removed + tags: [ "docker_compose" ] ansible.builtin.file: path: "{{ item.path }}" state: absent @@ -72,8 +72,8 @@ loop: "{{ docker_compose__config_files_to_remove.files }}" notify: docker compose restart -- tags: ["docker_compose"] - name: make sure all given configuration files are deployed +- name: make sure all given configuration files are deployed + tags: [ "docker_compose" ] ansible.builtin.copy: content: "{{ item.content }}" dest: "/ansible_docker_compose/configs/{{ item.name }}" @@ -86,8 +86,8 @@ label: "{{ item.name }}" notify: docker compose restart -- tags: ["docker_compose"] - name: Sync files +- name: Sync files + tags: [ "docker_compose" ] ansible.posix.synchronize: src: "{{ docker_compose__files }}/" dest: "/ansible_docker_compose/files" @@ -98,12 +98,12 @@ notify: docker compose restart when: docker_compose__files != "" -- tags: ["docker_compose"] - 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 -- tags: ["docker_compose"] - name: docker compose up +- name: docker compose up + tags: [ "docker_compose" ] community.docker.docker_compose_v2: project_src: /ansible_docker_compose state: present @@ -112,15 +112,15 @@ remove_orphans: true become: true -- tags: ["docker_compose"] - name: Make sure anacron is installed +- name: Make sure anacron is installed + tags: [ "docker_compose" ] become: true ansible.builtin.package: name: anacron state: present -- tags: ["docker_compose"] - name: ensure automatic update cron job is present +- name: ensure automatic update cron job is present + tags: [ "docker_compose" ] become: true ansible.builtin.cron: name: 'ansible docker compose auto update' diff --git a/roles/infrastructure_authorized_keys/tasks/main.yaml b/roles/infrastructure_authorized_keys/tasks/main.yaml index 5c6ef1c..c82ced3 100644 --- a/roles/infrastructure_authorized_keys/tasks/main.yaml +++ b/roles/infrastructure_authorized_keys/tasks/main.yaml @@ -1,6 +1,6 @@ --- -- tags: ["infrastructure_authorized_keys"] - name: deploy infrastructure authorized keys +- name: deploy infrastructure authorized keys + tags: [ "infrastructure_authorized_keys" ] ansible.posix.authorized_key: state: present user: chaos diff --git a/roles/msmtp/tasks/main.yaml b/roles/msmtp/tasks/main.yaml index 655f391..664ff6d 100644 --- a/roles/msmtp/tasks/main.yaml +++ b/roles/msmtp/tasks/main.yaml @@ -1,13 +1,13 @@ --- -- tags: ["msmtp"] - name: ensure msmtp is installed +- name: ensure msmtp is installed + tags: [ "msmtp" ] ansible.builtin.apt: name: msmtp state: present become: true -- tags: ["msmtp"] - name: ensure msmtp config for root user +- name: ensure msmtp config for root user + tags: [ "msmtp" ] ansible.builtin.template: src: msmtprc.j2 dest: /root/.msmtprc