我们正在使用AWS OpsWorks堆栈与Chef Version 11.10。使用default HAProxy Layer。我们希望将HAProxy升级到1.6-stable的最新版本(从默认的1.4-stable)。 我们的Ubuntu版本似乎有dedicated PPA。
但是我们在哪里可以让OpsWorks使用这个PPA来安装HAProxy?
在default cookbook中有default attributes file,其中包含以下行:
default[:haproxy][:version] = '1.4.22'
default[:haproxy][:patchlevel] = '1'
default[:haproxy][:rpm] = "haproxy-#{node[:haproxy][:version]}-#{node[:haproxy][:patchlevel]}.#{rhel_arch}.rpm"
default[:haproxy][:rpm_url] = "#{node[:opsworks_commons][:assets_url]}/packages/#{node[:platform]}/#{node[:platform_version]}/#{node[:haproxy][:rpm]}"
在我们的食谱中覆盖文件并在这里天真地更改版本号没有达到预期的效果。
答案 0 :(得分:0)
我们最终覆盖了haproxy/recipes/default.rb
这样的食谱:
#Install software-properties-common if not installed
package 'software-properties-common' do
action :install
end
#Add PPA for haproxy 1.6 and update repo
execute "add-ppa-update" do
command "add-apt-repository ppa:vbernat/haproxy-1.6 && apt-get update -y"
action :run
end
package "haproxy" do
retries 3
retry_delay 5
version '1.6.4-3ppa1~trusty'
action :install
end
if platform?('debian','ubuntu')
template '/etc/default/haproxy' do
source 'haproxy-default.erb'
owner 'root'
group 'root'
mode 0644
end
end
include_recipe 'haproxy::service'
template '/etc/haproxy/haproxy.cfg' do
source 'haproxy.cfg.erb'
owner 'root'
group 'root'
mode 0644
notifies :restart, "service[haproxy]"
end
template "/etc/haproxy/server.pem" do
source "server.pem.erb"
owner 'root'
group 'root'
mode 0600
notifies :restart, "service[haproxy]"
end
service 'haproxy' do
action [:enable, :start]
end
此外,我们需要更新haproxy.conf以使用新版本。
现在一切都很美好。