2
木偶初学者所以也许我做错了什么......“无效的资源类型”想在这里用木偶的定义的资源类型
我有一个包含以下内容的清单定义
define amqconf (
$activemq_home = '/opt/apache-activemq',
$group = 'activemq',
$mode = 0644,
$owner = 'activemq',
$broker_name = $title,
$broker_port = 61616,
) {
file { $title:
ensure => present,
path => "${activemq_home}/${broker_name}/conf/activemq.xml",
content => template('profiles/activemq.xml.erb'),
}
}
和然后尝试使用定义
$broker_conf = hiera('profiles::activemq::broker::conf')
create_resources(amqconf, $broker_conf)
,但是当我尝试使用这个类,我得到以下错误
Info: Using configured environment 'testing'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type amqconf at /etc/puppetlabs/code/environments/testing/modules/profiles/manifests/activemq.pp:73:5 on node cust-stage.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
为了能够使用此定义,我需要做些什么?
编辑:添加完整的清单
class profiles::activemq {
include archive
include profiles::java_7_oracle
$activemq_version = '5.13.3'
define amqconf (
$activemq_home = '/opt/apache-activemq',
$group = 'activemq',
$mode = 0644,
$owner = 'activemq',
$broker_name = $title,
$broker_port = 61616,
) {
file { $title:
ensure => present,
path => "${activemq_home}/${broker_name}/conf/activemq.xml",
content => template('profiles/activemq.xml.erb'),
}
}
group { 'activemq':
ensure => present,
}
user { 'activemq':
groups => 'activemq',
comment => 'Service user for running the ActiveMQ service',
home => "/opt/apache-activemq-$activemq_version",
ensure => present,
shell => '/bin/bash',
}
file { "/opt/apache-activemq-$activemq_version" :
ensure => directory,
owner => 'activemq',
group => 'activemq',
mode => '0755',
}
archive { "/tmp/apache-activemq-$activemq_version-bin.tar.gz" :
ensure => present,
source => 'http://archive.apache.org/dist/activemq/5.13.3/apache-activemq-5.13.3-bin.tar.gz',
checksum => 'c19e2717f5c844a2f271fcd39eb024d04ebcfa5d',
checksum_type => 'sha1',
extract => true,
extract_path => '/opt',
creates => "/opt/apache-activemq-$activemq_version/bin",
cleanup => true,
user => 'activemq',
group => 'activemq',
}
# Create the brokers defined in hiera.
$brokers = hiera('profiles::activemq::brokers')
$broker_defaults = {
cwd => "/opt/apache-activemq-${activemq_version}",
group => 'activemq',
user => 'activemq',
}
create_resources(exec , $brokers, $broker_defaults)
$broker_conf = hiera('profiles::activemq::broker::conf')
create_resources(amqconf, $broker_conf)
}
这个定义是在目录编译期间自动加载的吗?如果define位于'/ etc/puppetlabs/code/environments/testing/modules/amqconf/manifests/init.pp'文件中,那么答案可能是肯定的。否则,这需要进一步审查以调试您的情况。仅供参考:https://docs.puppet.com/puppet/latest/reference/lang_defined_types.html –
我已阅读引用的文档 - 位置部分下,它声明该定义可以位于类定义内(尽管它不是推荐的)。这是我的情况,定义和使用定义的资源类型都在同一个清单/类中。 – sceaj
你能告诉我们你的全班吗? – ptierno