简体   繁体   English

在Puppet资源链中使用变量

[英]Using variables in a Puppet resource chain

I've got a puppet manifest using an array to define some required packages to be installed by APT. 我有一个使用数组定义一个需要APT安装的必需软件包的up清单。 I've also got some resource chaining occurring to specify dependencies (I don't want to use 'requires' or 'before' because it makes the code difficult to read. The problem is in the chaining line, the array gets expanded and breaks the chaining. I've followed the custom function workaround here Puppet Syntax: how to include an array of objects into an ordering -> chain? which works but seems a bit overkill to define a function. 我还发生了一些资源链接来指定依赖项(我不想使用“ requires”或“ before”,因为这会使代码难以阅读。问题出在链接行中,数组被扩展并中断了我在这里遵循了自定义函数的变通方法:人偶语法:如何将对象数组包含在有序的->链中?可行,但定义一个函数似乎有些过头。

$my_deps = ["autoconf", "automake1.9", "autotools-dev", "binutils"]
package { $my_deps:
    ensure => installed,
}

exec {'c_update_apt':
    command => '/usr/bin/apt-get update',
    path => '/usr/bin/',
    }
Exec['c_update_apt'] -> Package[ $my_deps ]

This errors saying 'Package[autoconf]Package[automake1.9].... not matched'. 出现此错误,提示“ Package [autoconf] Package [automake1.9] ....不匹配”。 Any suggestions most appreciated. 任何建议,不胜感激。

You could use the '<| 您可以使用'<| |>' collection syntax to make sure the Exec block is executed before any packages are installed, instead of just the 4 in your list. |>集合语法,以确保在安装任何软件包之前执行Exec块,而不只是列表中的4个。

Exec['c_update_apt'] -> Package <| |>

See the bottom of the http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources section. 请参阅http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources部分的底部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM