官术网_书友最值得收藏!

Error propagation

Defining requirements serves another important purpose. References on declared resources will only be validated as successful references if the depended-upon resource was finished successfully. This can be seen as a kind of stop point inside Puppet DSL code, when a required resource is not synchronized successfully.

For example, a file resource will fail if the URL of the source file is broken:

file { '/etc/haproxy/haproxy.cfg':
ensure => file,
source => 'puppet:///modules/haproxy/etc/haproxy.cfg',
}

One path segment is missing here. Puppet will report that the file resource could not be synchronized:

root@puppetmaster:~# puppet apply typo.pp
Notice: Compiled catalog for puppetmaster.example.net in environment production in 0.62 seconds
Error: /Stage[main]/Main/File[/etc/haproxy/haproxy.cfg]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/haproxy/etc/haproxy.cfg
Notice: /Stage[main]/Main/Service[haproxy]: Dependency File[/etc/haproxy/haproxy.cfg] has failures: true
Warning: /Stage[main]/Main/Service[haproxy]: Skipping because of failed dependencies
Notice: Applied catalog in 0.06 seconds

In this example, the Error line describes the error caused by the broken URL. The error propagation is represented by the Notice and Warning lines below it.

Puppet failed to apply changes to the configuration file; it cannot compare the current state to the nonexistent source. As the service depends on the configuration file, Puppet will not even try to start it. This is for safety: if any dependencies cannot be put into the defined state, Puppet must assume that the system is not fit for the application of the dependent resource.

This is another important reason to make use of resource dependencies. Remember that both the chaining arrow and the before metaparameter imply error propagation as well.

主站蜘蛛池模板: 盐源县| 丘北县| 靖宇县| 耿马| 黑河市| 元谋县| 嘉荫县| 北宁市| 梁山县| 巴塘县| 阜城县| 鄂托克旗| 桂阳县| 武夷山市| 洞口县| 酒泉市| 特克斯县| 宁蒗| 灵台县| 萨嘎县| 德格县| 祁阳县| 黄浦区| 通辽市| 广元市| 嵊泗县| 新竹县| 平江县| 鄂尔多斯市| 莒南县| 丰宁| 聊城市| 贞丰县| 灵武市| 呼玛县| 饶河县| 长顺县| 东阳市| 林甸县| 合肥市| 崇左市|