RHEL8 Agent Install - Chicken or Egg Problem

I am having to run a bash script in Pre-Provisioning that registers the RHEL8 VM to Satellite. But if I choose the Install Agent checkbox on the image, it tries to run the cloud-init runcmd script before this registration has been performed, so the repos are not enabled, and the VM sits in a “Finalizing” state. Should I just run the /var/lib/cloud/instance/scripts/runcmd script after the satellite registration script? Or, is there a cleaner better way to install the agent as part of a provisioning workflow?

If you add the satellite registration script to the cloud-init user data on the virtual image record, it will run before the agent install runcmd as it will be added to the generated cloud-init userdata. pre-provision phase for vm’s does not execute before cloud-init run.

1 Like

That’s a great (better) idea. I was able to get it working like this, but of course it could confuse people because the “Install Agent” is unchecked, and this logic of mine would run regardless of whether someone checks the box or not. So let me try your method, which is cleaner.