Re: Bootstrap in chroot

"'Vratislav Podzimek' via help-cfengine" <[email protected]> Wed, 22 May 2024 12:50:44 +0200
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
Hi Markus,

On Mon, 2024-05-20 at 02:58 -0700, Markus Rexhepi-Lindberg wrote:
> 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?
Did you check if the second run is necessary? AFAICT, the error about cf-execd
not running is a valid one, but it doesn't mean that the rest of the bootstrap
process didn't run or failed. I'd expect the host to be bootstrapped just fine
just with the daemons (cf-execd, cf-serverd, cf-monitord) not running. So I
think you can skip the last step, but you should start the other two daemons in
the chroot as well.

--
Vratislav

-- 
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/ae036b1cced0152857105ee5a84e937aff8ce97e.camel%40northern.tech.
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEENAH7ns+FyuCe6j1XmyV2peQQR/QFAmZNzgQACgkQmyV2peQQ
R/SQ+w//cJBVMq5V6lWcIBvFmas0D0sKfuQwfIPmXRs9iZJd4Af3NySwLmezIGay
mVhkeutkhsBmgCwL9ELiJVhOfRohwgBaH7GjquzkxN1C7w5l8uV7EaDP6DcdJ6Oo
TUknDQp4hedEFq5DaM7KI10SRtWBMdfnuZ9B1iNb1kHlNAdce3jqXHw2nUbDMz6U
YXhLnntb68wiqHwWh4DeAnoCulqfa+Aw3oajLFS82+Y7OX5emtFWpBWe90Tm2Njm
yK33y6SikCnf2NHSNwplIdQOtv9HCa7FWcmiIyhYCoxFTx/X20aNESWtkAkEK3KI
hhj4CVggu4Iwbg0597oodJXLjCc+Dm7J8Af1YLYjwkLDNzya1tzz5t24IPAyEn5f
ynkuqhnFT6G0guljIzyevz7rXVjWFtj1BkfpktMcKoyppvMsuf0D8BFw+dRq3SY0
5GIIwFRG+of3Pq4tHpO3eo2kkM0e4dcPO5ojZt0eElNVZdrKJfCwkByRe5cu0vBC
oGLTIJ+1QcmAqaRrMwmWg7o+TctDeRaG038ljrZqsUdJ/JLlQt48zSaRHOSKhVnf
Agn5gCSNvGbgEHiGzXgqjyryxgGs8Cpm4LbWrlS+exPxm3RWPJuODBG5VfSPf58S
oPBUgVeQmpdBNdicb6QFswRRVtuDTbWnZi2meKqwx6i2m4xau/A=
=xGx5
-----END PGP SIGNATURE-----