簡體   English   中英

出現錯誤時如何停止Puppet應用配置?

[英]How to stop Puppet applying a configuration when there is an error?

目前,我對Puppet的舉止有些不直觀,這很可能是因為我尚未完全了解Puppet的精神。

好的,我在puppet代理中運行了一個簡單的puppetsimple.sh ,它正在應用來自puppet master的配置。 一切運行順利,符合預期。

不直觀(對我來說)但是,當我作為設置master的一部分創建錯誤,然后在代理中運行puppetsimple.sh時,它將發出錯誤,並通知我,並繼續將所有其他更改應用於該配置。

這有效地使代理處於損壞狀態,因為即使出現錯誤,代理也會繼續前進。

在某處是否有一個設置可以說“嘿,如果您遇到錯誤,請停下來,恢復到原來的狀態,然后繼續自己的快樂”?

給出以下示例。 我故意啟用了無效的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建模的依賴關系。 失敗的依賴關系將導致p跳過那些資源。

但是,通常,當遇到錯誤時,p不會停止或回滾運行。 如果需要回滾,您可以選擇還原到較早的人偶配置,也可以使用其他功能來還原節點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM