Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rightscale-cookbooks/rs-haproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
rshade committed May 4, 2017
2 parents 9b3fc0d + edf105f commit 62c5889
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 64 deletions.
7 changes: 7 additions & 0 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ platforms:
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install apt-transport-https lsb-release procps net-tools -y
attributes:
poise-service:
provider: 'upstart'

- name: ubuntu-16.04
driver:
Expand Down Expand Up @@ -112,6 +115,8 @@ suites:
stats_password: 'statspass'
health_check_uri: '/'
session_stickiness: true
rightscale:
monitoring_collector_http: 'tss-4.rightscale.com'

# Tests the HAProxy frontend and backend configuration and SSL by setting up fake application servers
# and attaching them to HAProxy. The tests verify that the application servers are attached to the
Expand All @@ -127,6 +132,8 @@ suites:
cloud:
provider: 'vagrant'
public_ips: ['192.0.2.2']
rightscale:
monitoring_collector_http: 'tss-4.rightscale.com'
rs-haproxy:
pools: ['test_example', 'appserver', 'example']
ssl_incoming_port: 445
Expand Down
28 changes: 4 additions & 24 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ provisioner:
name: chef_zero
always_update_cookbooks: true
platforms:
- name: ubuntu-14.04
- name: ubuntu-16.04
run_list:
- recipe[apt]
driver_config:
box: bento/ubuntu-14.04
- name: ubuntu-12.04
box: bento/ubuntu-16.04
- name: ubuntu-14.04
run_list:
- recipe[apt]
driver_config:
box: bento/ubuntu-12.04
box: bento/ubuntu-14.04
- name: centos-6.8
run_list: ['recipe[fake::create_secrets]','recipe[yum-epel]']
driver_config:
Expand All @@ -32,26 +32,6 @@ platforms:
run_list: ['recipe[yum-epel]', 'recipe[fake::mysql_repo]']
driver_config:
box: bento/centos-7.2
#- name: rhel-6.5
# run_list: ['recipe[yum-epel]', 'recipe[rhsm]', 'recipe[fake::wget_cacert]']
# attributes:
# rhsm:
# username: <%= ENV['RHSM_USERNAME'] %>
# password: <%= ENV['RHSM_PASSWORD'] %>
# additional_repos: ['rhel-6-server-optional-rpms']
# driver_config:
# box: local-rhel-6.5
# box_url: file://<%= File.expand_path('~') %>/opscode_rhel-6.5_chef-provisionerless.box
#- name: rhel-7.0
# run_list: ['recipe[yum-epel]', 'recipe[rhsm]', 'recipe[fake::mysql_repo]', 'recipe[fake::wget_cacert]']
# attributes:
# rhsm:
# username: <%= ENV['RHSM_USERNAME'] %>
# password: <%= ENV['RHSM_PASSWORD'] %>
# additional_repos: ['rhel-7-server-optional-rpms']
# driver_config:
# box: local-rhel-7.0
# box_url: file://<%= File.expand_path('~') %>/opscode_rhel-7.0_chef-provisionerless.box

# Tests the basic HAProxy configuration, load balancer related machine tags set on the server, and
# the HAProxy collectd monitoring configuration. The HAProxy configuration is verified by ensuring
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ env:
matrix:
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-ubuntu-1404
- INSTANCE=default-ubuntu-1204
- INSTANCE=default-centos-6
- INSTANCE=default-centos-7
- INSTANCE=backend-ubuntu-1404
- INSTANCE=backend-ubuntu-1204
- INSTANCE=backend-centos-6
- INSTANCE=backend-centos-7

Expand Down
62 changes: 36 additions & 26 deletions Berksfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ DEPENDENCIES
revision: a8890d13daad3fab3b69b507540323ced0cc9398
rs-base
git: https://github.com/rightscale-cookbooks/rs-base.git
revision: 5d66d7b46d49d7c2a9eda6dafd12585c8abdfd0c
revision: 088e44a646cf9db6e123534ef052775e45f25846
rs-haproxy
path: .
metadata: true
rsc_remote_recipe
git: https://github.com/rightscale-services-cookbooks/rsc_remote_recipe.git
revision: c2333f14505d3317de328775e98f550e054e3ea7
revision: 1b97227b64c063a8c132133e9e38ab8f5065c670

