From 53d7407ebdae8eb9c79ca2486a3ab52dd6f2c5c6 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Fri, 5 May 2023 09:49:52 +0200 Subject: [PATCH] image: run ansible-poll at first startup Ensure we don't have to wait an hour for cron to trigger the first pull. Immediately start configuring the system at first boot. We run twice, to make sure we've set the hostname and then applied the per-host configuration. --- image/overlay/domotica/etc/rc.d/ansibleprep | 9 +++++++++ image/overlay/domotica/home/kp/bin/ansible_poll | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/image/overlay/domotica/etc/rc.d/ansibleprep b/image/overlay/domotica/etc/rc.d/ansibleprep index 9d2632b..9d557b2 100755 --- a/image/overlay/domotica/etc/rc.d/ansibleprep +++ b/image/overlay/domotica/etc/rc.d/ansibleprep @@ -13,6 +13,8 @@ start_cmd="ansibleprep_start" ansibleprep_start() { + export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin + # Just enough so kp can log in pw user add kp pw user mod kp -s /usr/local/bin/zsh @@ -21,6 +23,13 @@ ansibleprep_start() # And sudo should work for ansible chown root:wheel /usr/local/etc/sudoers + + # Run ansible-pull so we install immediately rather than wait for cron + /home/kp/bin/ansible_poll + + # And again, because the first run sets a hostname, the second one + # applies per-host configuration + /home/kp/bin/ansible_poll } load_rc_config $name diff --git a/image/overlay/domotica/home/kp/bin/ansible_poll b/image/overlay/domotica/home/kp/bin/ansible_poll index 64d0b6a..db833ed 100755 --- a/image/overlay/domotica/home/kp/bin/ansible_poll +++ b/image/overlay/domotica/home/kp/bin/ansible_poll @@ -1,6 +1,6 @@ #!/bin/sh -ansible-pull \ +/usr/local/bin/ansible-pull \ -o \ -U https://git.sigsegv.be/pennestraat-domotica \ -i ansible/inventory.yaml \ -- 2.51.0