image: run ansible-poll at first startup
authorKristof Provost <kp@FreeBSD.org>
Fri, 5 May 2023 07:49:52 +0000 (09:49 +0200)
committerKristof Provost <kp@FreeBSD.org>
Fri, 5 May 2023 07:49:52 +0000 (09:49 +0200)
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
image/overlay/domotica/home/kp/bin/ansible_poll

index 9d2632b..9d557b2 100755 (executable)
@@ -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
index 64d0b6a..db833ed 100755 (executable)
@@ -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 \