GRAPH
apache2 (3.2.2)
Expand All @@ -30,7 +30,7 @@ GRAPH
mingw (>= 1.1)
seven_zip (>= 0.0.0)
chef-sugar (3.4.0)
collectd (2.2.2)
collectd (2.2.4)
poise (~> 2.2)
poise-service (~> 1.0)
collectd_plugins (2.1.3)
Expand All @@ -56,39 +56,43 @@ GRAPH
build-essential (>= 0.0.0)
dmg (>= 0.0.0)
yum-epel (>= 0.0.0)
haproxy (3.0.1)
haproxy (3.0.4)
build-essential (>= 0.0.0)
cpu (>= 0.2.0)
poise-service (>= 0.0.0)
hostsfile (2.4.5)
iis (5.0.7)
windows (>= 1.34.6)
iis (5.1.0)
windows (>= 2.0)
inifile_chef_gem (0.1.0)
build-essential (>= 0.0.0)
limits (1.0.0)
lvm (4.0.5)
machine_tag (2.0.4)
apt (>= 0.0.0)
build-essential (>= 0.0.0)
chef-sugar (>= 0.0.0)
mariadb (1.0.1)
mariadb (1.3.0)
apt (>= 0.0.0)
yum (>= 0.0.0)
yum-epel (>= 0.0.0)
yum-scl (>= 0.0.0)
marker (2.0.0)
mingw (2.0.0)
seven_zip (>= 0.0.0)
mysql (8.2.0)
mysql2_chef_gem (1.1.0)
build-essential (>= 0.0.0)
mysql (8.3.0)
mysql2_chef_gem (2.0.1)
build-essential (>= 2.4.0)
mariadb (>= 0.0.0)
mysql (>= 6.0)
mysql (>= 8.2.0)
now (1.0.0)
ntp (3.3.1)
ohai (5.0.0)
openssl (7.0.0)
php (2.2.1)
ohai (5.0.2)
openssl (7.0.1)
php (3.0.0)
build-essential (>= 0.0.0)
iis (>= 0.0.0)
mysql (>= 6.0.0)
windows (>= 0.0.0)
xml (>= 0.0.0)
yum-epel (>= 0.0.0)
poise (2.7.2)
Expand Down Expand Up @@ -116,41 +120,47 @@ GRAPH
rs-base (>= 0.0.0)
rsc_remote_recipe (>= 0.0.0)
yum-mysql-community (>= 0.0.0)
rs-base (2.0.1)
rs-base (2.1.1)
apt (>= 0.0.0)
collectd (~> 2.2.2)
collectd_plugins (~> 2.1.3)
ephemeral_lvm (~> 3.0)
collectd (>= 2.2.0)
collectd_plugins (>= 2.1.0)
ephemeral_lvm (>= 3.0.0)
machine_tag (~> 2.0)
marker (>= 0.0.0)
ntp (>= 0.0.0)
rightscale_tag (~> 2.0)
rsyslog (>= 0.0.0)
swap (>= 0.0.0)
selinux_policy (>= 0.0.0)
swap (>= 2.0.0)
sysctl (>= 0.0.0)
yum-epel (>= 0.0.0)
rs-haproxy (2.1.1)
collectd (= 2.2.2)
haproxy (~> 3.0)
rs-haproxy (2.1.2)
collectd (>= 0.0.0)
haproxy (= 3.0.4)
limits (>= 0.0.0)
machine_tag (~> 2.0.4)
rightscale_tag (>= 0.0.0)
rs-base (>= 0.0.0)
rsc_remote_recipe (>= 0.0.0)
sysctl (>= 0.0.0)
rsc_remote_recipe (10.1.1)
rsc_remote_recipe (10.2.0)
build-essential (>= 0.0.0)
rsyslog (6.0.1)
selinux_policy (2.0.0)
compat_resource (>= 12.16.3)
seven_zip (2.0.2)
windows (>= 1.2.2)
swap (2.0.0)
sysctl (0.8.1)
ohai (>= 4.0)
windows (2.1.1)
windows (3.0.3)
ohai (>= 4.0.0)
xml (3.1.1)
build-essential (>= 0.0.0)
yum (5.0.0)
yum-epel (2.1.1)
compat_resource (>= 12.16.3)
yum-mysql-community (2.0.3)
yum-mysql-community (2.1.0)
compat_resource (>= 12.16.3)
yum-scl (0.2.0)
inifile_chef_gem (>= 0.0.0)
yum (>= 0.0.0)
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ rs-haproxy Cookbook CHANGELOG

This file is used to list changes made in each version of the rs-haproxy cookbook.

v2.1.2
------
- as we compile with multiproc enabled removing haproxy tuning for affinity
- configured frontend and backend to support multiple items, especially when wrapped.
- removed ubuntu 12.04 from test-kitchen as its EOL

v2.1.1
------
- updating attributes/default.rb, and .kitchen.yml to match default.rb
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ desc 'Sets up knife, and vendors cookbooks'
task :setup_test_environment do
File.open('knife.rb', 'w+') do |file|
file.write <<-EOF
log_level :debug
log_level :info
log_location STDOUT
cookbook_path ['.', 'berks-cookbooks/' ]
EOF
Expand Down
9 changes: 6 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
license 'Apache 2.0'
description 'Application cookbook to set up HAProxy on a RightScale environment'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.1.1'
version '2.1.2'
issues_url 'https://github.com/rightscale-cookbooks/rs-haproxy/issues'
source_url 'https://github.com/rightscale-cookbooks/rs-haproxy'
chef_version '>= 12.0' if respond_to?(:chef_version)

depends 'haproxy', '~> 3.0'
depends 'collectd', '= 2.2.2'
supports 'ubuntu'
supports 'centos'

