- Puppet 5 Essentials(Third Edition)
- Martin Alfke Felix Frank
- 258字
- 2021-07-02 18:22:23
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.
- 從零開始:數(shù)字圖像處理的編程基礎(chǔ)與應(yīng)用
- 深度學(xué)習(xí)經(jīng)典案例解析:基于MATLAB
- C#程序設(shè)計(慕課版)
- 面向STEM的Scratch創(chuàng)新課程
- Java面向?qū)ο蟪绦蜷_發(fā)及實戰(zhàn)
- Linux操作系統(tǒng)基礎(chǔ)案例教程
- Building an RPG with Unity 2018
- SQL基礎(chǔ)教程(第2版)
- 單片機C語言程序設(shè)計實訓(xùn)100例
- C語言程序設(shè)計
- Image Processing with ImageJ
- ExtJS Web應(yīng)用程序開發(fā)指南第2版
- FFmpeg開發(fā)實戰(zhàn):從零基礎(chǔ)到短視頻上線
- Scala Functional Programming Patterns
- Oracle Data Guard 11gR2 Administration Beginner's Guide