这是使用puppet更改配置文件的正确方法吗?
我有一个rails应用程序,我想更改./config/environment/production.rb文件,根据我希望服务器执行的操作使用不同的配置 因此,我将从.pp文件进入.rb文件,更改一些字符串,然后重新启动服务。这对我来说真的很糟糕。有更好的方法吗?我被要求提供1 RPM,并通过puppet更改配置,所以这是使用puppet更改配置文件的正确方法吗?,puppet,Puppet,我有一个rails应用程序,我想更改./config/environment/production.rb文件,根据我希望服务器执行的操作使用不同的配置 因此,我将从.pp文件进入.rb文件,更改一些字符串,然后重新启动服务。这对我来说真的很糟糕。有更好的方法吗?我被要求提供1 RPM,并通过puppet更改配置,所以 class Cloud-widget($MServer, $GoogleEarthServer, $CSever) { package { "Cloud-widget":
class Cloud-widget($MServer, $GoogleEarthServer, $CSever) {
package { "Cloud-widget":
ensure => installed
}
service { "Cloud-widget":
ensure => running,
}
<%
file_names = ['./config/environment/production.rb']
file_names.each do |file_name|
puts text.gsub(/.*config.mserver(.*)/, "config.mserver_root = \"#{$Merver}\"")
puts text.gsub(/.*config.google_earth_url(.*)/, "config.google_earth_url( = \"#{$GoogleEarthServer}\"")
puts text.gsub(/.*config.cserver_base_url(.*)/, "config.cserver_base_url = \"#{$CServer}\"")
end
File.open(file_name, "w") {|file| file.puts output_of_gsub}
%>
service { Cloud-widget:
ensure => running,
subscribe => File["./config/environment/production.rb"],
}
}
classcloudwidget($MServer、$GoogleEarthServer、$CSever){
包{“云小部件”:
确保=>已安装
}
服务{“云小部件”:
确保=>正在运行,
}
服务{云小部件:
确保=>正在运行,
订阅=>文件[”/config/environment/production.rb”],
}
}
不,这不是实现您需要的目标的好方法
您可以查看模板并以这种方式生成配置文件。这样,您就可以在配置文件中使用变量。如果您需要从模式创建conf,您应该使用Puppetlabs中的INI文件模块
ini_setting { "sample setting":
path => '/tmp/foo.ini',
section => 'foo',
setting => 'foosetting',
value => 'FOO!',
ensure => present,
}
从以下位置安装此模块:
puppet module install cprice404-inifile
为此使用ERB模板(请参阅)