2015-09-02 40 views
2

我在puppet中創建一個名爲jboss的組,然後使用exec運行sed命令,以便在之後對/etc/group文件進行一些更改。
問題是exec命令在組命令之前運行。傀儡在其他命令之前運行exec

我YAML文件

group { 'jboss': 
     ensure => 'present', 
     gid => "501", 
    } 
    exec { "modify etc_group": 
     command => "/bin/sed -i -e '<regex>' /etc/group", 
     path => "/bin:/usr/bin", 
     unless => "<condition>", 
    } 

木偶運行輸出

notice: /Stage[main]/App::Misc/Exec[modify etc_group]/returns: current_value notrun, should be 0 (noop) 
notice: /Stage[main]/App::Misc/Group[jboss]/ensure: current_value absent, should be present (noop) 

如何確保該group命令後exec運行?

+1

濫用'exec'以不同方式管理資源(例如'groups'文件)幾乎總是一個壞主意。如何規避需求可能是一個更好的問題。 –

+0

是的,我知道這是一種糟糕的方式,但不幸的是,由於傳統設計不當,我們必須手動修改此文件,並且無法繞過它。 – Arpit

回答

4

只需定義groupexec之間的關係即可。

E.g:

exec { "modify etc_group": 
    command => "/bin/sed -i -e '<regex>' /etc/group", 
    path => "/bin:/usr/bin", 
    unless => "<condition>", 
    require => Group['jboss'], 
} 

更多關於木偶here關係。