【问题标题】:How to upgrade HAProxy on OpsWorks如何在 OpsWorks 上升级 HAProxy
【发布时间】:2016-08-04 16:36:35
【问题描述】:

我们正在使用带有 Chef 11.10 版的 AWS OpsWorks 堆栈。与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]}"

覆盖我们食谱中的文件并在此处天真地更改版本号并没有达到预期的效果。

【问题讨论】:

    标签: haproxy aws-opsworks


    【解决方案1】:

    我们最终像这样覆盖了配方 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 以使用新版本。

    现在一切运行良好。

    【讨论】:

      猜你喜欢
      • 2021-11-28
      • 2015-06-24
      • 2016-09-29
      • 2017-04-30
      • 1970-01-01
      • 2012-07-26
      • 2015-04-07
      • 2021-04-17
      • 2017-03-03
      相关资源
      最近更新 更多