这里绝对的木偶初学者。我的人偶清单出现了有趣的行为,我很想知道我做错了什么。例如,假设我正在使用以下有序类配置实例:
class { 'update_system': } ->
class { 'facter': } ->
class { 'user_sshkey': user => 'ubuntu', type => 'rsa', } ->
class { 'tmux': user => 'ubuntu', } ->
class { 'vim': user => 'ubuntu', } ->
class { 'bashrc': user => 'ubuntu' } ->
notify {"Configuring DB role":} ->
class { 'postgresql': }
Run Code Online (Sandbox Code Playgroud)
当我使用 --debug 开关运行清单时,通过查看通知语句,我可以看到类按以下顺序执行:
1. update_system starts
2. a cron type inside of postgresql class (the very **last** class in that ordered list above) is executed
3. postgres::install starts
5. facter starts installing
6. postgres::configure and postgres::service start
7. the vim class is executed
8. "Configuring DB role" notification is made. All the way at the end here.
etc
Run Code Online (Sandbox Code Playgroud)
基本上事情到处都是,订单似乎并没有以任何方式遵循箭头操作符。
我猜我在这里遗漏了一些会强制类一次执行一个的东西。可能是我在这里缺少某种锚点模式吗?无效收容?
编辑:据我所知,问题的一部分是我在 postgres 模块中使用了嵌套类:
class postgres {
class{'postgres::install': } ->
class{'postgres::config': } ~>
class{'postgres::service': } ->
}
Run Code Online (Sandbox Code Playgroud)
我的理解是,如果没有锚点 hack,这将无法正常工作,根据错误 8040
我得到这个正确吗?
您正在使用类 ( postgresql
) 和在其中直接声明的资源创建依赖项。这不会与从那里 ( postgresql::install
)包含的类创建依赖关系。因此,postgresql::install
您创建的依赖结构根本不涉及来自的资源。
您需要的是让资源仅依赖于它们真正需要的内容,而不是试图强制执行高级命令 - 如果您需要在特定资源运行之前完成系统更新,那么只需从那里要求它。