出现错误时如何停止 Puppet 应用配置?
How to stop Puppet applying a configuration when there is an error?
对我来说,我目前在 Puppet 中遇到了一些不直观的行为 - 很可能是因为我还没有完全理解 Puppet 的精神。
OK 我在 puppet 代理中有一个简单的 puppetsimple.sh
运行ning,它正在应用来自 puppet master 的配置。这一切 运行ning 都很顺利,符合预期。
不直观(对我来说) 然而,当我作为设置 master 的一部分时,创建一个错误,然后在代理中 运行 puppetsimple.sh
,它将触发错误,通知我,并继续应用该配置的所有其他更改。
这实际上使代理处于中断状态,因为即使出现错误它也会继续推进。
有什么设置可以说"hey, if you strike an error, stop, revert to how you were, and carry on your merry way"吗?
给出下面的例子。我故意启用无效的 conf 文件 (.confX) - 我收到错误通知,但它继续使用 "Hello World 3" 填充 "index.html"。
define a2ensite {
exec { 'a2ensite':
path => [ '/bin', '/usr/bin', '/usr/sbin' ],
command => "a2ensite ${title}",
notify => Service['apache2'],
}
}
class mysite {
include apache
file { '/etc/apache2/sites-available/mysite.example.org.conf':
owner => root,
group => root,
mode => 0644,
source => "puppet:///files/mysite/mysite_apache.conf",
notify => Service['apache2'],
}
a2ensite { 'mysite.example.org.confX': }
file { ['/home/', '/home/www/', '/home/www/mysite.example.org']:
ensure => directory,
owner => root,
group => root,
mode => 0755,
}
file { '/home/www/mysite.example.org/index.html':
owner => www-data,
group => www-data,
mode => 755,
content => "Hello World 3",
}
}
如果一个资源失败意味着不应该修改另一个资源,那么这就是您需要通过 require
建模的依赖关系。失败的依赖项将导致 Puppet 跳过这些资源。
但是,通常情况下,puppet 在遇到错误时不会停止或回滚运行。如果您需要回滚,您可以恢复到旧的 Puppet 配置或使用其他功能来恢复节点。
对我来说,我目前在 Puppet 中遇到了一些不直观的行为 - 很可能是因为我还没有完全理解 Puppet 的精神。
OK 我在 puppet 代理中有一个简单的 puppetsimple.sh
运行ning,它正在应用来自 puppet master 的配置。这一切 运行ning 都很顺利,符合预期。
不直观(对我来说) 然而,当我作为设置 master 的一部分时,创建一个错误,然后在代理中 运行 puppetsimple.sh
,它将触发错误,通知我,并继续应用该配置的所有其他更改。
这实际上使代理处于中断状态,因为即使出现错误它也会继续推进。
有什么设置可以说"hey, if you strike an error, stop, revert to how you were, and carry on your merry way"吗?
给出下面的例子。我故意启用无效的 conf 文件 (.confX) - 我收到错误通知,但它继续使用 "Hello World 3" 填充 "index.html"。
define a2ensite {
exec { 'a2ensite':
path => [ '/bin', '/usr/bin', '/usr/sbin' ],
command => "a2ensite ${title}",
notify => Service['apache2'],
}
}
class mysite {
include apache
file { '/etc/apache2/sites-available/mysite.example.org.conf':
owner => root,
group => root,
mode => 0644,
source => "puppet:///files/mysite/mysite_apache.conf",
notify => Service['apache2'],
}
a2ensite { 'mysite.example.org.confX': }
file { ['/home/', '/home/www/', '/home/www/mysite.example.org']:
ensure => directory,
owner => root,
group => root,
mode => 0755,
}
file { '/home/www/mysite.example.org/index.html':
owner => www-data,
group => www-data,
mode => 755,
content => "Hello World 3",
}
}
如果一个资源失败意味着不应该修改另一个资源,那么这就是您需要通过 require
建模的依赖关系。失败的依赖项将导致 Puppet 跳过这些资源。
但是,通常情况下,puppet 在遇到错误时不会停止或回滚运行。如果您需要回滚,您可以恢复到旧的 Puppet 配置或使用其他功能来恢复节点。