--- /dev/null
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+- hosts: servers
+ vars:
+ repo: "{{ ansible_local.env.vars.git_home_dir }}/cron.git"
+ tasks:
+ - name: Checkout systemd services and timers
+ command: /usr/bin/git --work-tree=/etc/systemd/system \
+ --git-dir={{ repo }} checkout main --force *.service *.timer
+ become: true
+ - find:
+ paths: /etc/systemd/system
+ file_type: file
+ patterns: "*.timer"
+ register: timers
+ - name: Enable all timers
+ service:
+ name: "{{ item.path }}"
+ enabled: true
+ daemon_reload: true
+ become: true
+ with_items: "{{ timers.files }}"
--- /dev/null
+#!/bin/sh
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+while read old_revision new_revision branch
+do
+ if [ "${branch}" != "refs/heads/main" ]
+ then
+ echo "${branch} is not the main branch so not deploying."
+ exit 0
+ fi
+ sudo /usr/bin/ansible-playbook --connection=local deploy.yaml
+done