我有一个清单,其中包依赖于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 {
apt::source { ... }
}
并像一样申报
class { 'site::apt_sources': stage => first }
请注意,不鼓励使用阶段。
如果你不使用虚拟资源,你可能会通过这种关系达到预期的效果:
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',
}