--- /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 }}/config.git"
+ tasks:
+ - name: Checkout environment to /etc
+ command: /usr/bin/git --work-tree=/etc --git-dir={{ repo }} \
+ checkout main --force environment
+ become: true
+ - name: Create facts.d directory
+ file:
+ path: /etc/ansible/facts.d
+ state: directory
+ become: true
+ - name: Export environment as ansible facts in the .ini format
+ shell: sed --expression 's/export\s//g ; s/\"//g ; 1s/^.*$/[vars]/' \
+ /etc/environment > /etc/ansible/facts.d/env.fact
+ become: true
--- /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