Ask Your Question

How can I set something only on first boot with puppet?

asked 2013-03-11 09:48:52 -0600

simonC gravatar image

updated 2013-03-11 10:00:15 -0600

llowder gravatar image


I would like to know if it is possible to do something only on the very first boot of the machine with puppet.

for example

if $::is_first_boot == true {
  do something
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-12 03:35:52 -0600

mattjb gravatar image

This is kind of a quick and dirty way to do this, but I generate a puppet_history file in /etc/puppet on every node. We have an inventory api that puppet does a POST to when a box gets installed or reinstalled and I do a lot of similar stuff by cheaply doing something similar to the following:

exec { "inventory_checkin":
    command => "/some/inventory/ && /bin/echo 'inventory_initialized' >> /etc/puppet/puppet_history",
    unless  => "/bin/grep 'inventory_initialized' /etc/puppet/puppet_history",
    returns => '0',
    require => File["/some/inventory/"],

If something breaks or does something odd, our central syslog sends us an alert ... (more)

edit flag offensive delete link more


I was also looking for something like this...I think I will go that way. Besides all this it would be realy cool to have a built in fact that ...(more)

simonC gravatar imagesimonC ( 2013-03-12 04:32:43 -0600 )edit

You could pass -q to grep to make it only return the exit status and not produce any output. Also look at 'creates': ...(more)

ptman gravatar imageptman ( 2013-03-12 07:50:00 -0600 )edit

answered 2013-03-11 09:57:42 -0600

llowder gravatar image

If you have a fact that is set to true on first boot, and false after that, this would be possible - though not 100% reliable as facts are provided by the client. You would need to make sure that Puppet is installed and configured as part of the template or provisioning - before the system is ever booted.

If you can describe what you are trying to accomplish, there is probably a better way (for example, as part of a provisioning phase of Razor, Cobbler or The Foreman), as this seems like a bad idea and a potential source of problems.

edit flag offensive delete link more


I'm seteing up a virtaul machine for our web java/mysql application via puppet and I install java, jboss, mysql via puppet and ashure that they are running...after ...(more)

simonC gravatar imagesimonC ( 2013-03-11 10:10:35 -0600 )edit

typically you would have something like database { myapp: ensure => present, notify => Exec['load_dump'] } and exec { 'load_dump': command => ..., refreshonly => true} So if puppet creates the database the ...(more)

Stefan gravatar imageStefan ( 2013-03-11 12:21:41 -0600 )edit

Agreed, sounds like maybe you want something that will import the dump if its not in the DB, as opposed to on the first boot only. You could also maybe ...(more)

jonn gravatar imagejonn ( 2013-03-17 11:19:53 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-03-11 09:48:52 -0600

Seen: 1,233 times

Last updated: Mar 12 '13