微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux – Satellite 6的puppet无法找到hiera数据源

使用随Foreman 1.6.0.53附带的Satellite 6.

认情况下,Puppetlabs的documentation声明hiera配置应该在$config / hiera.yaml中.

# puppet config print confdir hiera_config
confdir = /etc/puppet
hiera_config = /etc/puppet/hiera.yaml

看看我们的hiera配置:

# cat /etc/puppet/hiera.yaml
---
:backends: yaml
:yaml:
  :datadir: /var/lib/hiera
:hierarchy:
  - users
  - groups
  - global

数据文件存在:

# cat /var/lib/hiera/users.yaml
---
users:
  bfernandez:
    uid: 300
    fullname: Belmin Fernandez

而且,为了测试它,我使用hiera的CLI和木偶申请:

# hiera --conf=/etc/puppet/hiera.yaml --debug -h users
DEBUG: 2015-05-06 14:11:37 -0400: Hiera YAML backend starting
DEBUG: 2015-05-06 14:11:37 -0400: Looking up users in YAML backend
DEBUG: 2015-05-06 14:11:37 -0400: Looking for data source users
DEBUG: 2015-05-06 14:11:37 -0400: Found users in users
DEBUG: 2015-05-06 14:11:37 -0400: Looking for data source groups
DEBUG: 2015-05-06 14:11:37 -0400: Looking for data source global
{"bfernandez"=>{"uid"=>300,"fullname"=>"Belmin Fernandez"}}

# puppet apply -e '$foo = hiera_hash(users) notify { $foo: }'
Notice: Compiled catalog for foosat.example.com in environment production in 0.08 seconds
Notice: {"bfernandez"=>{"uid"=>300,"fullname"=>"Belmin Fernandez"}}
Notice: /Stage[main]/Main/Notify[{"bfernandez"=>{"uid"=>300,"fullname"=>"Belmin Fernandez"}}]/message: defined 'message' as '{"bfernandez"=>{"uid"=>300,"fullname"=>"Belmin Fernandez"}}'
Notice: Finished catalog run in 0.30 seconds

到目前为止,一切看起来都很好但是,当我在模块中引用hiera_hash(‘users’)并将其应用于节点时,我收到此错误

May  6 13:49:04 foo1 puppet-agent[8688]: Could not retrieve catalog from Remote Server: Error 400 on SERVER: Could not find data item users in any Hiera data file and no default supplied at /etc/puppet/modules/accounts/manifests/init.pp:10 on node foo1.example.com

关于我应该看什么的任何想法?感觉就像我在Foreman方面遗漏了一些东西.

更新1:

根据@lsd,尝试使用/etc/hiera.yaml作为配置,而不是通过创建符号链接.使用hiera CLI对其进行测试以确认配置:

# hiera --conf=/etc/hiera.yaml --debug -h users
DEBUG: 2015-05-06 14:31:13 -0400: Hiera YAML backend starting
DEBUG: 2015-05-06 14:31:13 -0400: Looking up users in YAML backend
DEBUG: 2015-05-06 14:31:13 -0400: Looking for data source defaults
DEBUG: 2015-05-06 14:31:13 -0400: Cannot find datafile /var/lib/hiera/defaults.yaml,skipping
DEBUG: 2015-05-06 14:31:13 -0400: Looking for data source users
DEBUG: 2015-05-06 14:31:13 -0400: Found users in users
DEBUG: 2015-05-06 14:31:13 -0400: Looking for data source groups
DEBUG: 2015-05-06 14:31:13 -0400: Looking for data source global
{"bfernandez"=>{"uid"=>300,"fullname"=>"Belmin Fernandez"}}

但仍然在代理上出现错误,因此没有解决问题.

解决方法

在我的通勤上考虑它后,决定检查SELinux,那里是:
[root@foosat hiera]# grep yaml /var/log/audit/audit.log | head -n1
type=AVC msg=audit(1430926955.728:75727): avc:  denied  { getattr } for  pid=17099 comm="ruby" path="/var/lib/hiera/users.yaml" dev="dm-2" ino=25185161 scontext=system_u:system_r:passenger_t:s0 tcontext=unconfined_u:object_r:var_lib_t:s0 tclass=file

将hiera文件上的文件上下文更改为puppet_etc_t(如果有人知道更合适的内容,请发表评论):

[root@foosat hiera]# semanage fcontext -a -s system_u -t puppet_etc_t "/var/lib/hiera(/.*)?"
[root@foosat hiera]# restorecon -R -v .
restorecon reset /var/lib/hiera/users.yaml context unconfined_u:object_r:var_lib_t:s0->unconfined_u:object_r:puppet_etc_t:s0

现在工作.希望这有助于其他人.

原文地址:https://www.jb51.cc/linux/399055.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