image: improve ansibleprep run
authorKristof Provost <kp@FreeBSD.org>
Wed, 12 Jul 2023 11:06:24 +0000 (13:06 +0200)
committerKristof Provost <kp@FreeBSD.org>
Wed, 12 Jul 2023 11:06:24 +0000 (13:06 +0200)
Make it more likely we'll call ansible-poll at first boot.
If there's no internet connectivity on first boot we woudln't ansible-
poll until the crontab called it.

Instead we now run ansibleprep every time and exit if our hostname
isn't poudriere-image (i.e. if we've actually run the first ansible-
poll call).

image/overlay/domotica/etc/rc.d/ansibleprep

index 9d557b2..e778aba 100755 (executable)
@@ -4,7 +4,6 @@
 # PROVIDE: ansibleprep
 # REQUIRE: DAEMON
 # BEFORE: LOGIN
-# KEYWORD: firstboot
 
 . /etc/rc.subr
 
@@ -13,6 +12,14 @@ start_cmd="ansibleprep_start"
 
 ansibleprep_start()
 {
+       # Only do this until we've set the hostname, which we use as a proxy for
+       # 'initial config done, reverse ssh tunnel ready'
+       # We do do a daily poll, so worst case it'll eventually work out.
+       if [ $(hostname) != "poudriere-image" ];
+       then
+               exit 0
+       fi
+
        export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
 
        # Just enough so kp can log in