我有一个现有的puppet清单,它安装了一堆php5软件包,只有在安装后才重新启动apache.简化的清单就像是
package { 'apache-php':
name => $modules,
ensure => installed
}
exec {'enable-mod-php':
command => $enable_cmd,
refreshonly => true
}
Package['apache-php'] ~> Exec['enable-mod-php'] ~> Service['apache']
Run Code Online (Sandbox Code Playgroud)
系统升级目录运行开始失败后出现以下错误消息:
错误:无法应用目录:包[apache-php]上的参数名称失败:名称必须是/etc/puppet/modules/apache/manifests/php.pp:22中的字符串而不是数组
我发现我使用了一个未记录的功能/ bug:Puppet 3.4.0名称作为包中的数组.
但是,我很难在升级后找到如何重做我的设置.我怎样才能重写这个清单,以便它适用于更新的木偶版本?
而不是在您的示例中使用包定义的任意标题.(例如.apache-php)并使用name参数,您可以执行以下操作:
$modules = ['foo','bar','baz']
package { $modules:
ensure => present
notify => Exec['enable-mod-php']
}
exec {'enable-mod-php':
command => $enable_cmd,
refreshonly => true,
notify => Service['apache']
}
service { 'apache':
# your apache params
}
Run Code Online (Sandbox Code Playgroud)
我没有查看包提供程序的代码,但可以验证上面的工作原理.你还应该注意到链接箭头都很好,但根据木偶风格指南,metaparameters是首选.
希望这可以帮助.