diff --git a/inventories/chaosknoten/group_vars/all.yaml b/inventories/chaosknoten/group_vars/all.yaml index e81690b..3612ebc 100644 --- a/inventories/chaosknoten/group_vars/all.yaml +++ b/inventories/chaosknoten/group_vars/all.yaml @@ -1,10 +1,9 @@ # ansible_pull # ansible_pull__age_private_key needs to be defined per host (probably HOST.sops.yaml). ansible_pull__repo_url: https://git.hamburg.ccc.de/CCCHH/ansible-infra.git +ansible_pull__inventory: inventories/chaosknoten ansible_pull__playbook: playbooks/maintenance.yaml -ansible_pull__checkout: ansible_pull_notify ansible_pull__timer_on_calendar: "*-*-* 04:00:00 Europe/Berlin" -ansible_pull__failure_notification_address: june+test@jsts.xyz ansible_pull__timer_randomized_delay_sec: 30min # msmtp diff --git a/roles/ansible_pull/README.md b/roles/ansible_pull/README.md index cf90e60..f31c552 100644 --- a/roles/ansible_pull/README.md +++ b/roles/ansible_pull/README.md @@ -13,7 +13,6 @@ Should work on Debian-based distributions. - `ansible_pull__inventory`: The inventory to use. - `ansible_pull__playbook`: The playbook to run. - `ansible_pull__timer_on_calendar`: When to run the playbook. This is the argument to a systemd timers OnCalendar. See the systemd.time man page for reference. -- `ansible_pull__failure_notification_address`: The address to send the failure notification to. ## Optional Arguments diff --git a/roles/ansible_pull/meta/argument_specs.yaml b/roles/ansible_pull/meta/argument_specs.yaml index 682fdcd..e5c88af 100644 --- a/roles/ansible_pull/meta/argument_specs.yaml +++ b/roles/ansible_pull/meta/argument_specs.yaml @@ -16,9 +16,6 @@ argument_specs: ansible_pull__timer_on_calendar: type: str required: true - ansible_pull__failure_notification_address: - type: str - required: true ansible_pull__user: type: str required: false diff --git a/roles/ansible_pull/meta/main.yaml b/roles/ansible_pull/meta/main.yaml deleted file mode 100644 index 25aaf90..0000000 --- a/roles/ansible_pull/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - role: msmtp diff --git a/roles/ansible_pull/tasks/main.yaml b/roles/ansible_pull/tasks/main.yaml index eff8cb0..53fc219 100644 --- a/roles/ansible_pull/tasks/main.yaml +++ b/roles/ansible_pull/tasks/main.yaml @@ -15,15 +15,6 @@ virtualenv: /usr/local/lib/ansible_pull_venv become: true -- name: ensure ansible-pull-failure-notify script installation exists - ansible.builtin.template: - src: ansible-pull-failure-notify.sh.j2 - dest: /usr/local/sbin/ansible-pull-failure-notify.sh - owner: root - group: root - mode: "0755" - become: true - - name: ensure secrets directory exists ansible.builtin.file: path: /etc/ansible_pull_secrets @@ -42,17 +33,14 @@ group: "{{ ansible_pull__user }}" become: true -- name: ensure systemd services exists +- name: ensure systemd service exists ansible.builtin.template: - src: "{{ item }}.j2" - dest: "/etc/systemd/system/{{ item }}" + src: ansible-pull.service.j2 + dest: /etc/systemd/system/ansible-pull.service owner: root group: root mode: "0644" become: true - loop: - - ansible-pull.service - - ansible-pull-failure-notify.service notify: - systemd daemon reload diff --git a/roles/ansible_pull/templates/ansible-pull-failure-notify.service.j2 b/roles/ansible_pull/templates/ansible-pull-failure-notify.service.j2 deleted file mode 100644 index fa5d471..0000000 --- a/roles/ansible_pull/templates/ansible-pull-failure-notify.service.j2 +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=ansible-pull failure notifier - -[Service] -Type=oneshot -ExecStart=/usr/local/sbin/ansible-pull-failure-notify.sh -User=root diff --git a/roles/ansible_pull/templates/ansible-pull-failure-notify.sh.j2 b/roles/ansible_pull/templates/ansible-pull-failure-notify.sh.j2 deleted file mode 100644 index fe7dbc8..0000000 --- a/roles/ansible_pull/templates/ansible-pull-failure-notify.sh.j2 +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -# Ideally we would use --invocation instead of --since, but this isn't supported in the systemd version Debian 12 ships. -ANSIBLE_PULL_LOG=$(journalctl --unit=ansible-pull --identifier=ansible-pull --since=-6h --output=cat) - -MESSAGE="Subject: [{{ inventory_hostname }}] ansible-pull: execution failure - -An error occured during the ansible-pull execution. - -Logs: -""$ANSIBLE_PULL_LOG"" - -To view the logs yourself run: -journalctl --unit=ansible-pull --identifier=ansible-pull -e -" - -printf "$MESSAGE" | msmtp '{{ ansible_pull__failure_notification_address }}' diff --git a/roles/ansible_pull/templates/ansible-pull.service.j2 b/roles/ansible_pull/templates/ansible-pull.service.j2 index 0f80907..588741c 100644 --- a/roles/ansible_pull/templates/ansible-pull.service.j2 +++ b/roles/ansible_pull/templates/ansible-pull.service.j2 @@ -2,7 +2,6 @@ Description=ansible-pull for configuration and maintenance After=network-online.target Wants=network-online.target -OnFailure=ansible-pull-failure-notify.service [Service] Type=oneshot