简体   繁体   中英

Puppet reboot in stages

I need to do a two step installation of a CentOS6 host with puppet (currently using puppet apply) and got stuck. Not even sure it's currently possible today.

Step 1 , setup of base system eg setup hosts, ntp, mail and some driver stuff.

reboot required

Step 2 , setup of a custom service.

Can this bee done a smooth way? I'm not very familiar with the puppet environment yet.

First off, I very much doubt that any setup steps on a CentOS machine strictly require a reboot. It is usually sufficient to restart the right set of services to make all settings take effect.

Anyway, basic approach to this type of problem could be to

  1. Define a custom fact that determines whether a machine is ready to receive the final configuration steps (Step 2 in your question)
  2. Protect the pertinent parts of your manifest with an if condition that uses that fact value.

You may want to create a file first, then delete it when you are done installing the base system (ntp in the below example)

for example

exec { '/tmp/reboot':
  path    => "/usr/bin:/bin:/sbin",
  command => 'touch /tmp/reboot',
  onlyif => 'test ! -f /tmp/rebooted',
}


service { 'ntp':
    require => Exec['/tmp/reboot'],
...
}

exec { 'reboot':
    command => "mv /tmp/reboot /tmp/rebooted; reboot",
    path    => "/usr/bin:/bin:/sbin",
    onlyif  => "test -f /tmp/reboot",
    require => Service['ntp'],
    creates => '/tmp/rebooted',
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM