首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行“傀儡代理--noop”时缺少资源

运行“傀儡代理--noop”时缺少资源
EN

Stack Overflow用户
提问于 2014-06-19 17:48:13
回答 1查看 1.4K关注 0票数 0

我可能误解了"puppet agent --noop“的工作方式:

在类的定义中,我设置了一个文件的存在,并设置了它的用户和组所有权,这就是我在运行"puppet agent --noop“时所拥有的:

  • 如果文件不存在,"puppet agent --noop“可以正常工作
  • 如果文件存在但用户或组不存在,那么"puppet agent --noop“就会失败,抱怨缺少的用户或组。
  • 如果我只运行"puppet agent“(没有"--noop"),它可以正常工作:不管用户、组或文件是否存在):它创建组、用户和/或文件。

"--noop“第一个问题:我认为运行不会验证目录是否要求创建缺少的资源。不是吗?

"--noop"?第二个问题:在启动时,是否有任何方法来模仿以避免资源丢失的问题?

让我们粘贴一些代码来显示它:

代码语言:javascript
复制
   # 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]
  } 

产出:

代码语言:javascript
复制
# 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“就像一种魅力:

代码语言:javascript
复制
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)

非常感谢!!

/安琪尔

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-19 22:09:53

不幸的是,目前没有办法克服这一限制。

ensure属性不会因为缺少所有者而失败--我相信文件最终会被根用户拥有。这就是为什么当文件不存在时输出更令人愉快的原因。

至于现有文件的行为:每个资源都是单独考虑的,如果在计算文件时组不存在,则文件资源必须承认失败。在没有noop的情况下创建组(很可能)这一事实是不容易解释的。

至于你的想法,忽略这个问题在noop条件下,如果有一个用户资源-这是有价值的,我相信。你会在木偶的Jira上把它作为特性请求提出来吗?

更新

对于木偶3.3,您可以使用由代理提供的$clientnoop值以及Facter事实。请注意,定制清单以避免noop模式下的故障有两个后果。

  1. 显式本身变得更不容易维护和可理解。
  2. 来自noop运行的报告变得不准确,因为“不安全”属性值不是noop目录的一部分。

您可以这样构建清单:

代码语言:javascript
复制
# 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,
  }
}

ownergroup属性在noop模式下被忽略,其优点和缺点如上文所述。

从各方面来看,我觉得这根本不值得麻烦。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24313147

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档