木偶:无权调用查找
puppet: Not authorized to call find
我正在 运行ning puppet 2.7.26 因为这是 redhat 软件包提供的。
我正在尝试提供 未 存储在任何人偶模块中的文件。这些文件保存在人偶服务器上的另一个位置,这就是我需要从中提供它们的地方。
我的 /etc/puppet/fileserver.conf
中有这个
[files]
path /var/www/cobbler/pub
allow *
然后我有一个这样的 class 文件:
class etchostfile
(
$hostfile /* declare that this class has one parameter */
)
{
File
{
owner => 'root',
group => 'root',
mode => '0644',
}
file { $hostfile :
ensure => file,
source => "puppet:///files/hosts-${hostfile}.txt",
path => '/root/hosts',
}
}
但是当我的节点调用
class { 'etchostfile' :
hostfile => foo,
}
我收到这个错误
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Error 400
on SERVER: Not authorized to call find on
/file_metadata/files/hosts-foo.txt with {:links=>"manage"} Could not
retrieve file metadata for puppet:///files/hosts-foo.txt: Error 400 on
SERVER: Not authorized to call find on
/file_metadata/files/hosts-foo.txt with {:links=>"manage"} at
/etc/puppet/modules/etchostfile/manifests/init.pp:27
这个post
https://viewsby.wordpress.com/2013/04/05/puppet-error-400-on-server-not-authorized-to-call-find/
表明这就是我需要做的。但我一定是漏掉了什么。
更新
当我 运行 master 处于调试模式时,我没有得到任何错误。
大师如此回应:
info: access[^/catalog/([^/]+)$]: allowing 'method' find
info: access[^/catalog/([^/]+)$]: allowing access
info: access[^/node/([^/]+)$]: allowing 'method' find
info: access[^/node/([^/]+)$]: allowing access
info: access[/certificate_revocation_list/ca]: allowing 'method' find
info: access[/certificate_revocation_list/ca]: allowing * access
info: access[^/report/([^/]+)$]: allowing 'method' save
info: access[^/report/([^/]+)$]: allowing access
info: access[/file]: allowing * access
info: access[/certificate/ca]: adding authentication any
info: access[/certificate/ca]: allowing 'method' find
info: access[/certificate/ca]: allowing * access
info: access[/certificate/]: adding authentication any
info: access[/certificate/]: allowing 'method' find
info: access[/certificate/]: allowing * access
info: access[/certificate_request]: adding authentication any
info: access[/certificate_request]: allowing 'method' find
info: access[/certificate_request]: allowing 'method' save
info: access[/certificate_request]: allowing * access
info: access[/]: adding authentication any
info: Inserting default '/status' (auth true) ACL because none were found in '/etc/puppet/auth.conf'
info: Expiring the node cache of agent.redacted.com
info: Not using expired node for agent.redacted.com from cache; expired at Thu Aug 13 14:18:48 +0000 2015
info: Caching node for agent.redacted.com
debug: importing '/etc/puppet/modules/etchostfile/manifests/init.pp' in environment production
debug: Automatically imported etchostfile from etchostfile into production
debug: File[foo]: Adding default for selrange
debug: File[foo]: Adding default for group
debug: File[foo]: Adding default for seluser
debug: File[foo]: Adding default for selrole
debug: File[foo]: Adding default for owner
debug: File[foo]: Adding default for mode
debug: File[foo]: Adding default for seltype
notice: Compiled catalog for agent.redacted.com in environment production in 0.11 seconds
info: mount[files]: allowing * access
debug: Received report to process from agent.redacted.com
debug: Processing report from agent.redacted.com with processor Puppet::Reports::Store
代理人这样回应:
info: Caching catalog for agent.redacted.com
info: Applying configuration version '1439475588'
notice: /Stage[main]/Etchostfile/File[foo]/ensure: defined content as '{md5}75125a96a68a0ff0d42f91f10dca8336'
notice: Finished catalog run in 0.42 seconds
文件正确 installed/updated。
所以master在debug模式下可以正常运行,但是master在standard(?)模式下会报错。我可以来来回回,随意进入和退出调试模式,每次在调试模式下都有效,而在标准模式下每次都失败。
更新 2
运行 puppetmasterd
从命令行,一切正常。
运行 service puppetmaster start
或 /etc/init.d/puppetmaster start
从命令行,它失败了。所以至少我越来越近了。
/etc/sysconfig/puppetmaster
被完全注释掉了。所以到现在为止,我看不出启动 puppetmasterd 和使用服务脚本有什么区别。
更新 3
我认为这是一个 SELinux 问题。
在 master 上使用 SELinux "enforcing",service puppetmaster restart
,我得到了错误。
我把master上的SELinux改成"Permissive",还是报错
但是现在 SELinux 设置为 Permissive,如果我 service puppetmaster restart
,我的文件将得到正确的服务。
但现在它可以正常工作了,我将 SELinux 设置为 Enforcing,但我得到了一个不同的错误:
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Could not
retrieve information from environment production source(s)
puppet:///files/hosts-foo.txt at
/etc/puppet/modules/etchostfile/manifests/init.pp:27
然后我做了一个service puppetmaster restart
然后我又回到了原来的错误。
所以情况的变化取决于
- 我是如何启动服务的(
puppetmasterd
或 service
)
- 我启动服务时 SELinux 设置的是什么
- 当代理 运行s.
时 SELinux 设置为什么
越近越迷糊
更新 4
我想我找到了。在我开始研究 SELinux 后,我发现了我需要进行的策略更改(允许 ruby/puppet 访问 cobbler 文件),现在它似乎可以正常工作...
原来是 SELinux 问题。我最终发现了这个错误信息
SELinux is preventing /usr/bin/ruby from read access
on the file /var/www/cobbler/pub/hosts-foo.txt .
这让我想到了 audit2allow 规则,我需要应用它来允许 puppet 访问我的 cobbler 文件。
我在 ubuntu 20.
上的 puppet 服务器上遇到了这个错误
错误:/Stage[main]/Dvod_tocr/File[/install/wine-data.tar.gz]:无法评估:无法检索 puppet:///extra_files/wine-data 的文件元数据.tar.gz:服务器上的错误 500:服务器错误:未授权使用 {:rest=>"extra_files/wine-data 在 /file_metadata/extra_files/wine-data.tar.gz 上调用查找.tar.gz", :links=>"管理", :checksum_type=>"sha256", :source_permissions=>"忽略"}
我的 fileserver.conf 文件位于错误的位置。此人偶版本和 ubuntu 20 上的正确位置是 /etc/puppetlabs/puppet/fileserver.conf
我正在 运行ning puppet 2.7.26 因为这是 redhat 软件包提供的。
我正在尝试提供 未 存储在任何人偶模块中的文件。这些文件保存在人偶服务器上的另一个位置,这就是我需要从中提供它们的地方。
我的 /etc/puppet/fileserver.conf
中有这个[files]
path /var/www/cobbler/pub
allow *
然后我有一个这样的 class 文件:
class etchostfile
(
$hostfile /* declare that this class has one parameter */
)
{
File
{
owner => 'root',
group => 'root',
mode => '0644',
}
file { $hostfile :
ensure => file,
source => "puppet:///files/hosts-${hostfile}.txt",
path => '/root/hosts',
}
}
但是当我的节点调用
class { 'etchostfile' :
hostfile => foo,
}
我收到这个错误
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/hosts-foo.txt with {:links=>"manage"} Could not retrieve file metadata for puppet:///files/hosts-foo.txt: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/hosts-foo.txt with {:links=>"manage"} at /etc/puppet/modules/etchostfile/manifests/init.pp:27
这个post https://viewsby.wordpress.com/2013/04/05/puppet-error-400-on-server-not-authorized-to-call-find/ 表明这就是我需要做的。但我一定是漏掉了什么。
更新
当我 运行 master 处于调试模式时,我没有得到任何错误。
大师如此回应:
info: access[^/catalog/([^/]+)$]: allowing 'method' find
info: access[^/catalog/([^/]+)$]: allowing access
info: access[^/node/([^/]+)$]: allowing 'method' find
info: access[^/node/([^/]+)$]: allowing access
info: access[/certificate_revocation_list/ca]: allowing 'method' find
info: access[/certificate_revocation_list/ca]: allowing * access
info: access[^/report/([^/]+)$]: allowing 'method' save
info: access[^/report/([^/]+)$]: allowing access
info: access[/file]: allowing * access
info: access[/certificate/ca]: adding authentication any
info: access[/certificate/ca]: allowing 'method' find
info: access[/certificate/ca]: allowing * access
info: access[/certificate/]: adding authentication any
info: access[/certificate/]: allowing 'method' find
info: access[/certificate/]: allowing * access
info: access[/certificate_request]: adding authentication any
info: access[/certificate_request]: allowing 'method' find
info: access[/certificate_request]: allowing 'method' save
info: access[/certificate_request]: allowing * access
info: access[/]: adding authentication any
info: Inserting default '/status' (auth true) ACL because none were found in '/etc/puppet/auth.conf'
info: Expiring the node cache of agent.redacted.com
info: Not using expired node for agent.redacted.com from cache; expired at Thu Aug 13 14:18:48 +0000 2015
info: Caching node for agent.redacted.com
debug: importing '/etc/puppet/modules/etchostfile/manifests/init.pp' in environment production
debug: Automatically imported etchostfile from etchostfile into production
debug: File[foo]: Adding default for selrange
debug: File[foo]: Adding default for group
debug: File[foo]: Adding default for seluser
debug: File[foo]: Adding default for selrole
debug: File[foo]: Adding default for owner
debug: File[foo]: Adding default for mode
debug: File[foo]: Adding default for seltype
notice: Compiled catalog for agent.redacted.com in environment production in 0.11 seconds
info: mount[files]: allowing * access
debug: Received report to process from agent.redacted.com
debug: Processing report from agent.redacted.com with processor Puppet::Reports::Store
代理人这样回应:
info: Caching catalog for agent.redacted.com
info: Applying configuration version '1439475588'
notice: /Stage[main]/Etchostfile/File[foo]/ensure: defined content as '{md5}75125a96a68a0ff0d42f91f10dca8336'
notice: Finished catalog run in 0.42 seconds
文件正确 installed/updated。
所以master在debug模式下可以正常运行,但是master在standard(?)模式下会报错。我可以来来回回,随意进入和退出调试模式,每次在调试模式下都有效,而在标准模式下每次都失败。
更新 2
运行 puppetmasterd
从命令行,一切正常。
运行 service puppetmaster start
或 /etc/init.d/puppetmaster start
从命令行,它失败了。所以至少我越来越近了。
/etc/sysconfig/puppetmaster
被完全注释掉了。所以到现在为止,我看不出启动 puppetmasterd 和使用服务脚本有什么区别。
更新 3
我认为这是一个 SELinux 问题。
在 master 上使用 SELinux "enforcing",service puppetmaster restart
,我得到了错误。
我把master上的SELinux改成"Permissive",还是报错
但是现在 SELinux 设置为 Permissive,如果我 service puppetmaster restart
,我的文件将得到正确的服务。
但现在它可以正常工作了,我将 SELinux 设置为 Enforcing,但我得到了一个不同的错误:
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Could not
retrieve information from environment production source(s)
puppet:///files/hosts-foo.txt at
/etc/puppet/modules/etchostfile/manifests/init.pp:27
然后我做了一个service puppetmaster restart
然后我又回到了原来的错误。
所以情况的变化取决于
- 我是如何启动服务的(
puppetmasterd
或service
) - 我启动服务时 SELinux 设置的是什么
- 当代理 运行s. 时 SELinux 设置为什么
越近越迷糊
更新 4
我想我找到了。在我开始研究 SELinux 后,我发现了我需要进行的策略更改(允许 ruby/puppet 访问 cobbler 文件),现在它似乎可以正常工作...
原来是 SELinux 问题。我最终发现了这个错误信息
SELinux is preventing /usr/bin/ruby from read access
on the file /var/www/cobbler/pub/hosts-foo.txt .
这让我想到了 audit2allow 规则,我需要应用它来允许 puppet 访问我的 cobbler 文件。
我在 ubuntu 20.
上的 puppet 服务器上遇到了这个错误错误:/Stage[main]/Dvod_tocr/File[/install/wine-data.tar.gz]:无法评估:无法检索 puppet:///extra_files/wine-data 的文件元数据.tar.gz:服务器上的错误 500:服务器错误:未授权使用 {:rest=>"extra_files/wine-data 在 /file_metadata/extra_files/wine-data.tar.gz 上调用查找.tar.gz", :links=>"管理", :checksum_type=>"sha256", :source_permissions=>"忽略"}
我的 fileserver.conf 文件位于错误的位置。此人偶版本和 ubuntu 20 上的正确位置是 /etc/puppetlabs/puppet/fileserver.conf