Bootstrap in chroot

Markus Rexhepi-Lindberg <[email protected]> Mon, 20 May 2024 02:58:14 -0700 (PDT)
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
Is it possible to bootstrap a host running in a chroot?

I want to bootstrap a host during its provisioning stage were it currently 
runs in a chroot environment. While bootstrapping cf-agent complains that 
the cf-execd daemon is not running, which seems to be the case since 
cfengine3.service is not allowed to start in a chroot environment.

```
# chroot /target cf-agent -B <cfehub>
notice: Bootstrap mode: implicitly trusting server, use --trust-server=no 
if server trust is already established
  notice: Trusting new key: MD5=<redacted>
R: Bootstrapping from host '<redacted>' via built-in policy 
'/var/cfengine/inputs/failsafe.cf'
R: This autonomous node assumes the role of voluntary client
R: Updated local policy from policy server
R: Triggered an initial run of the policy
R: Restarted systemd unit cfengine3
   error: Bootstrapping failed, cf-execd is not running
  notice: Bootstrap mode: implicitly trusting server, use --trust-server=no 
if server trust is already established
```

I managed to workaround this by first trying to bootstrap, which fails, 
then manually start cf-execd in the chroot and finally try to bootstrap 
again which succeeds.

```
# chroot /traget cf-execd
# chroot /target cf-agent -B <cfehub>
R: Bootstrapping from host '<redacted>' via built-in policy 
'/var/cfengine/inputs/failsafe.cf'
R: This autonomous node assumes the role of voluntary client
R: Updated local policy from policy server
R: Triggered an initial run of the policy
  notice: Bootstrap to '<redacted>' completed successfully!
```

This works but feels like a hack. Is there another way this could be done?

--
Markus

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/e6e87828-d8aa-4040-9352-ef9e6f4a1f9bn%40googlegroups.com.