我已经完成了本地 Puppet 安装:
# puppet module install puppetlabs/apt
Preparing to install into /etc/puppet/modules ...
Downloading from http://forge.puppetlabs.com ...
Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ puppetlabs-apt (v1.1.0)
└── puppetlabs-stdlib (v3.2.0)
我还有以下nodes.pp
要申请的:
node default {
include stdlib
class {'apt':
always_apt_update => true,
disable_keys => true,
stage => 'setup'
}
->
apt::source { "cassandra":
location => "http://debian.datastax.com/community",
release => "stable",
repos => "main",
key => "B999A372",
key_source => "http://debian.datastax.com/debian/repo_key",
include_src => false
}
}
当我尝试应用它时,我得到:
# puppet apply nodes.pp
err: Could not apply complete catalog: Found 1 dependency cycle:
(Anchor[apt::key B999A372 present] => Apt::Key[Add key: B999A372 from Apt::Source cassandra] => File[cassandra.list] => Exec[apt_update] => Class[Apt::Update] => Stage[setup] => Stage[main] => Class[Main] => Node[default] => Apt::Source[cassandra] => File[cassandra.list])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
notice: Finished catalog run in 0.12 seconds
问题似乎出在stage => 'setup'
参数上,但我想了解发生了什么以及我能做些什么来解决这个问题(我继承了一个大型 puppet 代码库 - 以上只是一个概念证明 - 它使用stage
我还不想删除它,因为我不太了解 Puppet 的内部工作原理)。
更新#1
尝试将apt::source
步骤移至setup
舞台,如下所示:
class cassandra {
apt::source { "cassandra":
location => "http://debian.datastax.com/community",
release => "stable",
repos => "main",
key => "B999A372",
key_source => "http://debian.datastax.com/debian/repo_key",
include_src => false
}
}
node default {
include stdlib
class {'apt':
always_apt_update => true,
disable_keys => true,
stage => setup
}
->
class {'cassandra': stage => setup}
}
但是,这并不能解决问题,只会产生另一个依赖循环。
err: Could not apply complete catalog: Found 1 dependency cycle:
(Anchor[apt::key B999A372 present] => Apt::Key[Add key: B999A372 from Apt::Source cassandra] => File[cassandra.list] => Exec[apt_update] => Class[Apt::Update] => Anchor[apt::update] => Class[Apt] => Class[Cassandra] => Apt::Source[cassandra] => File[cassandra.list])
完整的调试输出在这里。依赖图是
所以在我看来,试图以“自然”的方式(通过->
操作员)强制执行操作顺序会导致这种奇怪的依赖循环。