puppet - "Invalid Resource Type"尝试使用 Puppet 的定义资源类型

标签 puppet

这里是 puppet 初学者,所以也许我做错了什么......

我有一个包含以下定义的 list

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

我需要做什么才能使用这个定义?

编辑:添加完整 list

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 )

}

最佳答案

我从来无法让定义在类中工作,但是通过将其放在自己的文件中,我能够让定义工作。

amqconf.pp

define profiles::amqconf (
    $activemq_home = '/opt/apache-activemq',
    $group         = 'activemq',
    $mode          = 0644,
    $owner         = 'activemq',
    $broker_name   = $title,
    $broker_port   = 61616,
    $broker_network_uri = 'NONE',
) {
    file { $title:
        ensure  => present,
        path    => "${activemq_home}/${broker_name}/conf/activemq.xml",
        content => template('profiles/activemq.xml.erb'),
    }
}

然后在activemq.pp中声明它

profiles::amqconf { 'amq-1-conf' :
    broker_name   => 'amq-1',
    activemq_home => "/opt/apache-activemq-${activemq_version}",
}

定义按预期工作。

关于puppet - "Invalid Resource Type"尝试使用 Puppet 的定义资源类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37889190/

相关文章:

linux - 运行 puppet 证书列表不显示我正在寻找的证书

git - 使用 awk sed 解析更新 puppet 文件

Windows puppet exec 命令文件路径

puppet - Puppet中的通知功能和通知资源到底有什么区别?

ubuntu - 将 PuPHPet 中的配置用于生产服务器

xml - 如何使用 augeas 更改 XML 中哪个位置发生变化的属性值?

python - 无法使用 Puppet 设置 Python 3 的安装目录

windows - 使用 Puppet 更改 TrustedInstaller 拥有的注册表项的权限

ubuntu - 为什么 puppet 无法启动 Dropbox 守护进程?

scala - 部署自动化