简体   繁体   English

人偶分阶段重启

[英]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. 我需要使用p(目前使用puppet apply)对CentOS6主机进行两步安装,并被卡住。 Not even sure it's currently possible today. 甚至不确定今天是否有可能。

Step 1 , setup of base system eg setup hosts, ntp, mail and some driver stuff. 步骤1 ,基本系统的设置,例如设置主机,ntp,邮件和一些驱动程序。

reboot required 需要重启

Step 2 , setup of a custom service. 步骤2 ,设置自定义服务。

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. 首先,我非常怀疑CentOS机器上的任何设置步骤都严格要求重新启动。 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)
  2. Protect the pertinent parts of your manifest with an if condition that uses that fact value. 使用使用该事实值的if条件保护清单的相关部分。

You may want to create a file first, then delete it when you are done installing the base system (ntp in the below example) 您可能要先创建一个文件,然后在完成基本系统的安装后将其删除(以下示例中的ntp)

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',
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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