Puppet 只有类可以设置';舞台;;像XXX这样的普通资源无法更改运行阶段
我有一个清单,其中包依赖于Puppet 只有类可以设置';舞台;;像XXX这样的普通资源无法更改运行阶段,puppet,Puppet,我有一个清单,其中包依赖于apt::source资源。我试图通过设置一个阶段来确保首先运行apt::source: include apt stage { 'first': before => Stage['main'] } apt::source { 'erlang_repo': location => 'http://packages.erlang-solutions.com/ubuntu', repos => 'contrib', key
apt::source
资源。我试图通过设置一个阶段来确保首先运行apt::source
:
include apt
stage { 'first':
before => Stage['main']
}
apt::source { 'erlang_repo':
location => 'http://packages.erlang-solutions.com/ubuntu',
repos => 'contrib',
key => 'A14F4FCA',
stage => first
}
package { 'erlang':
ensure => '1:17.3'
}
但是,我遇到了以下错误:
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Only classes can set 'stage'; normal resources like Apt::Source[erlang_repo] cannot change run stage at /tmp/manifests/default.pp:12 on node vagrant-ubuntu-trusty-64.home
==> default: Wrapped exception:
==> default: Only classes can set 'stage'; normal resources like Apt::Source[erlang_repo] cannot change run stage
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Only classes can set 'stage'; normal resources like Apt::Source[erlang_repo] cannot change run stage at /tmp/manifests/default.pp:12 on node vagrant-ubuntu-trusty-64.home
如果您真的想使用stage,您应该将适当的资源封装在(可能是专用的)类中
然后像这样宣布
class { 'site::apt_sources': stage => first }
请注意,不鼓励使用阶段
如果您不使用虚拟资源,则可以通过此关系来实现所需的效果:
Apt::Source<| |> -> Package<| |>
Apt::Source->Package
我最终决定这样做:
include apt
Apt::Pin <| |> -> Package <| |>
Apt::Source <| |> -> Package <| |>
apt::source { 'erlang_repo':
location => 'http://packages.erlang-solutions.com/ubuntu',
repos => 'contrib',
key => 'A14F4FCA'
}
package { 'erlang':
ensure => '1:17.3',
}
包括apt
Apt::Pin->Package
Apt::Source->Package
apt::source{'erlang_repo':
位置=>'http://packages.erlang-solutions.com/ubuntu',
回购协议=>'contrib',
键=>'A14F4FCA'
}
包{'erlang':
确保=>'1:17.3',
}
include apt
Apt::Pin <| |> -> Package <| |>
Apt::Source <| |> -> Package <| |>
apt::source { 'erlang_repo':
location => 'http://packages.erlang-solutions.com/ubuntu',
repos => 'contrib',
key => 'A14F4FCA'
}
package { 'erlang':
ensure => '1:17.3',
}