(更新)我在原始問題中忽略了一行重要的代碼。如何確保服務在執行Exec資源之前重新啓動?
我寫了一個將創建本地存儲的傀儡模塊。這是不自動的方式。
- 編輯/etc/multipath.conf文件
- 重新啓動在multipathd守護
- 執行pvcreate將$設備
- 執行的vgcreate $ VOLUME_NAME $設備
所以在我的木偶模塊I如果/etc/multipath.conf文件更改,則要確保multipathd守護進程重新啓動。所以我用這種方式寫了我的傀儡表。
Service['multipathd'] -> Anchor['create_storage_volume::begin']
...
file { '/etc/multipath.conf':
ensure => file,
content => template('local_storage::hadoop/multipath.conf.erb'),
owner => 'root',
mode => '0600',
notify => Service['multipathd'],
} ->
service { 'multipathd':
enable => true,
ensure => running,
}
anchor { 'create_storage_volume::begin': } ->
exec { "pvcreate ${device}":
path => ['/usr/sbin', '/bin'],
unless => "pvs | grep ${"volume_name},
} ->
exec { "vgcreate ${volume_name} ${device}":
path => ['/usr/sbin', '/bin'],
unless => "pvs | grep ${"volume_name},
} -> # -> do nova config stuff
anchor { 'create_storage_volume::end': }
...
我的問題是,「做上面的代碼保證了在multipathd守護程序被執行pvcreate和運行vgcreate指令執行前重新啓動」?我是否需要添加更多類似資源的訂單...
Service['multipathd'] -> Anchor['local_storage::begin']
?
謝謝你的回答。我有幾個問題。我在我原來的問題中忽略了這一行:Service ['multipathd'] - > Anchor ['create_storage_volume :: begin'](我會更新我的問題),但確保服務multipathd在我之前重新啓動Exec資源執行? –
從技術上講,Puppet的文檔沒有明確說明資源刷新的時間。在實踐中,在當前和歷史版本的Puppet中,如果資源要刷新,那麼它將在它(或將要)同步之後立即執行。 –
@RedCricket我唯一的補充建議是檢查Puppet的'lvm'模塊。 –