Puppet 包括变量的定义
我正在整理一些傀儡脚本——我有一个需要以非常相似的方式部署的服务列表(大概20个左右)Puppet 包括变量的定义,puppet,Puppet,我正在整理一些傀儡脚本——我有一个需要以非常相似的方式部署的服务列表(大概20个左右) 停止现有服务 从nexus中取出软件包 将其解压缩到目录中 设置配置变量 启动服务 问题是#4。每个服务的配置略有不同。我想使用augeas为每个服务设置配置,并且为每个服务的配置定义,然后在主服务定义中加载该定义似乎是有意义的 因此,我得到了如下结果: definition service ($serviceName) { //stopping, wget, unzip config[do
definition service ($serviceName) {
//stopping, wget, unzip
config[downcase($serviceName)] { "${servicename}_config":
serviceName => $serviceName
}
//start
}
然后,我在配置模块的清单文件夹“foo.pp”中找到了(例如)
这是不工作,由于各种规则,我肯定我打破了,但不知道。有没有一种“标准”的方式来做我想做的事情 您可以尝试下面的代码。您可以将所有这些内容放在一个
define
类型中,其中包含服务名称myserv
的变量。我建议使用templates
来设置配置,而不是augeas
。。。更容易控制
exec { "stop_myserv" :
command => "service stop myserv",
path => "/path/to/command/service",
refreshonly => true,
}
exec { "get_pkg_from_nexus" :
command => "/command/to/do/the/above && unzip to/dirctory",
path => "/path/to/command",
require => Exec["stop_myserv"],
}
file { "set_configuration" :
path => "/etc/somewhere/file",
content => template("modulename/file.erb"),
mode => "999",
group => "jiut",
owner => "muit",
require => Exec["get_pkg_from_nexus"],
}
service { "myserv" :
ensure => running,
subscribe => File["set_configuration"],
}
exec { "stop_myserv" :
command => "service stop myserv",
path => "/path/to/command/service",
refreshonly => true,
}
exec { "get_pkg_from_nexus" :
command => "/command/to/do/the/above && unzip to/dirctory",
path => "/path/to/command",
require => Exec["stop_myserv"],
}
file { "set_configuration" :
path => "/etc/somewhere/file",
content => template("modulename/file.erb"),
mode => "999",
group => "jiut",
owner => "muit",
require => Exec["get_pkg_from_nexus"],
}
service { "myserv" :
ensure => running,
subscribe => File["set_configuration"],
}