[英]Missing resources when running “puppet agent --noop”
我可能誤解了“ puppet agent --noop
”的工作原理:
在類的定義中,我設置了一個文件的存在,並設置了它的用戶和組所有權,這就是我取消“ puppet agent --noop
”時的狀態:
puppet agent --noop
”可以正常工作 puppet agent --noop
”無法抱怨缺少的用戶或組。 puppet agent
”(不帶“ --noop
”),它就可以正常工作:用戶,組或文件先前是否存在無關緊要:它將創建組,用戶和/或文件。 第一個問題:我想“ --noop
”運行不會驗證目錄是否要求創建丟失的資源。 是不是
第二個問題:啟動“時,有沒有辦法做任何一種嘲諷 ,以避免丟失資源的問題--noop
”?
讓我們粘貼一些代碼來顯示它:
# yes, it should better be virtual resources
group { $at_group:
ensure => "present"
}
user { $at_user:
ensure => present,
gid => "$at_group",
require => Group[$at_group],
}
file { '/etc/afile':
owner => $at_user,
group => $at_group,
mode => '0440',
content => template('......erb')
require => User[$at_user]
}
輸出:
# puppet agent --test --noop
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Caching catalog for pagent02
Info: Applying configuration version '1403055383'
Notice: /Stage[main]/Agalindotest::Install/Group[my_group]/ensure: current_value absent, should be present (noop)
Notice: /Stage[main]/Agalindotest::Install/User[my_user]/ensure: current_value absent, should be present (noop)
Error: Could not find user my_user
Error: /Stage[main]/Agalindotest::Install/File[/etc/afile]/owner: change from 1001 to my_user failed: Could not find user my_user
Error: Could not find group my_group
Error: /Stage[main]/Agalindotest::Install/File[/etc/afiles]/group: change from 1001 to my_group failed: Could not find group my_group
讓我們展示一下文件不存在時的工作方式:
然后“ puppet agent --test --noop
”就像一個puppet agent --test --noop
:
Notice: /Stage[main]/Agalindotest::Install/Group[my_group]/ensure: current_value absent, should be present (noop)
Notice: /Stage[main]/Agalindotest::Install/User[my_user]/ensure: current_value absent, should be present (noop)
Notice: /Stage[main]/Agalindotest::Install/File[/etc/afile]/ensure: current_value absent, should be file (noop)
非常感謝!!
/天使
不幸的是,目前沒有辦法克服這一限制。
ensure
屬性不會僅由於缺少所有者而失敗-我相信文件最終將最終歸root擁有。 這就是為什么文件不存在時輸出更令人愉悅的原因。
關於現有文件的行為:單獨考慮每個資源,並且在評估文件時如果該組不存在,則文件資源必須承認失敗。 創建該組(可能)不使用noop
的事實不容易解釋。
至於您的想法,我認為如果有用戶資源,那就在無條件的情況下忽略該問題。 您是否會在Puppet的Jira中提出這一功能請求?
從Puppet 3.3
您可以依賴於由代理提供的$clientnoop
值以及Facter事實。 請注意,調整清單以避免在noop
模式下失敗有兩個后果。
noop
目錄的一部分,因此noop
運行的報告變得不准確。 您可以這樣構建清單:
# this scenario does not actually call for virtual resources at all :-)
group { $at_group:
ensure => "present"
}
user { $at_user:
ensure => present,
gid => "$at_group",
require => Group[$at_group],
}
file { '/etc/afile':
mode => '0440',
content => template('......erb')
# require => User[$at_user] # <- not needed at all, Puppet autorequires the user and group
}
if ! $::clientnoop {
File['/etc/afile'] {
owner => $at_user,
group => $at_group,
}
}
在noop
模式下, owner
和group
屬性將被忽略,具有上述優點和缺點。
考慮到所有事情,我覺得這根本不值得麻煩。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.