2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This file is generated by ModuleSync, do not edit.
*.rb eol=lf
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
13 changes: 13 additions & 0 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@
/convert_report.txt
/update_report.txt
.DS_Store
/appveyor.yml
/.fixtures.yml
/Gemfile
/.gitattributes
/.gitignore
/.gitlab-ci.yml
/.pdkignore
/Rakefile
/.rspec
/.rubocop.yml
/.travis.yml
/.yardopts
/spec/
1 change: 1 addition & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--relative
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
sudo: false
dist: trusty
language: ruby
cache: bundler
before_install:
- bundle -v
- rm -f Gemfile.lock
- gem update --system
- gem update --system $RUBYGEMS_VERSION
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.5.0
- 2.5.1
env:
global:
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
Expand All @@ -24,15 +23,15 @@ matrix:
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
rvm: 2.5.0
rvm: 2.5.1
script: bundle exec rake beaker
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
rvm: 2.5.0
rvm: 2.5.1
script: bundle exec rake beaker
services: docker
sudo: required
Expand All @@ -43,9 +42,6 @@ matrix:
-
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.4
-
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
rvm: 2.1.9
branches:
only:
- master
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [3.0.0](https://github.com/puppetlabs/puppetlabs-haproxy/tree/3.0.0) (2019-02-01)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-haproxy/compare/2.2.0...3.0.0)

### Changed

- \(FM-7675\) - Support has been removed for RHEL 6 [\#345](https://github.com/puppetlabs/puppetlabs-haproxy/pull/345) ([david22swan](https://github.com/david22swan))

### Added

- \(MODULES-8539\) Added 'accepted\_payload\_size' to resolver [\#346](https://github.com/puppetlabs/puppetlabs-haproxy/pull/346) ([genebean](https://github.com/genebean))
- Sergey leskov/servertemplatekwimp [\#337](https://github.com/puppetlabs/puppetlabs-haproxy/pull/337) ([LeskovSergey](https://github.com/LeskovSergey))

### Fixed

- \(MODULES-8407\) Add option to set the service's name [\#342](https://github.com/puppetlabs/puppetlabs-haproxy/pull/342) ([genebean](https://github.com/genebean))
- pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#341](https://github.com/puppetlabs/puppetlabs-haproxy/pull/341) ([tphoney](https://github.com/tphoney))

## [2.2.0](https://github.com/puppetlabs/puppetlabs-haproxy/tree/2.2.0) (2018-09-27)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-haproxy/compare/2.1.0...2.2.0)
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ group :development do
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
Expand Down
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [Beginning with haproxy](#beginning-with-haproxy)
4. [Usage - Configuration options and additional functionality](#usage)
* [Configure HAProxy options](#configure-haproxy-options)
* [HAProxy and Software Collections](#haproxy-and-software-collections)
* [Configure HAProxy daemon listener](#configure-haproxy-daemon-listener)
* [Configure multi-network daemon listener](#configure-multi-network-daemon-listener)
* [Configure HAProxy load-balanced member nodes](#configure-haproxy-load-balanced-member-nodes)
Expand Down Expand Up @@ -128,6 +129,22 @@ class { 'haproxy':
}
~~~

### HAProxy and Software Collections

To use this module with a software collection such as
[rh-haproxy18](https://www.softwarecollections.org/en/scls/rhscl/rh-haproxy18/)
you will need to set a few extra parameters like so:

~~~puppet
class { 'haproxy':
package_name => 'rh-haproxy18',
config_dir => '/etc/opt/rh/rh-haproxy18/haproxy',
config_file => '/etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg',
config_validate_cmd => '/bin/scl enable rh-haproxy18 "haproxy -f % -c"',
service_name => 'rh-haproxy18-haproxy',
}
~~~

### Configure HAProxy daemon listener

To export the resource for a balancermember and collect it on a single HAProxy load balancer server:
Expand Down Expand Up @@ -317,18 +334,19 @@ class { 'haproxy':
# Declare the resolver
haproxy::resolver { 'puppet00':
nameservers => {
nameservers => {
'dns1' => '192.168.56.1:53',
'dns2' => '192.168.56.2:53'
},
hold => {
hold => {
'nx' => '30s',
'valid' => '10s'
},
resolve_retries => 3,
timeout => {
resolve_retries => 3,
timeout => {
'retry' => '1s'
},
accepted_payload_size => 512,
}
# Setup the balancermember to use the resolver for DNS resolution
Expand Down Expand Up @@ -599,6 +617,8 @@ Main class, includes all other classes.

* `service_manage`: Specifies whether the state of the HAProxy service should be managed by Puppet. Valid options: 'true' and 'false'. Default: 'true'.

* `service_name`: Specifies the name of the HAProxy service. Valid options: a string. Default: 'haproxy'.

* `service_options`: Contents for the `/etc/defaults/haproxy` file on Debian. Defaults to "ENABLED=1\n" on Debian, and is ignored on other systems.

* `sysconfig_options`: Contents for the `/etc/sysconfig/haproxy` file on RedHat(-based) systems. Defaults to OPTIONS="" on RedHat(-based) systems and is ignored on others
Expand Down Expand Up @@ -861,6 +881,11 @@ stopped and disabled at boot. Defaults to 'running'
Chooses whether the haproxy service state should be managed by puppet at
all. Defaults to true

* `service_name`:
The service name for haproxy. Defaults to undef. If no name is given then
the value computed for $instance_name will be used.
NOTE: Class['haproxy'] has a different default.

* `global_options`:
A hash of all the haproxy global options. If you want to specify more
than one option (i.e. multiple timeout or stats options), pass those
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?

def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
Expand Down
37 changes: 37 additions & 0 deletions manifests/balancermember.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# configuration. If you use an array in server_names and ipaddresses, the
# same port is used for all balancermembers.
#
# [*port*]
# A port for server-template. It is an optional specification.
#
# [*server_names*]
# The name of the balancer member server as known to haproxy in the
# listening service's configuration block. This defaults to the
Expand All @@ -39,6 +42,18 @@
# The ip address used to contact the balancer member server.
# Can be an array, see documentation to server_names.
#
# [*prefix*]
# A prefix for the server-template for the server names to be built.
#
# [*amount*]
# If "amount" is provided, the server-template initializes <num> servers
# with 1 up to <num> as server name suffixes. A range of numbers
# <num_low>-<num_high> may also be used to use <num_low> up to
# <num_high> as server name suffixes.
#
# [*fqdn*]
# A FQDN for all the servers the server-template initializes.
#
# [*options*]
# An array of options to be specified after the server declaration
# in the listening service's configuration block.
Expand Down Expand Up @@ -94,13 +109,35 @@
# options => 'check',
# }
#
# Implemented in HAPROXY 1.8:
# Set a template to initialize servers with shared parameters.
# The names of these servers are built from <prefix> and <amount> parameters.
#
# Initializes 5 servers with srv1, srv2, srv3, srv4 and srv5 as names,
# myserver.example.com as FQDN, 8140 as port, and health-check enabled.
#
# haproxy::balancermember { 'haproxy':
# listening_service => 'puppet00',
# type => 'server-template'
# port => '8140',
# prefix => 'srv',
# amount => '1-5',
# fqdn => 'myserver.example.com',
# options => 'check',
# }
#
# (this resource can be declared anywhere)
#
define haproxy::balancermember (
$listening_service,
$type = 'server',
$ports = undef,
$port = undef,
$server_names = $::hostname,
$ipaddresses = $::ipaddress,
$prefix = 'server',
$amount = '1',
$fqdn = '',
$options = '',
$define_cookies = false,
$instance = 'haproxy',
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
# Chooses whether the haproxy service state should be managed by puppet at
# all. Defaults to true
#
# [*service_name*]
# The service name for haproxy. Defaults to 'haproxy'
# NOTE: haproxy::instance has a different default.
#
# [*service_options*]
# Contents for the `/etc/defaults/haproxy` file on Debian. Defaults to "ENABLED=1\n" on Debian, and is ignored on other systems.
#
Expand Down Expand Up @@ -113,6 +117,7 @@
String $package_name = $haproxy::params::package_name,
Variant[Enum['running', 'stopped'], Boolean] $service_ensure = 'running',
Boolean $service_manage = true,
String $service_name = $haproxy::params::service_name,
String $service_options = $haproxy::params::service_options,
$sysconfig_options = $haproxy::params::sysconfig_options,
Hash $global_options = $haproxy::params::global_options,
Expand Down Expand Up @@ -163,6 +168,7 @@
package_name => $package_name,
service_ensure => $_service_ensure,
service_manage => $_service_manage,
service_name => $service_name,
global_options => $global_options,
defaults_options => $defaults_options,
restart_command => $restart_command,
Expand Down
10 changes: 9 additions & 1 deletion manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
# Chooses whether the haproxy service state should be managed by puppet at
# all. Defaults to true
#
# [*service_name*]
# The service name for haproxy. Defaults to undef. If no name is given then
# the value computed for $instance_name will be used.
# NOTE: Class['haproxy'] has a different default.
#
# [*global_options*]
# A hash of all the haproxy global options. If you want to specify more
# than one option (i.e. multiple timeout or stats options), pass those
Expand Down Expand Up @@ -144,6 +149,7 @@
String[1] $package_ensure = 'present',
Variant[Enum['running', 'stopped'], Boolean] $service_ensure = 'running',
Boolean $service_manage = true,
Optional[String] $service_name = undef,
Optional[Hash] $global_options = undef,
Optional[Hash] $defaults_options = undef,
$restart_command = undef,
Expand Down Expand Up @@ -188,6 +194,8 @@
$_config_dir = pick($config_dir, inline_template($haproxy::params::config_dir_tmpl))
}

$instance_service_name = pick($service_name, $instance_name)

haproxy::config { $title:
instance_name => $instance_name,
config_dir => $_config_dir,
Expand All @@ -204,7 +212,7 @@
package_ensure => $package_ensure,
}
haproxy::service { $title:
instance_name => $instance_name,
instance_name => $instance_service_name,
service_ensure => $service_ensure,
service_manage => $service_manage,
restart_command => $restart_command,
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
case $::osfamily {
'Archlinux', 'Debian', 'Redhat', 'Gentoo', 'Suse' : {
$package_name = 'haproxy'
$service_name = 'haproxy'
$global_options = {
'log' => "${::ipaddress} local0",
'chroot' => '/var/lib/haproxy',
Expand Down Expand Up @@ -50,6 +51,7 @@
}
'FreeBSD': {
$package_name = 'haproxy'
$service_name = 'haproxy'
$global_options = {
'log' => [
'127.0.0.1 local0',
Expand Down
Loading