Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sous-chefs/haproxy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.1.0
Choose a base ref
...
head repository: sous-chefs/haproxy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.0.0
Choose a head ref
  • 16 commits
  • 23 files changed
  • 4 contributors

Commits on May 1, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f3d6fac View commit details

Commits on May 4, 2019

  1. Update Readme with opencollective

    This commit will update the readme
    xorima committed May 4, 2019
    Copy the full SHA
    1b2f891 View commit details

Commits on May 6, 2019

  1. Copy the full SHA
    32b9019 View commit details

Commits on May 7, 2019

  1. sponsors

    xorima committed May 7, 2019
    Copy the full SHA
    71b2ba5 View commit details
  2. Copy the full SHA
    a718273 View commit details
  3. Merge pull request #382 from sous-chefs/contrib-readme

    Update Readme with opencollective
    xorima authored May 7, 2019
    Copy the full SHA
    b9211cf View commit details

Commits on May 12, 2019

  1. Readme Maintainers

    This commit adds information about us, the maintainers, and how to contact us on slack/ our website
    xorima committed May 12, 2019
    Copy the full SHA
    77ba6e2 View commit details

Commits on May 13, 2019

  1. Standardise Danger (#384)

    This commit will standardise the dangerfile and bring it in line with all other repositories
    xorima authored and damacus committed May 13, 2019
    Copy the full SHA
    665dac2 View commit details
  2. Copy the full SHA
    29cc823 View commit details
  3. Merge pull request #385 from sous-chefs/readmeMaintainers

    Readme Maintainers
    xorima authored May 13, 2019
    Copy the full SHA
    cd0f8d7 View commit details
  4. Accept Chef License (#386)

    This commit enables us to accept the chef license inside dokken
    xorima authored and damacus committed May 13, 2019
    Copy the full SHA
    1baa48e View commit details

Commits on May 14, 2019

  1. Copy the full SHA
    2197929 View commit details

Commits on May 23, 2019

  1. Copy the full SHA
    c48eb2c View commit details

Commits on May 28, 2019

  1. Copy the full SHA
    ae7769c View commit details

Commits on May 29, 2019

  1. Copy the full SHA
    5086dd8 View commit details
  2. v8.0.0 (#394)

    JohnRoesler authored May 29, 2019
    Copy the full SHA
    23e16eb View commit details
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ lint_and_unit: &lint_and_unit
version: 2.1

orbs:
kitchen: sous-chefs/kitchen@1
kitchen: sous-chefs/kitchen@2

workflows:
kitchen:
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,12 @@

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

## [v8.0.0] (2019-05-29)

- The bind config hash joins with a space instead of a colon
- Add the peer resource
- Add the mailer resource

## [v7.1.0] (2019-04-16)

- Clean up unused templates and files
@@ -454,3 +460,5 @@ This file is used to list changes made in each version of the haproxy cookbook.
[v6.3.0]: https://github.com/sous-chefs/haproxy/compare/v6.2.7...v6.3.0
[v6.4.0]: https://github.com/sous-chefs/haproxy/compare/v6.3.0...v6.4.0
[v7.0.0]: https://github.com/sous-chefs/haproxy/compare/v6.4.0...v7.0.0
[v7.1.0]: https://github.com/sous-chefs/haproxy/compare/v7.0.0...v7.1.0
[v8.0.0]: https://github.com/sous-chefs/haproxy/compare/v7.1.0...v8.0.0
10 changes: 6 additions & 4 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Reference: http://danger.systems/reference.html

# A pull request summary is required. Add a description of the pull request purpose.
# Add labels to the pull request in github to identify the type of change. https://help.github.com/articles/applying-labels-to-issues-and-pull-requests/
# Changelog must be updated for each pull request.
# Changelog must be updated for each pull request that changes code.
# Warnings will be issued for:
# Pull request with more than 400 lines of code changed
# Pull reqest that change more than 5 lines without test changes
# Failures will be issued for:
# Pull request without summary
# Pull requests with code changes without changelog entry

def code_changes?
code = %w(libraries attributes recipes resources)
code = %w(libraries attributes recipes resources files templates)
code.each do |location|
return true unless git.modified_files.grep(/#{location}/).empty?
end
@@ -29,7 +31,7 @@ warn 'This is a big Pull Request.' if git.lines_of_code > 400

# Require a CHANGELOG entry for non-test changes.
if !git.modified_files.include?('CHANGELOG.md') && code_changes?
fail 'Please include a [CHANGELOG](https://github.com/sous-chefs/line-cookbook/blob/master/CHANGELOG.md) entry.'
fail 'Please include a CHANGELOG entry.'
end

# A sanity check for tests.
57 changes: 30 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# haproxy Cookbook

[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/haproxy/master.svg)](https://circleci.com/gh/sous-chefs/haproxy) [![Cookbook Version](https://img.shields.io/cookbook/v/haproxy.svg)](https://supermarket.chef.io/cookbooks/haproxy)
[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/haproxy/master.svg)](https://circleci.com/gh/sous-chefs/haproxy)
[![Cookbook Version](https://img.shields.io/cookbook/v/haproxy.svg)](https://supermarket.chef.io/cookbooks/haproxy)
[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)

Installs and configures HAProxy.

## Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).

## Requirements

* HAProxy `stable` or `LTS`
* Chef 13+

## Contributors

This project is made possible by our backers on [OpenCollective](https://opencollective.com/sous-chefs)

[![OpenCollective](https://opencollective.com/sous-chefs/tiers/regular-backer.svg?avatarHeight=36&width=600)](https://opencollective.com/sous-chefs)

### Platforms

This cookbook officially supports and is tested against the following platforms:
@@ -23,7 +25,6 @@ This cookbook officially supports and is tested against the following platforms:
* ubuntu: 16.04 & 18.04
* centos: 7
* amazonlinux: 2
* opensuseleap: 15

PRs are welcome to add support for additional platforms.

@@ -78,6 +79,8 @@ listen default
* [haproxy_frontend](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_frontend.md)
* [haproxy_install](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_install.md)
* [haproxy_listen](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_listen.md)
* [haproxy_mailer](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_mailer.md)
* [haproxy_peer](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_peer.md)
* [haproxy_resolver](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_resolver.md)
* [haproxy_service](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_service.md)
* [haproxy_use_backend](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_use_backend.md)
@@ -129,27 +132,27 @@ The `haproxy.cfg` file has a few specific rule orderings that will generate vali
)
```

## License & Authors
## Contributors

* Author:: Dan Webb (<https://github.com/damacus>)
* Author:: Will Fisher (<https://github.com/teknofire>)
* Author:: Richard Shade (<https://github.com/rshade>)
* Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))
* Author:: Aaron Baer ([aaron@hw-ops.com](mailto:aaron@hw-ops.com))
* Author:: Justin Kolberg ([justin@hw-ops.com](mailto:justin@hw-ops.com))
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)

```text
Copyright:: Heavy Water Operations, LLC.
### Backers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Thank you to all our backers!

http://www.apache.org/licenses/LICENSE-2.0
![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
### Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)
2 changes: 1 addition & 1 deletion documentation/haproxy_frontend.md
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ Introduced: v4.0.0

| Name | Type | Default | Description | Allowed Values
| -- | -- | -- | -- | -- |
| `bind` | String, Hash | `0.0.0.0:80` | |
| `bind` | String, Hash | `0.0.0.0:80` | String - sets as given. Hash joins with a space |
| `mode` | String | none | Set the running mode or protocol of the instance | `http`, `tcp`
| `maxconn` | Integer | none | Sets the maximum per-process number of concurrent connections |
| `reqrep` | String, Array | none | Replace a regular expression with a string in an HTTP request line |
2 changes: 1 addition & 1 deletion documentation/haproxy_listen.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ Introduced: v4.0.0

| Name | Type | Default | Description | Allowed Values
| -- | -- | -- | -- | -- |
| `bind` | String, Hash | `0.0.0.0:80` | |
| `bind` | String, Hash | `0.0.0.0:80` | String - sets as given. Hash joins with a space |
| `mode` | String | none | Set the running mode or protocol of the instance | `http`, `tcp`
| `maxconn` | Integer | none | Sets the maximum per-process number of concurrent connections |
| `reqrep` | String, Array | none | Replace a regular expression with a string in an HTTP request line |
39 changes: 39 additions & 0 deletions documentation/haproxy_mailer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[back to resource list](https://github.com/sous-chefs/haproxy#resources)

---

# haproxy_mailer

Mailer describes a mailers resource for sending email alerts on server state changes.

Introduced: v8.0.0

## Actions

`:create`

## Properties

| Name | Type | Default | Description | Allowed Values
| -- | -- | -- | -- | -- |
| `mailer` | String, Array | none | Defines a mailer inside a mailers section |
| `timeout` | String | none | Defines the time available for a mail/connection to be made and send to the mail-server |
| `config_dir` | String | `/etc/haproxy` | The directory where the HAProxy configuration resides | Valid directory
| `config_file` | String | `/etc/haproxy/haproxy.cfg` | The HAProxy configuration file | Valid file name
| `config_cookbook` | String | `haproxy` | Used to configure loading config from another cookbook

## Examples

```ruby
haproxy_mailer 'mymailer' do
mailer ['smtp1 192.168.0.1:587', 'smtp2 192.168.0.2:587']
timeout '20s'
end

haproxy_backend 'admin' do
server ['admin0 10.0.0.10:80 check weight 1 maxconn 100']
extra_options('email-alert' => [ 'mailers mymailers',
'from test1@horms.org',
'to test2@horms.org' ])
end
```
60 changes: 60 additions & 0 deletions documentation/haproxy_peer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[back to resource list](https://github.com/sous-chefs/haproxy#resources)

---

# haproxy_peer

Peer describes a peers resource for haproxy to propogate entries of any data-types in stick-tables between several haproxy instances over TCP connections in a multi-master fashion.

Most of the properties are available only when using HAProxy version >= 2.0. To set properties for versions < 2.0, use the `extra_options` hash. See examples below.

Introduced: v8.0.0

## Actions

`:create`

## Properties

| Name | Type | Default | Description | Allowed Values
| -- | -- | -- | -- | -- |
| `bind` | String, Hash | none | String - sets as given. Hash joins with a space. HAProxy version >= 2.0 |
| `state` | String, nil | nil | Set the state of the peers | `enabled`, `disabled`, nil
| `server` | Array | none | Servers in the peer |
| `default_bind` | String | none | Defines the binding parameters for the local peer, excepted its address |
| `default_server` | String | none | Change default options for a server |
| `table` | Array | none | Configure a stickiness table |
| `extra_options` | Hash | none | Used for setting any HAProxy directives |
| `config_dir` | String | `/etc/haproxy` | The directory where the HAProxy configuration resides | Valid directory
| `config_file` | String | `/etc/haproxy/haproxy.cfg` | The HAProxy configuration file | Valid file name
| `config_cookbook` | String | `haproxy` | Used to configure loading config from another cookbook

## Examples

HAProxy version >= 2.0

```ruby
haproxy_peer 'mypeers' do
bind '0.0.0.0:1336'
default_server 'ssl verify none'
server ['hostA 127.0.0.10:10000']
end
```

```ruby
haproxy_peer 'mypeers' do
bind('0.0.0.0:1336' => 'ssl crt mycerts/pem')
default_server 'ssl verify none'
server ['hostA 127.0.0.10:10000', 'hostB']
end
```

HAProxy version < 2.0

```ruby
haproxy_peer 'mypeers' do
extra_options(
'peer' => ['haproxy1 192.168.0.1:1024','haproxy2 192.168.0.2:1024']
)
end
```
1 change: 1 addition & 0 deletions .kitchen.dokken.yml → kitchen.dokken.yml
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
driver:
name: dokken
privileged: true # because Docker and SystemD/Upstart
env: [CHEF_LICENSE=accept]

transport:
name: dokken
File renamed without changes.
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
license 'Apache-2.0'
description 'Installs and configures haproxy'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '7.1.0'
version '8.0.0'
source_url 'https://github.com/sous-chefs/haproxy'
issues_url 'https://github.com/sous-chefs/haproxy/issues'
chef_version '>= 13.0'
2 changes: 1 addition & 1 deletion resources/frontend.rb
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
if new_resource.bind.is_a? Hash
new_resource.bind.map do |addresses, ports|
(Array(addresses).product Array(ports)).each do |combo|
variables['frontend'][new_resource.name]['bind'] << combo.join(':')
variables['frontend'][new_resource.name]['bind'] << combo.join(' ').strip
end
end
else
2 changes: 1 addition & 1 deletion resources/listen.rb
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
if new_resource.bind.is_a? Hash
new_resource.bind.map do |addresses, ports|
(Array(addresses).product Array(ports)).each do |combo|
variables['listen'][new_resource.name]['bind'] << combo.join(':')
variables['listen'][new_resource.name]['bind'] << combo.join(' ').strip
end
end
else
32 changes: 32 additions & 0 deletions resources/mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
property :mailer, [String, Array],
description: 'Defines a mailer inside a mailers section'
property :timeout, String,
description: 'Defines the time available for a mail/connection to be made and send to the mail-server'
property :config_dir, String,
default: '/etc/haproxy',
description: 'The directory where the HAProxy configuration resides'
property :config_file, String,
default: lazy { ::File.join(config_dir, 'haproxy.cfg') },
description: 'The HAProxy configuration file'
property :config_cookbook, String,
default: 'haproxy',
description: 'Used to configure loading config from another cookbook'

action :create do
# As we're using the accumulator pattern we need to shove everything
# into the root run context so each of the sections can find the parent
with_run_context :root do
edit_resource(:template, new_resource.config_file) do |new_resource|
node.run_state['haproxy'] ||= { 'conf_template_source' => {}, 'conf_cookbook' => {} }
source lazy { node.run_state['haproxy']['conf_template_source'][new_resource.config_file] ||= 'haproxy.cfg.erb' }
cookbook lazy { node.run_state['haproxy']['conf_cookbook'][new_resource.config_cookbook] ||= 'haproxy' }
variables['mailer'] ||= {}
variables['mailer'][new_resource.name] ||= {}
variables['mailer'][new_resource.name]['mailer'] ||= [new_resource.mailer].flatten unless new_resource.mailer.nil?
variables['mailer'][new_resource.name]['timeout'] ||= new_resource.timeout unless new_resource.timeout.nil?

action :nothing
delayed_action :create
end
end
end
38 changes: 38 additions & 0 deletions resources/peer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
property :bind, [ String, Hash ]
property :state, [ String, nil ], default: nil, equal_to: [ 'enabled', 'disabled', nil ]
property :server, Array
property :default_bind, String
property :default_server, String
property :table, Array
property :extra_options, Hash
property :config_dir, String, default: '/etc/haproxy'
property :config_file, String, default: lazy { ::File.join(config_dir, 'haproxy.cfg') }
property :config_cookbook, String, default: 'haproxy'

action :create do
# As we're using the accumulator pattern we need to shove everything
# into the root run context so each of the sections can find the parent
with_run_context :root do
edit_resource(:template, new_resource.config_file) do |new_resource|
node.run_state['haproxy'] ||= { 'conf_template_source' => {}, 'conf_cookbook' => {} }
source lazy { node.run_state['haproxy']['conf_template_source'][new_resource.config_file] ||= 'haproxy.cfg.erb' }
cookbook lazy { node.run_state['haproxy']['conf_cookbook'][new_resource.config_cookbook] ||= 'haproxy' }
variables['peer'] ||= {}
variables['peer'][new_resource.name] ||= {}
variables['peer'][new_resource.name]['bind'] ||= {}
variables['peer'][new_resource.name]['bind'] = new_resource.bind unless new_resource.bind.nil?
variables['peer'][new_resource.name]['state'] = new_resource.state unless new_resource.state.nil?
variables['peer'][new_resource.name]['server'] ||= []
variables['peer'][new_resource.name]['server'] << new_resource.server unless new_resource.server.nil?
variables['peer'][new_resource.name]['default_bind'] = new_resource.default_bind unless new_resource.default_bind.nil?
variables['peer'][new_resource.name]['default_server'] = new_resource.default_server unless new_resource.default_server.nil?
variables['peer'][new_resource.name]['table'] ||= []
variables['peer'][new_resource.name]['table'] << new_resource.table unless new_resource.table.nil?
variables['peer'][new_resource.name]['extra_options'] ||= {} unless new_resource.extra_options.nil?
variables['peer'][new_resource.name]['extra_options'] = new_resource.extra_options unless new_resource.extra_options.nil?

action :nothing
delayed_action :create
end
end
end
2 changes: 1 addition & 1 deletion spec/unit/recipes/frontend_backend_spec.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
haproxy_install 'package'

haproxy_frontend 'admin' do
bind '0.0.0.0:1337'
bind '0.0.0.0:1337' => ''
mode 'http'
use_backend ['admin0 if path_beg /admin0']
extra_options('http-request' => 'add-header Test Value')
2 changes: 1 addition & 1 deletion spec/unit/recipes/listen_spec.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
haproxy_install 'package'

haproxy_listen 'admin' do
bind '0.0.0.0:1337'
bind '0.0.0.0:1337' => ''
mode 'http'
stats uri: '/',
realm: 'Haproxy-Statistics',
Loading