Puppet run from provisioning script doesn't work

After I provision a new instance via Foreman, it doesn't seem to be able to
run the puppet agent properly. In the agent report the most obvious error I
see is:

Could not retrieve catalog from remote server: Error 400 on SERVER: Failed
when searching for node foo.exampledomain.com: Failed to find
foo.exampledomain.com via exec: Execution of '/usr/local/bin/foreman_enc.rb
foo.exampledomain.com' returned :

If I then log onto the server via ssh and run puppet agent manually, it
works fine.

I did some more testing and fired up a new server, and while Foreman was
provisioning the server I tried running my foreman enc script with the new
host's hostname. It sat there deliberating for a long, long time without
spitting out any info. While this was happening I checked the new instance
and puppet was running. I also checked /var/lib/puppet/yaml/facts on the
puppet/foreman server and the yaml for the new instance didn't get created
for ages.

It's like there's some kind of weird catch-22 where foreman doesn't create
the server info till after the provisioning process is complete, which
means the puppet agent can't get the info when the provisioning script runs.

Any ideas why?

I found a solution for this. Instead of running puppet from the
provisioning script, I instead set the script to reboot after changing the
hostname and updated /etc/rc.local to run puppet on first boot. It seems to
be working so far.

ยทยทยท On Thursday, 18 July 2013 11:39:36 UTC-7, Guy Knights wrote: > > After I provision a new instance via Foreman, it doesn't seem to be able > to run the puppet agent properly. In the agent report the most obvious > error I see is: > > Could not retrieve catalog from remote server: Error 400 on SERVER: Failed > when searching for node foo.exampledomain.com: Failed to find > foo.exampledomain.com via exec: Execution of > '/usr/local/bin/foreman_enc.rb foo.exampledomain.com' returned : > > If I then log onto the server via ssh and run puppet agent manually, it > works fine. > > I did some more testing and fired up a new server, and while Foreman was > provisioning the server I tried running my foreman enc script with the new > host's hostname. It sat there deliberating for a long, long time without > spitting out any info. While this was happening I checked the new instance > and puppet was running. I also checked /var/lib/puppet/yaml/facts on the > puppet/foreman server and the yaml for the new instance didn't get created > for ages. > > It's like there's some kind of weird catch-22 where foreman doesn't create > the server info till after the provisioning process is complete, which > means the puppet agent can't get the info when the provisioning script runs. > > Any ideas why? >