depends 'haproxy', '= 3.0.4'
depends 'collectd'
depends 'rightscale_tag'
depends 'machine_tag', '~> 2.0.4'
depends 'rs-base'
Expand Down
4 changes: 2 additions & 2 deletions recipes/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ class Chef::Recipe
end

# Initialize frontend section which will be generated in the haproxy.cfg
node.default['haproxy']['config']['frontend'] = {}
node.default['haproxy']['config']['frontend'] ||= {}
node.default['haproxy']['config']['frontend']['all_requests'] ||= {}
node.default['haproxy']['config']['frontend']['all_requests']['default_backend'] = node['rs-haproxy']['pools'].last
node.default['haproxy']['config']['frontend']['all_requests']['bind'] = "#{node['haproxy']['incoming_address']}:#{node['haproxy']['incoming_port']}"
node.default['haproxy']['config']['frontend']['all_requests']['maxconn'] = node['rs-haproxy']['maxconn']

# Initialize backend section which will be generated in the haproxy.cfg
node.default['haproxy']['config']['backend'] = {}
node.default['haproxy']['config']['backend'] ||= {}

# Iterate through each application server pool served by the HAProxy server and set up the
# ACLs in the frontend section and the corresponding backed sections
Expand Down
2 changes: 1 addition & 1 deletion recipes/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
cron 'rs-haproxy::frontend' do
minute "*/#{interval}"
hour '*'
command "rsc rl10 run_right_script /rll/run/right_script 'right_script=Haproxy Frontend - chef'"
command "/usr/local/bin/rsc rl10 run_right_script /rll/run/right_script 'right_script=Haproxy Frontend - chef'"
action schedule_enable ? :create : :delete
end
1 change: 0 additions & 1 deletion recipes/tuning.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
include_recipe 'haproxy::tuning'
include_recipe 'sysctl::default'

set_limit '*' do
Expand Down
1 change: 1 addition & 0 deletions spec/collectd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
node.set['rs-base']['monitoring_type'] = 'collectd'
node.set['rightscale']['instance_uuid'] = 'abcd1234'
node.set['rs-base']['collectd_server'] = 'tss-4.rightscale.com'
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
end.converge(described_recipe)
end
file_content = <<-EOF
Expand Down
2 changes: 2 additions & 0 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
context 'main haproxy without ssl' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |node|
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
end.converge(described_recipe)
end

Expand Down Expand Up @@ -39,6 +40,7 @@
context 'ssl is enabled' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |node|
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
node.set['rs-haproxy']['ssl_cert'] = 'certdata'
end.converge(described_recipe)
end
Expand Down
1 change: 1 addition & 0 deletions spec/frontend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
let(:chef_run) do
ChefSpec::SoloRunner.new do |node|
node.set['cloud']['provider'] = 'vagrant'
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
end.converge(described_recipe)
end

Expand Down
1 change: 1 addition & 0 deletions spec/hatop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
describe 'rs-haproxy::hatop' do
let(:chef_run) do
ChefSpec::SoloRunner.new(file_cache_path: Chef::Config[:file_cache_path]) do |node|
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
end.converge(described_recipe)
end

Expand Down
6 changes: 4 additions & 2 deletions spec/schedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
ChefSpec::SoloRunner.new do |node|
node.set['rs-haproxy']['schedule']['enable'] = true
node.set['rs-haproxy']['schedule']['interval'] = '15'
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
end.converge(described_recipe)
end

it 'creates a crontab entry' do
expect(chef_run).to create_cron('rs-haproxy::frontend').with(
minute: '*/15',
hour: '*',
command: "rsc rl10 run_right_script /rll/run/right_script 'right_script=Haproxy Frontend - chef'"
command: "/usr/local/bin/rsc rl10 run_right_script /rll/run/right_script 'right_script=Haproxy Frontend - chef'"
)
end
end
Expand All @@ -24,14 +25,15 @@
ChefSpec::SoloRunner.new do |node|
node.set['rs-haproxy']['schedule']['enable'] = false
node.set['rs-haproxy']['schedule']['interval'] = '15'
node.set['rightscale']['monitoring_collector_http'] = 'tss4.rightscale.com'
end.converge(described_recipe)
end

it 'deletes the crontab entry' do
expect(chef_run).to delete_cron('rs-haproxy::frontend').with(
minute: '*/15',
hour: '*',
command: "rsc rl10 run_right_script /rll/run/right_script 'right_script=Haproxy Frontend - chef'"
command: "/usr/local/bin/rsc rl10 run_right_script /rll/run/right_script 'right_script=Haproxy Frontend - chef'"
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/backend/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'csv'
require 'json'
require 'rubygems/dependency_installer'

set :backend, :exec
# server_spec requires Gems to be installed in a specific path so the following is needed to make machine_tag
# available for testing
installer = Gem::DependencyInstaller.new
Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'csv'
require 'json'
require 'rubygems/dependency_installer'

set :backend, :exec
# Helper function to sort through the haproxy.cfg
#
# @param config_file [String] the name of the config file (/var/haproxy/haproxy.cfg)
Expand Down

0 comments on commit 62c5889

Please sign in to comment.