From fc0116aad6687e11b05ca19090d46fc48ae84bd3 Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Sun, 18 May 2025 17:03:16 +0800 Subject: [PATCH 01/10] debian12 changes for QA env --- cookbooks/supervisor/recipes/default.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cookbooks/supervisor/recipes/default.rb b/cookbooks/supervisor/recipes/default.rb index 549880fe..f13775b9 100644 --- a/cookbooks/supervisor/recipes/default.rb +++ b/cookbooks/supervisor/recipes/default.rb @@ -28,7 +28,7 @@ # Install supervisor based on Debian version if platform?('debian') && (node['platform_version'] == '12' || node['lsb']['codename'] == 'bookworm') execute 'pipx install supervisor' do - command 'pipx install supervisor --index=https://pypi.python.org/simple/' + command 'PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install supervisor --index=https://pypi.python.org/simple/' end else execute 'pip install supervisor' do @@ -118,3 +118,4 @@ action [:enable] end end + From 218df7bb1387b1110fb438f3c622a8b2328cdaaf Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Mon, 19 May 2025 13:45:48 +0800 Subject: [PATCH 02/10] wip --- cookbooks/supervisor/recipes/default.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/cookbooks/supervisor/recipes/default.rb b/cookbooks/supervisor/recipes/default.rb index f13775b9..03e79ff0 100644 --- a/cookbooks/supervisor/recipes/default.rb +++ b/cookbooks/supervisor/recipes/default.rb @@ -29,6 +29,7 @@ if platform?('debian') && (node['platform_version'] == '12' || node['lsb']['codename'] == 'bookworm') execute 'pipx install supervisor' do command 'PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install supervisor --index=https://pypi.python.org/simple/' + not_if { ::File.exist?('/usr/local/bin/supervisorctl') } end else execute 'pip install supervisor' do From 62aa137520d6de042b8a6eb6a12cd63590eeef15 Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 14:47:47 +0800 Subject: [PATCH 03/10] debian_13 --- cookbooks/supervisor/recipes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbooks/supervisor/recipes/default.rb b/cookbooks/supervisor/recipes/default.rb index 03e79ff0..3450fb85 100644 --- a/cookbooks/supervisor/recipes/default.rb +++ b/cookbooks/supervisor/recipes/default.rb @@ -26,7 +26,7 @@ end # Install supervisor based on Debian version -if platform?('debian') && (node['platform_version'] == '12' || node['lsb']['codename'] == 'bookworm') +if platform?('debian') && (%w(12 13).include?(node['platform_version']) || %w(bookworm trixie).include?(node['lsb']['codename'])) execute 'pipx install supervisor' do command 'PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install supervisor --index=https://pypi.python.org/simple/' not_if { ::File.exist?('/usr/local/bin/supervisorctl') } From 2f4b8415b40f5565f680fae90d68aba2a0f45dd1 Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 14:52:31 +0800 Subject: [PATCH 04/10] debian_13 --- cookbooks/haproxy/.markdownlint.json | 6 + cookbooks/haproxy/CHANGELOG.md | 769 ++++++++++++++++++ cookbooks/haproxy/LICENSE | 201 +++++ cookbooks/haproxy/README.md | 161 ++++ cookbooks/haproxy/chefignore | 115 +++ cookbooks/haproxy/files/haproxy-default | 0 cookbooks/haproxy/libraries/helpers.rb | 85 ++ cookbooks/haproxy/libraries/resource.rb | 52 ++ cookbooks/haproxy/libraries/template.rb | 9 + cookbooks/haproxy/metadata.json | 40 + cookbooks/haproxy/metadata.rb | 16 + cookbooks/haproxy/resources/acl.rb | 40 + cookbooks/haproxy/resources/backend.rb | 82 ++ cookbooks/haproxy/resources/cache.rb | 40 + .../haproxy/resources/config_defaults.rb | 64 ++ cookbooks/haproxy/resources/config_global.rb | 70 ++ cookbooks/haproxy/resources/fastcgi.rb | 53 ++ cookbooks/haproxy/resources/frontend.rb | 89 ++ cookbooks/haproxy/resources/install.rb | 182 +++++ cookbooks/haproxy/resources/listen.rb | 109 +++ cookbooks/haproxy/resources/mailer.rb | 33 + .../haproxy/resources/partial/_config_file.rb | 35 + .../resources/partial/_extra_options.rb | 2 + cookbooks/haproxy/resources/peer.rb | 61 ++ cookbooks/haproxy/resources/resolver.rb | 35 + cookbooks/haproxy/resources/service.rb | 91 +++ cookbooks/haproxy/resources/use_backend.rb | 43 + cookbooks/haproxy/resources/userlist.rb | 35 + .../haproxy/templates/default/haproxy.cfg.erb | 462 +++++++++++ cookbooks/supervisor/recipes/default.rb | 2 +- 30 files changed, 2981 insertions(+), 1 deletion(-) create mode 100644 cookbooks/haproxy/.markdownlint.json create mode 100644 cookbooks/haproxy/CHANGELOG.md create mode 100644 cookbooks/haproxy/LICENSE create mode 100644 cookbooks/haproxy/README.md create mode 100644 cookbooks/haproxy/chefignore create mode 100644 cookbooks/haproxy/files/haproxy-default create mode 100644 cookbooks/haproxy/libraries/helpers.rb create mode 100644 cookbooks/haproxy/libraries/resource.rb create mode 100644 cookbooks/haproxy/libraries/template.rb create mode 100644 cookbooks/haproxy/metadata.json create mode 100644 cookbooks/haproxy/metadata.rb create mode 100644 cookbooks/haproxy/resources/acl.rb create mode 100644 cookbooks/haproxy/resources/backend.rb create mode 100644 cookbooks/haproxy/resources/cache.rb create mode 100644 cookbooks/haproxy/resources/config_defaults.rb create mode 100644 cookbooks/haproxy/resources/config_global.rb create mode 100644 cookbooks/haproxy/resources/fastcgi.rb create mode 100644 cookbooks/haproxy/resources/frontend.rb create mode 100644 cookbooks/haproxy/resources/install.rb create mode 100644 cookbooks/haproxy/resources/listen.rb create mode 100644 cookbooks/haproxy/resources/mailer.rb create mode 100644 cookbooks/haproxy/resources/partial/_config_file.rb create mode 100644 cookbooks/haproxy/resources/partial/_extra_options.rb create mode 100644 cookbooks/haproxy/resources/peer.rb create mode 100644 cookbooks/haproxy/resources/resolver.rb create mode 100644 cookbooks/haproxy/resources/service.rb create mode 100644 cookbooks/haproxy/resources/use_backend.rb create mode 100644 cookbooks/haproxy/resources/userlist.rb create mode 100644 cookbooks/haproxy/templates/default/haproxy.cfg.erb diff --git a/cookbooks/haproxy/.markdownlint.json b/cookbooks/haproxy/.markdownlint.json new file mode 100644 index 00000000..95b5094c --- /dev/null +++ b/cookbooks/haproxy/.markdownlint.json @@ -0,0 +1,6 @@ +{ + "MD024": { + "siblings_only": true + }, + "MD013":false +} diff --git a/cookbooks/haproxy/CHANGELOG.md b/cookbooks/haproxy/CHANGELOG.md new file mode 100644 index 00000000..68c407f1 --- /dev/null +++ b/cookbooks/haproxy/CHANGELOG.md @@ -0,0 +1,769 @@ +# haproxy Cookbook CHANGELOG + +This file is used to list changes made in each version of the haproxy cookbook. + +## 12.2.3 - *2022-04-21* + +- Remove delivery folder +- Standardise files with files in sous-chefs/repo-management +- Migrate to new workflow pipelines + +## 12.2.2 - *2021-10-05* + +- Update supported platforms in README.md + +## 12.2.1 - *2021-08-30* + +- Standardise files with files in sous-chefs/repo-management + +## 12.2.0 - *2021-08-11* + +- Add `use_promex` property to install.rb to support compiling with Prometheus Exporter support - [@Wicaeed](https://github.com/wicaeed) + +## 12.1.0 - *2021-06-14* + +- Add `ssl_lib` and `ssl_inc` properties to `haproxy_install` to support openssl - [@derekgroh](https://github.com/derekgroh) + +## 12.0.1 - *2021-06-01* + +- Standardise files with files in sous-chefs/repo-management + +## 12.0.0 - *2021-05-13* + +- Refactor to use resource partials +- Add delete action to most resources +- Convert `install` resource boolean strings to true/false +- Ensure section is created before adding an ACL + +## 11.0.0 - *2021-05-07* + +- Drop testing for Debian 8, Ubuntu 16.04 & Ubuntu 18.04 +- Add testing for Debian 9 Ubuntu 20.04 & Ubuntu 21.04 +- Fix the minimum Chef version to 15.3 + unified_mode was introduced in 15.3 +- Change kitchen to use the Bento provided Amazonlinux2 image +- Fix test suite + +## 10.0.1 - *2021-04-26* + +- Add missing configuration file properties to all resources + +## 10.0.0 - *2021-04-24* + +- Add configuration test function to the service resource - [@bmhughes](https://github.com/bmhughes) +- Fix generating multiple actions from the service resource - [@bmhughes](https://github.com/bmhughes) +- Kitchen test with CentOS 8/8 stream - [@bmhughes](https://github.com/bmhughes) +- Fix IUS repo causing a run failure on an unsupported platform - [@bmhughes](https://github.com/bmhughes) +- Move configuration resource creation into resource helper module - [@bmhughes](https://github.com/bmhughes) + +## [v9.1.0] (2020-10-07) + +### Added + +- testing for haproxy 2.2 + +### Removed + +- testing for haproxy 1.9 & 2.1 + +## [v9.0.1] (2020-09-15) + +### Added + +- added lua compilation flags to `haproxy_install` resource + +### Fixed + +- resolved cookstyle error: libraries/helpers.rb:19:24 refactor: `ChefCorrectness/InvalidPlatformFamilyInCase` +- Updated IUS repo url to `https://repo.ius.io/ius-release-el7.rpm` + +### Changed + +- Turn on unified_mode for all resources + +## [v9.0.0] (2020-02-21) + +### Changed + +- Removed `depends_on` build-essential, as this is now in Chef Core + +### Fixed + +- Cookstyle fixes for cookstyle version 5.20 + +## [v8.3.0] (2020-01-09) + +### Added + +- on `haproxy_install` epel is now a configurable option + +### Changed + +- Migrated testing to github actions + +### Fixed + +- ius repo will only echo out if enabled + +## [v8.2.0] (2019-12-23) + +### Added + +- `fastcgi` resource to support FastCGI applications + +### Changed + +- Default source install version is haproxy 2.1 + +### Fixed + +- Bug with single newline between resources when multiple of the same type are defined + +### Removed + +- `.foodcritic` as it is no longer run by deliver local. +- `.rubocop.yml` as no longer required. + +## [v8.1.1] (2019-10-02) + +### Changed + +- Updated `config_defaults` resourcce `stats` property default value to empty hash. +- Updated metadata.rb chef_version to >=13.9 due to resource `description`. + +## [v8.1.0] (2019-06-24) + +### Changed + +- Updated build target to linux-glibc for haproxy 2.0 compatibility. +- Updated integration tests to cover haproxy 2.0. +- Moved install resource target_os check to libraries. + +## [v8.0.0] (2019-05-29) + +### Added + +- The bind config hash joins with a space instead of a colon. +- The peer resource. +- The mailer resource. + +## [v7.1.0] (2019-04-16) + +### Changed + +- Clean up unused templates and files. + +### Fixed + +- Name conflict with systemd_unit in service resource. + +## [v7.0.0] (2019-04-10) + +### Added + +- `health` to allowed values for `mode` on `frontend`, `backend`, `listen`, `default`. +- `apt-update` for debian platforms. +- ius repo for CentOS and Redhat package installations (resolves #348). + +### Changed + +- Clean up unit and integration test content regular expressions. +- Move system command to a helper. +- Support only systemd init systems. + +### Removed + +- Remove `poise_service` dependency in favor of systemd_unit. + +### Fixed + +- Fix cookbook default value in `config_global`. + +## [v6.4.0] (2019-03-20) + +### Changed + +- Move resource documentation to dedicated folder with md per resource. +- Rename haproxy_cache `name` property as `cache_name`. + +### Fixed + +- Source installs on CentOS 6. + +## [v6.3.0] (2019-02-18) + +### Added + +- Haproxy_cache resource for caching small objects with HAProxy version >=1.8. + +### Changed + +- Expand integration test coverage to all stable and LTS HAProxy versions. +- Documentation - clarify extra_options hash string => array option. +- Clarify the supported platforms - add AmazonLinux 2, remove fedora & freebsd. + +## [v6.2.7] (2019-01-10) + +### Added + +- Test for appropriate spacing from start of line and end of line. +- `hash_type` param to `haproxy_backend`, `haproxy_listen`, and `haproxy_config_defaults` resources. +- `reqirep` and `reqrep` params to `haproxy_backend`, `haproxy_frontend`, and `haproxy_listen` resources. +- `sensitive` param to `haproxy_install`; set to false to show diff output during Chef run. + +### Changed + +- Allow passing an array to `haproxy_listen`'s `http_request` param. + +### Fixed + +- Fix ordering for `haproxy_listen`: `acl` directives should be applied before `http-request`. + +## [v6.2.6] (2018-11-05) + +### Changed + +- Put `http_request` rules before the `use_backend`. + +## [v6.2.5] (2018-10-09) + +### Added + +- rspec examples for resource usage. + +### Removed + +- Chef-12 support. +- CPU cookbook dependency. + +### Fixed + +- Systemd wrapper, the wrapper is no longer included with haproxy versions greater than 1.8. + +## [v6.2.4] (2018-09-19) + +### Added + +- Server property to listen resource and config template. + +## [v6.2.3] (2018-08-03) + +### Removed + +- A few resource default values so they can be specified in the haproxy.cfg default section and added service reload exmample to the readme for config changes. + +## [v6.2.2] (2018-08-03) + +### Changed + +- Made `haproxy_install` `source_url` property dynamic with `source_version` property and removed the need to specify checksum #307. + +## [v6.2.1] (2018-08-01) + +### Added + +- Compiling from source crypt support #305. + +## [v6.2.0] (2018-05-11) + +### Changed + +- Require Chef 12.20 or later. +- Uses the build_essential resource not the default recipe so the cookbook can be skipped entirely if running on Chef 14+. + +## [v6.1.0] (2018-04-12) + +### **Breaking changes** + +### Added + +- `haproxy_service` resource see test suites for usage. +- Support for haproxy 1.8. +- Test haproxy version 1.8.7 and 1.7.8. +- Test on chef-client version 13.87 and 14. +- Notes on how we generate the travis.yml list. + +### Changed + +- Require Chef 12.20 or later. +- Uses the build_essential resource not the default recipe so the cookbook can be skipped entirely if running on Chef 14+. +- Simplify the kitchen matrix. +- Use default action in tests (:create). +- Set the use_systemd property from the init package system. +- Adding in systemd for SUSE Linux. + +### Removed + +- `kitchen.dokken.yml` suites and inherit from kitchen.yml. +- Amazon tests until a new dokken image is produced that is reliable. + +### Fixed + +- Source comparison. + +## [v6.0.0] (2018-03-28) + +### Removed + +- `compat_resource` cookbok dependency and push the required Chef version to 12.20 + +## [v5.0.4] (2018-03-28) + +### Changed + +- Make 1.8.4 the default installed version (#279) +- Use dokken docker images +- Update tests for haproxy service +- tcplog is now a valid input for the `haproxy_config_defaults` resource (#284) +- bin prefix is now reflected in the service config. (#288, #289) + +## [v5.0.3] (2018-02-02) + +### Fixed + +- `foodcritic` warning for not defining `name_property`. + +## [v5.0.2] (2017-11-29) + +### Fixed + +- Typo in listen section, makes previously unprintable expressions, printable in http-request, http-response and `default_backend`. + +## [v5.0.1] (2017-08-10) + +### Removed + +- useless blank space in generated config file haproxy.cfg + +## [v5.0.0] (2017-08-07) + +### Added + +- Option for install only #251. + +### Changed + +- Updating service to use cookbook template. +- updating to haproxy 1.7.8, updating `source_version` in test files(kitchen,cookbook, etc) +- updating properties to use `new_resource` + +### Fixed + +- `log` `property` in `global` resource can now be of type `Array` or `String`. This fixes #252 +- fixing supports line #258 + +## [v4.6.1] (2017-08-02) + +### Changed + +- Reload instead of restart on config change +- Specify -sf argument last to support haproxy < 1.6.0 + +## [v4.6.0] (2017-07-13) + +### Added + +- `conf_template_source` +- `conf_cookbook` +- Support Array value for `extra_options` entries. (#245, #246) + +## [v4.5.0] (2017-06-29) + +### Added + +- `resolver` resource (#240) + +## [v4.4.0] (2017-06-28) + +### Added + +- `option` as an Array `property` for `backend` resource. This fixes #234 +- Synced Debian/Ubuntu init script with latest upstream package changes + +## [v4.3.1] (2017-06-13) + +### Added + +- Oracle Linux 6 support + +### Removed + +- Scientific linux support as we don't have a reliable image + +## [v4.3.0] (2017-05-31) + +### Added + +- Chefspec Matchers for the resources defined in this cookbook. +- `mode` property to `backend` and `frontend` resources. +- `maxconn` to `global` resource. + +### Removed + +- `default_backend` as a required property on the `frontend` resource. + +## [v4.2.0] (2017-05-04) + +### Added + +- In `acl` resource, usage: `test/fixtures/cookbooks/test/recipes/config_acl.rb` +- In `use_backend` resource, usage: `test/fixtures/cookbooks/test/recipes/config_acl.rb` +- `acl` and `use_backend` to `listen` resource. +- Amazon Linux as a supported platform. + +### Changed + +- Pinned `build-essential`, `>= 8.0.1` +- Pinned `poise-service`, `>= 1.5.1` +- Cleaned up arrays in `templates/default/haproxy.cfg.erb` + +### Fixed + +- Init script for Amazon Linux. + +### BREAKING CHANGES + +- This version removes `stats_socket`, `stats_uri` and `stats_timeout` properties from the `haproxy_global` and `haproxy_listen` resources in favour of using a hash to pass configuration options. + +## [v4.1.0] (2017-05-01) + +### Added + +- `userlist` resource, to see usage: `test/fixtures/cookbooks/test/recipes/config_1_userlist.rb` +- chef-search example in: `test/fixtures/cookbooks/test/recipes/config_backend_search.rb` +- Multiple addresses and ports on listener and frontend (#205) + +### Changed + +- Updating source install test to take node attributes as haproxy.org is slow. + +### Fixed + +- `haproxy_retries` in `haproxy_config_defaults` resource + +## [v4.0.2] (2017-04-21) + +### Fixed + +- haproxy service start on Ubuntu 14.04 (#199) +- Reload HAProxy when changing configuration (#197) + +## [v4.0.1] (2017-04-20) + +### Added + +- Updating README.md +- Adding compat_resource for chef-12 support +- Improvement when rendering the configuration file (#196) + +## [v4.0.0] (2017-04-18) + +### COMPATIBILIY WARNING + +- This version removes the existing recipes, attributes, and instance provider in favor of the new haproxy_install and haproxy_ configuration resources. Why not just leave them in place? Well unfortunately they were utterly broken for anything other than the most trivial usage. Rather than continue the user pain we've opted to remove them and point users to a more modern installation method. If you need the legacy installation methods simply pin to the 3.0.4 release. +- THIS IS GOING TO BREAK EVERYTHING YOU KNOW AND LOVE +- 12.5 or greater rewrite +- Custom Resource Only, no recipes + +## [v3.0.4] (2017-03-29) + +### Fixed + +- Bug introduced in (#174) (#182) + +## [v3.0.3] (2017-03-28) + +### Added + +- Multiple addresses and ports on listener and frontend (#174) +- Customize logging destination (#178) + +### Changed + +- Updating to use bats/serverspec (#179) + +## [v3.0.2] (2017-03-27) + +### Added + +- Allow server startup from `app_lb` recipe. (#171) +- Use Delivery instead of Rake +- Make this cookbook compatible with Chef-13, note: `params` option is now `parameters` (#175) + +## [v3.0.1] (2017-01-30) + +### Added + +- Reload haproxy configuration on changes (#152) +- Merging in generic socket conf (#107) +- Updating config to use facilities hash dynamically (#102) +- Adding `tproxy` and splice per (#98) + +### Removed + +- Members with nil ips from member array. (#79) + +## [v3.0.0] (2017-01-24) + +### Added + +- Configurable debug options +- CentOS7 compatibility (#123) +- Adding poise-service for service management + +### Changed + +- Updating source install to use Haproxy 1.7.2 +- Chef >= 12.1 required +- Use `['haproxy']['source']['target_cpu']` instead of `['haproxy']['source']['target_os']` to detect correct architecture. (#150) + +## [v2.0.2] (2016-12-30) + +### Fixed + +- Cookstyle +- The github URL for the repo in various locations + +### Changed + +- Travis testing updates +- Converted file modes to strings +- Updated the config resource to lazily evaluate node attribute values to better load the values when overridden in wrapper cookbooks + +## v2.0.1 (2016-12-08) + +### Fixed + +- Dynamic configuration to properly template out frontend and backend sections + +### Chnaged + +- Update Chef Brigade to Sous Chefs +- Updated contributing docs to remove the reference to the develop branch + +## v2.0.0 (2016-11-09) + +### Breaking Changes + +- The default recipe is now an empty recipe with manual configuration performed in the 'manual' recipe +- Remove Chef 10 compatibility code +- Switch from Librarian to Berksfile +- Updated the source recipe to install 1.6.9 by default + +### Added + +- Migrated this cookbook from Heavy Water to Chef Brigade so we can ensure more frequent releases and maintenance +- A code of conduct for the project. Read it. +- Several new syslog configuration attributes +- A new attribute for stats_socket_level +- A new attribute for retries +- A chefignore file to speed up syncs from the server +- Scientific and oracle as supported platforms in the metadata +- source_url, issues_url, and chef_version metadata +- Enabled why-run support in the default haproxy resource +- New haproxy_config resource +- Guardfile +- Testing in Travis CI with a Rakefile that runs cookstyle, foodcritic, and ChefSpec as well as a Kitchen Dokken config that does integration testing of the package install +- New node['haproxy']['pool_members'] and node['haproxy']['pool_members_option'] attributes + +### Changed + +- The haproxy config is now verified before the service restarts / reloads to prevent taking down haproxy with a bad config +- Update the Kitchen config file to use Bento boxes and new platforms +- Update ChefSpec matchers to use the latest format +- Broke search logic out into a new_discovery recipe + +### Removed + +- Attributes from the metadata file as these are redundant +- Broken tarball validation in the source recipe to prevented installs from completing + +### Fixed + +- Source installs not running if an older version was present on the node +- Resolved all cookstyle and foodcritic warnings + +## v1.6.7 + +### Added + +- ChefSpec matchers and test coverage + +### Changed + +- Replaced references to Opscode with Chef + +## v1.6.6 + +### Changed + +- Parameterize options for admin listener. +- Renamed templates/rhel to templates/redhat. +- Sort pool members by hostname to avoid needless restarts. +- Support amazon linux init script. +- Support to configure global options. + +### Fixed + +- CPU Tuning, corrects cpu_affinity resource triggers + +## v1.6.4 + +## v1.6.2 + +### Added + +- [COOK-3135](https://tickets.chef.io/browse/COOK-3135) - Allow setting of members with default recipe without changing the template. + +### Fixed + +- [COOK-3424](https://tickets.chef.io/browse/COOK-3424) - Haproxy cookbook attempts to alter an immutable attribute. + +## v1.6.0 + +### Added + +- Allow setting of members with default recipe without changing the template. + +## v1.5.0 + +### Added + +- [COOK-3660](https://tickets.chef.io/browse/COOK-3660) - Make haproxy socket default user group configurable +- [COOK-3537](https://tickets.chef.io/browse/COOK-3537) - Add OpenSSL and zlib source configurations +- [COOK-2384](https://tickets.chef.io/browse/COOK-2384) - Add LWRP for multiple haproxy sites/configs + +## v1.4.0 + +### Added + +- [COOK-3237](https://tickets.chef.io/browse/COOK-3237) - Enable cookie-based persistence in a backend +- [COOK-3216](https://tickets.chef.io/browse/COOK-3216) - Metadata attributes +- [COOK-3211](https://tickets.chef.io/browse/COOK-3211) - Support RHEL +- [COOK-3133](https://tickets.chef.io/browse/COOK-3133) - Allow configuration of a global stats socket + +## v1.3.2 + +### Fixed + +- [COOK-3046]: haproxy default recipe broken by COOK-2656. + +### Added + +- [COOK-2009]: Test-kitchen support to haproxy. + +## v1.3.0 + +### Changed + +- [COOK-2656]: Unify the haproxy.cfg with that from `app_lb`. + +### Added + +- [COOK-1488]: Provide an option to build haproxy from source. + +## v1.2.0 + +### Added + +- [COOK-1936] - use frontend / backend logic. +- [COOK-1937] - cleanup for configurations. +- [COOK-1938] - more flexibility for options. +- [COOK-1939] - reloading haproxy is better than restarting. +- [COOK-1940] - haproxy stats listen on 0.0.0.0 by default. +- [COOK-1944] - improve haproxy performance. + +## v1.1.4 + +### Added + +- [COOK-1839] - `httpchk` configuration to `app_lb` template. + +## v1.1.0 + +### Changed + +- [COOK-1275] - haproxy-default.erb should be a cookbook_file. + +### Fixed + +- [COOK-1594] - Template-Service ordering issue in `app_lb` recipe. + +## v1.0.6 + +### Changed + +- [COOK-1310] - Redispatch flag has changed. + +## v1.0.4 + +### Changed + +- [COOK-806] - Load balancer should include an SSL option. +- [COOK-805] - Fundamental haproxy load balancer options should be configurable. + +## v1.0.3 + +### Changed + +- [COOK-620] `haproxy::app_lb`'s template should use the member cloud private IP by default. + +## v1.0.2 + +### Fixed + +- Regression introduced in v1.0.1. + +## v1.0.1 + +### Added + +- Account for the case where load balancer is in the pool. + +## v1.0.0 + +### Changed + +- Use `node.chef_environment` instead of `node['app_environment']`. + +[10.0.0 - *2021-04-24*]: https://github.com/sous-chefs/haproxy/compare/v6.4.0...HEAD +[v3.0.0]: https://github.com/sous-chefs/haproxy/compare/v2.0.2...v3.0.0 +[v3.0.1]: https://github.com/sous-chefs/haproxy/compare/v3.0.0...v3.0.1 +[v3.0.2]: https://github.com/sous-chefs/haproxy/compare/v3.0.1...v3.0.2 +[v3.0.3]: https://github.com/sous-chefs/haproxy/compare/v3.0.2...v3.0.3 +[v3.0.4]: https://github.com/sous-chefs/haproxy/compare/v3.0.3...v3.0.4 +[v4.0.0]: https://github.com/sous-chefs/haproxy/compare/v3.0.4...v4.0.0 +[v4.0.1]: https://github.com/sous-chefs/haproxy/compare/v4.0.0...v4.0.1 +[v4.0.2]: https://github.com/sous-chefs/haproxy/compare/v4.0.1...v4.0.2 +[v4.1.0]: https://github.com/sous-chefs/haproxy/compare/v4.0.2...v4.1.0 +[v4.2.0]: https://github.com/sous-chefs/haproxy/compare/v4.1.0...v4.2.0 +[v4.3.0]: https://github.com/sous-chefs/haproxy/compare/v4.2.0...v4.3.0 +[v4.3.1]: https://github.com/sous-chefs/haproxy/compare/v4.3.0...v4.3.1 +[v4.4.0]: https://github.com/sous-chefs/haproxy/compare/v4.3.1...v4.4.0 +[v4.5.0]: https://github.com/sous-chefs/haproxy/compare/v4.4.0...v4.5.0 +[v4.6.0]: https://github.com/sous-chefs/haproxy/compare/v4.5.0...v4.6.0 +[v4.6.1]: https://github.com/sous-chefs/haproxy/compare/v4.6.0...v4.6.1 +[v5.0.0]: https://github.com/sous-chefs/haproxy/compare/v4.6.1...v5.0.0 +[v5.0.1]: https://github.com/sous-chefs/haproxy/compare/v5.0.0...v5.0.1 +[v5.0.2]: https://github.com/sous-chefs/haproxy/compare/v5.0.1...v5.0.2 +[v5.0.3]: https://github.com/sous-chefs/haproxy/compare/v5.0.2...v5.0.3 +[v5.0.4]: https://github.com/sous-chefs/haproxy/compare/v5.0.3...v5.0.4 +[v6.0.0]: https://github.com/sous-chefs/haproxy/compare/v5.0.4...v6.0.0 +[v6.1.0]: https://github.com/sous-chefs/haproxy/compare/v6.0.0...v6.1.0 +[v6.2.0]: https://github.com/sous-chefs/haproxy/compare/v6.1.0...v6.2.0 +[v6.2.1]: https://github.com/sous-chefs/haproxy/compare/v6.2.0...v6.2.1 +[v6.2.2]: https://github.com/sous-chefs/haproxy/compare/v6.2.1...v6.2.2 +[v6.2.3]: https://github.com/sous-chefs/haproxy/compare/v6.2.2...v6.2.3 +[v6.2.4]: https://github.com/sous-chefs/haproxy/compare/v6.2.3...v6.2.4 +[v6.2.5]: https://github.com/sous-chefs/haproxy/compare/v6.2.4...v6.2.5 +[v6.2.6]: https://github.com/sous-chefs/haproxy/compare/v6.2.5...v6.2.6 +[v6.2.7]: https://github.com/sous-chefs/haproxy/compare/v6.2.6...v6.2.7 +[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 +[v8.1.0]: https://github.com/sous-chefs/haproxy/compare/v8.0.0...v8.1.0 +[v8.1.1]: https://github.com/sous-chefs/haproxy/compare/v8.1.0...v8.1.1 +[v8.2.0]: https://github.com/sous-chefs/haproxy/compare/v8.1.1...v8.2.0 +[v8.3.0]: https://github.com/sous-chefs/haproxy/compare/v8.2.0...v8.3.0 diff --git a/cookbooks/haproxy/LICENSE b/cookbooks/haproxy/LICENSE new file mode 100644 index 00000000..11069edd --- /dev/null +++ b/cookbooks/haproxy/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +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. diff --git a/cookbooks/haproxy/README.md b/cookbooks/haproxy/README.md new file mode 100644 index 00000000..24017f8c --- /dev/null +++ b/cookbooks/haproxy/README.md @@ -0,0 +1,161 @@ +# haproxy Cookbook + +[![CI State](https://github.com/sous-chefs/haproxy/workflows/ci/badge.svg)](https://github.com/sous-chefs/haproxy/actions?query=workflow%3Aci) +[![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.9+ + +### Platforms + +This cookbook officially supports and is tested against the following platforms: + +* debian: 9 & 10 +* ubuntu: 20.04 & 21.04 +* centos: 7 & 8 +* centos-stream: 8 +* fedora: latest +* amazonlinux: 2 + +PRs are welcome to add support for additional platforms. + +### Examples + +Please check for working examples in [TEST](./test/fixtures/cookbooks/test/) + +## Common Resource Features + +HAProxy has many configurable options available, this cookbook makes the most popular options available as resource properties. + +If you wish to use a HAProxy property that is not listed the `extra_options` hash is available to take in any number of additional values. + +For example, the ability to disable listeners is not provided out of the box. Further examples can be found in either `test/fixtures/recipes` or `spec/test/recipes`. If you have questions on how this works or would like to add more examples so it is easier to understand, please come talk to us on the [Chef Community Slack](http://community-slack.chef.io/) on the #sous-chefs channel. + +```ruby +haproxy_listen 'disabled' do + bind '0.0.0.0:1337' + mode 'http' + extra_options('disabled': '') +end +``` + +The `extra_options` hash is of `String => String` or `String => Array`. When an `Array` value is provided. The values are looped over mapping the key to each value in the config. + +For example: + +```ruby +haproxy_listen 'default' do + extra_options( + 'http-request' => [ 'set-header X-Public-User yes', 'del-header X-Bad-Header' ] + ) +end +``` + +Becomes: + +```haproxy +listen default + ... + http-request set-header X-Public-User yes + http-request del-header X-Bad-Header +``` + +## Resources + +* [haproxy_acl](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_acl.md) +* [haproxy_backend](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_backend.md) +* [haproxy_cache](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_cache.md) +* [haproxy_config_defaults](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_config_defaults.md) +* [haproxy_config_global](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_config_global.md) +* [haproxy_fastcgi](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_fastcgi.md) +* [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) +* [haproxy_userlist](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_userlist.md) + +## Configuration Validation + +The `haproxy.cfg` file has a few specific rule orderings that will generate validation errors if not loaded properly. If using any combination of the below rules, avoid the errors by loading the rules via `extra_options` to specify the top down order as noted below in config file. + +### frontend & listen + +```haproxy + tcp-request connection + tcp-request session + tcp-request content + monitor fail + block (deprecated) + http-request + reqxxx (any req excluding reqadd, e.g. reqdeny, reqallow) + reqadd + redirect + use_backend +``` + +```ruby + extra_options( + 'tcp-request' => 'connection set-src src,ipmask(24)', + 'reqdeny' => '^Host:\ .*\.local', + 'reqallow' => '^Host:\ www\.', + 'use_backend' => 'dynamic' + ) +``` + +### backend + +```haproxy + http-request + reqxxx (any req excluding reqadd, e.g. reqdeny, reqallow) + reqadd + redirect +``` + +```ruby + extra_options( + 'http-request' => 'set-path /%[hdr(host)]%[path]', + 'reqdeny' => '^Host:\ .*\.local', + 'reqallow' => '^Host:\ www\.', + 'redirect' => 'dynamic' + ) +``` + +## Contributors + +This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false) + +### Backers + +Thank you to all our backers! + +![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40) + +### 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) diff --git a/cookbooks/haproxy/chefignore b/cookbooks/haproxy/chefignore new file mode 100644 index 00000000..a27b0b25 --- /dev/null +++ b/cookbooks/haproxy/chefignore @@ -0,0 +1,115 @@ +# Put files/directories that should be ignored in this file when uploading +# to a Chef Infra Server or Supermarket. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +ehthumbs.db +Icon? +nohup.out +Thumbs.db +.envrc + +# EDITORS # +########### +.#* +.project +.settings +*_flymake +*_flymake.* +*.bak +*.sw[a-z] +*.tmproj +*~ +\#* +REVISION +TAGS* +tmtags +.vscode +.editorconfig + +## COMPILED ## +############## +*.class +*.com +*.dll +*.exe +*.o +*.pyc +*.so +*/rdoc/ +a.out +mkmf.log + +# Testing # +########### +.circleci/* +.codeclimate.yml +.delivery/* +.foodcritic +.kitchen* +.mdlrc +.overcommit.yml +.rspec +.rubocop.yml +.travis.yml +.watchr +.yamllint +azure-pipelines.yml +Dangerfile +examples/* +features/* +Guardfile +kitchen*.yml +mlc_config.json +Procfile +Rakefile +spec/* +test/* + +# SCM # +####### +.git +.gitattributes +.gitconfig +.github/* +.gitignore +.gitkeep +.gitmodules +.svn +*/.bzr/* +*/.git +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Bundler # +########### +vendor/* +Gemfile +Gemfile.lock + +# Policyfile # +############## +Policyfile.rb +Policyfile.lock.json + +# Documentation # +############# +CODE_OF_CONDUCT* +CONTRIBUTING* +documentation/* +TESTING* +UPGRADING* + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/cookbooks/haproxy/files/haproxy-default b/cookbooks/haproxy/files/haproxy-default new file mode 100644 index 00000000..e69de29b diff --git a/cookbooks/haproxy/libraries/helpers.rb b/cookbooks/haproxy/libraries/helpers.rb new file mode 100644 index 00000000..a85f1246 --- /dev/null +++ b/cookbooks/haproxy/libraries/helpers.rb @@ -0,0 +1,85 @@ +module Haproxy + module Cookbook + module Helpers + def haproxy_version + v = Mixlib::ShellOut.new("haproxy -v | grep version | awk '{ print $3 }'") + v.run_command.stdout.to_f + end + + def source_package_list + case node['platform_family'] + when 'debian' + %w(libpcre3-dev libssl-dev zlib1g-dev libsystemd-dev) + when 'rhel', 'amazon', 'fedora' + %w(pcre-devel openssl-devel zlib-devel systemd-devel) + when 'suse' + %w(pcre-devel libopenssl-devel zlib-devel systemd-devel) + end + end + + def ius_package + { + name: 'ius-release.rpm', + url: 'https://repo.ius.io/ius-release-el7.rpm', + } + end + + def ius_platform_valid? + platform_family?('rhel') && (platform_version.to_i == 6 || platform_version.to_i == 7) + end + + def target_os(source_version) + major_revision = node['kernel']['release'].split('.')[0..1].join('.').to_f + minor_revision = node['kernel']['release'].split('.')[2].split('-').first.to_i + + if major_revision > 2.6 + source_version.chars.first == '1' ? 'linux2628' : 'linux-glibc' + elsif major_revision == 2.6 + if minor_revision >= 28 + source_version.chars.first == '1' ? 'linux2628' : 'linux-glibc' + else + 'linux26' + end + else + 'generic' + end + end + + def systemd_command(bin_prefix) + if haproxy_version < 1.8 + ::File.join(bin_prefix, 'sbin', 'haproxy-systemd-wrapper') + else + ::File.join(bin_prefix, 'sbin', 'haproxy') + ' -Ws' + end + end + + def default_systemd_unit_content + { + 'Unit' => { + 'Description' => 'HAProxy Load Balancer', + 'Documentation' => 'file:/usr/share/doc/haproxy/configuration.txt.gz', + 'After' => %w(network.target syslog.service), + }, + 'Service' => { + 'EnvironmentFile' => '-/etc/default/haproxy', + 'Environment' => "CONFIG=#{config_file} PIDFILE=/run/haproxy.pid", + 'ExecStartPre' => "#{bin_prefix}/sbin/haproxy -f $CONFIG -c -q", + 'ExecStart' => "#{systemd_command(bin_prefix)} -f $CONFIG -p $PIDFILE $OPTIONS", + 'ExecReload' => [ + "#{bin_prefix}/sbin/haproxy -f $CONFIG -c -q", + '/bin/kill -USR2 $MAINPID', + ], + 'KillSignal' => 'TERM', + 'User' => 'root', + 'WorkingDirectory' => '/', + 'KillMode' => 'mixed', + 'Restart' => 'always', + }, + 'Install' => { + 'WantedBy' => 'multi-user.target', + }, + } + end + end + end +end diff --git a/cookbooks/haproxy/libraries/resource.rb b/cookbooks/haproxy/libraries/resource.rb new file mode 100644 index 00000000..9d5f7c90 --- /dev/null +++ b/cookbooks/haproxy/libraries/resource.rb @@ -0,0 +1,52 @@ +module Haproxy + module Cookbook + module ResourceHelpers + def haproxy_config_resource_init + haproxy_config_resource_create unless haproxy_config_resource_exist? + end + + def haproxy_config_resource + return unless haproxy_config_resource_exist? + + find_resource!(:template, new_resource.config_file) + end + + private + + def haproxy_config_resource_exist? + !find_resource!(:template, new_resource.config_file).nil? + rescue Chef::Exceptions::ResourceNotFound + false + end + + def haproxy_config_resource_create + with_run_context(:root) do + declare_resource(:directory, ::File.dirname(new_resource.config_file)) do + owner new_resource.user + group new_resource.group + mode new_resource.config_dir_mode + + recursive true + + action :create + end + + declare_resource(:template, new_resource.config_file) do + cookbook new_resource.cookbook + source new_resource.template + + owner new_resource.user + group new_resource.group + mode new_resource.config_file_mode + sensitive new_resource.sensitive + + helpers(Haproxy::Cookbook::TemplateHelpers) + + action :nothing + delayed_action :create + end + end + end + end + end +end diff --git a/cookbooks/haproxy/libraries/template.rb b/cookbooks/haproxy/libraries/template.rb new file mode 100644 index 00000000..7b6d151e --- /dev/null +++ b/cookbooks/haproxy/libraries/template.rb @@ -0,0 +1,9 @@ +module Haproxy + module Cookbook + module TemplateHelpers + def nil_or_empty?(v) + v.nil? || (v.respond_to?(:empty?) && v.empty?) + end + end + end +end diff --git a/cookbooks/haproxy/metadata.json b/cookbooks/haproxy/metadata.json new file mode 100644 index 00000000..bb64f0e9 --- /dev/null +++ b/cookbooks/haproxy/metadata.json @@ -0,0 +1,40 @@ +{ + "name": "haproxy", + "description": "Installs and configures haproxy", + "long_description": "", + "maintainer": "Sous Chefs", + "maintainer_email": "help@sous-chefs.org", + "license": "Apache-2.0", + "platforms": { + "debian": ">= 0.0.0", + "ubuntu": ">= 0.0.0", + "centos": ">= 0.0.0", + "amazon": ">= 0.0.0", + "opensuseleap": ">= 0.0.0" + }, + "dependencies": { + "yum-epel": ">= 0.0.0" + }, + "providing": { + + }, + "recipes": { + + }, + "version": "12.2.3", + "source_url": "https://github.com/sous-chefs/haproxy", + "issues_url": "https://github.com/sous-chefs/haproxy/issues", + "privacy": false, + "chef_versions": [ + [ + ">= 16" + ] + ], + "ohai_versions": [ + + ], + "gems": [ + + ], + "eager_load_libraries": true +} diff --git a/cookbooks/haproxy/metadata.rb b/cookbooks/haproxy/metadata.rb new file mode 100644 index 00000000..c63eebcf --- /dev/null +++ b/cookbooks/haproxy/metadata.rb @@ -0,0 +1,16 @@ +name 'haproxy' +maintainer 'Sous Chefs' +maintainer_email 'help@sous-chefs.org' +license 'Apache-2.0' +description 'Installs and configures haproxy' +version '12.2.3' +source_url 'https://github.com/sous-chefs/haproxy' +issues_url 'https://github.com/sous-chefs/haproxy/issues' +chef_version '>= 16' + +supports 'debian' +supports 'ubuntu' +supports 'centos' +supports 'amazon' +supports 'opensuseleap' +depends 'yum-epel' diff --git a/cookbooks/haproxy/resources/acl.rb b/cookbooks/haproxy/resources/acl.rb new file mode 100644 index 00000000..1a88bcde --- /dev/null +++ b/cookbooks/haproxy/resources/acl.rb @@ -0,0 +1,40 @@ +use 'partial/_config_file' + +property :acl, [String, Array], + name_property: true, + coerce: proc { |p| Array(p) }, + description: 'The access control list items' + +property :section, String, + required: true, + equal_to: %w(frontend listen backend), + description: 'The section where the acl(s) should be applied' + +property :section_name, String, + required: true, + description: 'The name of the specific frontend, listen or backend section' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables[new_resource.section] ||= {} + + haproxy_config_resource.variables[new_resource.section][new_resource.section_name] ||= {} + + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'] ||= [] + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'].push(new_resource.acl) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables[new_resource.section] ||= {} + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'] ||= [] + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'].delete(new_resource.acl) +end diff --git a/cookbooks/haproxy/resources/backend.rb b/cookbooks/haproxy/resources/backend.rb new file mode 100644 index 00000000..496659f8 --- /dev/null +++ b/cookbooks/haproxy/resources/backend.rb @@ -0,0 +1,82 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :mode, String, + equal_to: %w(http tcp health), + description: 'Set the running mode or protocol of the instance' + +property :server, [String, Array], + coerce: proc { |p| Array(p) }, + description: 'Servers the backend routes to' + +property :tcp_request, [String, Array], + coerce: proc { |p| Array(p) }, + description: 'HAProxy tcp-request settings' + +property :reqrep, [String, Array], + coerce: proc { |p| Array(p) }, + description: 'Replace a regular expression with a string in an HTTP request line' + +property :reqirep, [String, Array], + coerce: proc { |p| Array(p) }, + description: 'reqrep ignoring case' + +property :acl, Array, + description: 'Access control list items' + +property :option, Array, + description: 'Array of HAProxy option directives' + +property :hash_type, String, + equal_to: %w(consistent map-based), + description: 'Specify a method to use for mapping hashes to servers' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['backend'] ||= {} + + haproxy_config_resource.variables['backend'][new_resource.name] ||= {} + haproxy_config_resource.variables['backend'][new_resource.name]['mode'] = new_resource.mode if property_is_set?(:mode) + + if property_is_set?(:server) + haproxy_config_resource.variables['backend'][new_resource.name]['server'] ||= [] + haproxy_config_resource.variables['backend'][new_resource.name]['server'].push(new_resource.server) + end + + if property_is_set?(:tcp_request) + haproxy_config_resource.variables['backend'][new_resource.name]['tcp_request'] ||= [] + haproxy_config_resource.variables['backend'][new_resource.name]['tcp_request'].push(new_resource.tcp_request) + end + + haproxy_config_resource.variables['backend'][new_resource.name]['reqrep'] = new_resource.reqrep.flatten if property_is_set?(:reqrep) + haproxy_config_resource.variables['backend'][new_resource.name]['reqirep'] = new_resource.reqirep.flatten if property_is_set?(:reqirep) + + if property_is_set?(:acl) + haproxy_config_resource.variables['backend'][new_resource.name]['acl'] ||= [] + haproxy_config_resource.variables['backend'][new_resource.name]['acl'].push(new_resource.acl) + end + + if property_is_set?(:option) + haproxy_config_resource.variables['backend'][new_resource.name]['option'] ||= [] + haproxy_config_resource.variables['backend'][new_resource.name]['option'].push(new_resource.option) + end + + haproxy_config_resource.variables['backend'][new_resource.name]['hash_type'] = new_resource.hash_type if property_is_set?(:hash_type) + haproxy_config_resource.variables['backend'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['backend'] ||= {} + + haproxy_config_resource.variables['backend'][new_resource.name] ||= {} + haproxy_config_resource.variables['backend'].delete(new_resource.name) if haproxy_config_resource.variables['backend'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/cache.rb b/cookbooks/haproxy/resources/cache.rb new file mode 100644 index 00000000..8e7b7d23 --- /dev/null +++ b/cookbooks/haproxy/resources/cache.rb @@ -0,0 +1,40 @@ +use 'partial/_config_file' + +property :cache_name, String, + name_property: true, + description: 'Name of the cache' + +property :total_max_size, Integer, + description: 'Define the size in RAM of the cache in megabytes' + +property :max_object_size, Integer, + description: 'Define the maximum size of the objects to be cached' + +property :max_age, Integer, + description: 'Define the maximum expiration duration in seconds' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['cache'] ||= {} + + haproxy_config_resource.variables['cache'][new_resource.cache_name] ||= {} + haproxy_config_resource.variables['cache'][new_resource.cache_name]['total_max_size'] = new_resource.total_max_size if property_is_set?(:total_max_size) + haproxy_config_resource.variables['cache'][new_resource.cache_name]['max_object_size'] = new_resource.max_object_size if property_is_set?(:max_object_size) + haproxy_config_resource.variables['cache'][new_resource.cache_name]['max_age'] = new_resource.max_age if property_is_set?(:max_age) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['cache'] ||= {} + + haproxy_config_resource.variables['cache'][new_resource.cache_name] ||= {} + haproxy_config_resource.variables['cache'].delete(new_resource.cache_name) if haproxy_config_resource.variables['cache'].key?(new_resource.cache_name) +end diff --git a/cookbooks/haproxy/resources/config_defaults.rb b/cookbooks/haproxy/resources/config_defaults.rb new file mode 100644 index 00000000..501880b9 --- /dev/null +++ b/cookbooks/haproxy/resources/config_defaults.rb @@ -0,0 +1,64 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :timeout, Hash, + default: { client: '10s', server: '10s', connect: '10s' }, + description: 'Default HAProxy timeout values' + +property :log, String, + default: 'global', + description: 'Enable per-instance logging of events and traffic' + +property :mode, String, + default: 'http', + equal_to: %w(http tcp health), + description: 'Set the running mode or protocol of the instance' + +property :balance, String, + default: 'roundrobin', + equal_to: %w(roundrobin static-rr leastconn first source uri url_param header rdp-cookie), + description: 'Define the load balancing algorithm to be used in a backend' + +property :option, Array, + default: %w(httplog dontlognull redispatch tcplog), + description: 'Array of HAProxy option directives' + +property :stats, Hash, + default: {}, + description: 'Enable HAProxy statistics' + +property :maxconn, Integer, + description: 'Sets the maximum per-process number of concurrent connections' + +property :haproxy_retries, Integer, + description: 'Set the number of retries to perform on a server after a connection failure' + +property :hash_type, [String, nil], + equal_to: ['consistent', 'map-based', nil], + description: 'Specify a method to use for mapping hashes to servers' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['defaults'] ||= {} + + haproxy_config_resource.variables['defaults']['timeout'] = new_resource.timeout + haproxy_config_resource.variables['defaults']['log'] = new_resource.log + haproxy_config_resource.variables['defaults']['mode'] = new_resource.mode + haproxy_config_resource.variables['defaults']['balance'] = new_resource.balance + + haproxy_config_resource.variables['defaults']['option'] ||= [] + haproxy_config_resource.variables['defaults']['option'].push(new_resource.option).flatten! + + haproxy_config_resource.variables['defaults']['stats'] = new_resource.stats + haproxy_config_resource.variables['defaults']['maxconn'] = new_resource.maxconn.to_s if property_is_set?(:maxconn) + haproxy_config_resource.variables['defaults']['retries'] = new_resource.haproxy_retries.to_s if property_is_set?(:haproxy_retries) + haproxy_config_resource.variables['defaults']['hash_type'] = new_resource.hash_type if property_is_set?(:hash_type) + haproxy_config_resource.variables['defaults']['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end diff --git a/cookbooks/haproxy/resources/config_global.rb b/cookbooks/haproxy/resources/config_global.rb new file mode 100644 index 00000000..827f5c97 --- /dev/null +++ b/cookbooks/haproxy/resources/config_global.rb @@ -0,0 +1,70 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :pidfile, String, + default: '/var/run/haproxy.pid', + description: 'Writes PIDs of all daemons into file ' + +property :log, [String, Array], + default: '/dev/log syslog info', + description: 'Adds a global syslog server' + +property :daemon, [true, false], + default: true, + description: 'Makes the process fork into background' + +property :debug_option, String, + default: 'quiet', + equal_to: %w(quiet debug), + description: 'Sets the debugging mode' + +property :stats, Hash, + default: lazy { + { + socket: "/var/run/haproxy.sock user #{user} group #{group}", + timeout: '2m', + } + }, + description: 'Enable stats with various options' + +property :maxconn, [Integer, String], + default: 4096, + description: 'Sets the maximum per-process number of concurrent connections' + +property :chroot, String, + description: 'Changes current directory to and performs a chroot() there before dropping privileges' + +property :log_tag, String, + default: 'haproxy', + description: 'Specifies the log tag to use for all outgoing logs' + +property :tuning, Hash, + description: 'A hash of tune.' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['global'] ||= {} + + haproxy_config_resource.variables['global']['user'] = new_resource.user + haproxy_config_resource.variables['global']['group'] = new_resource.group + haproxy_config_resource.variables['global']['pidfile'] = new_resource.pidfile + + haproxy_config_resource.variables['global']['log'] ||= [] + haproxy_config_resource.variables['global']['log'].push(new_resource.log) + + haproxy_config_resource.variables['global']['log_tag'] = new_resource.log_tag + haproxy_config_resource.variables['global']['chroot'] = new_resource.chroot if property_is_set?(:chroot) + haproxy_config_resource.variables['global']['daemon'] = new_resource.daemon.to_s + haproxy_config_resource.variables['global']['debug_option'] = new_resource.debug_option + haproxy_config_resource.variables['global']['maxconn'] = new_resource.maxconn + haproxy_config_resource.variables['global']['stats'] = new_resource.stats + haproxy_config_resource.variables['global']['tuning'] = new_resource.tuning if property_is_set?(:tuning) + haproxy_config_resource.variables['global']['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end diff --git a/cookbooks/haproxy/resources/fastcgi.rb b/cookbooks/haproxy/resources/fastcgi.rb new file mode 100644 index 00000000..70729dbb --- /dev/null +++ b/cookbooks/haproxy/resources/fastcgi.rb @@ -0,0 +1,53 @@ +use 'partial/_config_file' + +property :fastcgi, String, + name_property: true, + description: 'Name property - sets the fcgi-app name' + +property :docroot, String, + description: 'Define the document root on the remote host' + +property :index, String, + description: 'Define the script name that will be appended after an URI that ends with a slash' + +property :log_stderr, String, + description: 'Enable logging of STDERR messages reported by the FastCGI application' + +property :option, Array, + description: 'Array of HAProxy option directives' + +property :extra_options, Hash, + description: 'Used for setting any HAProxy directives' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['fastcgi'] ||= {} + + haproxy_config_resource.variables['fastcgi'][new_resource.name] ||= {} + haproxy_config_resource.variables['fastcgi'][new_resource.name]['docroot'] = new_resource.docroot if property_is_set?(:docroot) + haproxy_config_resource.variables['fastcgi'][new_resource.name]['index'] = new_resource.index if property_is_set?(:index) + haproxy_config_resource.variables['fastcgi'][new_resource.name]['log_stderr'] = new_resource.log_stderr if property_is_set?(:log_stderr) + + if property_is_set?(:option) + haproxy_config_resource.variables['fastcgi'][new_resource.name]['option'] ||= [] + haproxy_config_resource.variables['fastcgi'][new_resource.name]['option'].push(new_resource.option) + end + + haproxy_config_resource.variables['fastcgi'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['fastcgi'] ||= {} + + haproxy_config_resource.variables['fastcgi'][new_resource.name] ||= {} + haproxy_config_resource.variables['fastcgi'].delete(new_resource.name) if haproxy_config_resource.variables['fastcgi'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/frontend.rb b/cookbooks/haproxy/resources/frontend.rb new file mode 100644 index 00000000..13746ded --- /dev/null +++ b/cookbooks/haproxy/resources/frontend.rb @@ -0,0 +1,89 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :bind, [String, Hash], + default: '0.0.0.0:80', + description: 'String - sets as given. Hash - joins with a space' + +property :mode, String, + equal_to: %w(http tcp health), + description: 'Set the running mode or protocol of the instance' + +property :maxconn, [Integer, String], + coerce: proc { |p| p.to_s }, + description: 'Sets the maximum per-process number of concurrent connections' + +property :reqrep, [Array, String], + description: 'Replace a regular expression with a string in an HTTP request line' + +property :reqirep, [Array, String], + description: 'reqrep ignoring case' + +property :default_backend, String, + description: 'Specify the backend to use when no "use_backend" rule has been matched' + +property :use_backend, Array, + description: 'Switch to a specific backend if/unless an ACL-based condition is matched' + +property :acl, Array, + description: 'Access control list items' + +property :option, Array, + description: 'Array of HAProxy option directives' + +property :stats, Hash, + description: 'Enable stats with various options' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['frontend'] ||= {} + + haproxy_config_resource.variables['frontend'][new_resource.name] ||= {} + haproxy_config_resource.variables['frontend'][new_resource.name]['bind'] = [] + + if new_resource.bind.is_a?(Hash) + new_resource.bind.map do |addresses, ports| + Array(addresses).product(Array(ports)).each do |combo| + haproxy_config_resource.variables['frontend'][new_resource.name]['bind'].push(combo.join(' ').strip) + end + end + else + haproxy_config_resource.variables['frontend'][new_resource.name]['bind'].push(new_resource.bind) + end + + haproxy_config_resource.variables['frontend'][new_resource.name]['default_backend'] = new_resource.default_backend if property_is_set?(:default_backend) + haproxy_config_resource.variables['frontend'][new_resource.name]['mode'] = new_resource.mode if property_is_set?(:mode) + haproxy_config_resource.variables['frontend'][new_resource.name]['stats'] = new_resource.stats if property_is_set?(:stats) + haproxy_config_resource.variables['frontend'][new_resource.name]['maxconn'] = new_resource.maxconn if property_is_set?(:maxconn) + haproxy_config_resource.variables['frontend'][new_resource.name]['reqrep'] = [new_resource.reqrep].flatten if property_is_set?(:reqrep) + haproxy_config_resource.variables['frontend'][new_resource.name]['reqirep'] = [new_resource.reqirep].flatten if property_is_set?(:reqirep) + haproxy_config_resource.variables['frontend'][new_resource.name]['use_backend'] = new_resource.use_backend if property_is_set?(:use_backend) + + if property_is_set?(:acl) + haproxy_config_resource.variables['frontend'][new_resource.name]['acl'] ||= [] + haproxy_config_resource.variables['frontend'][new_resource.name]['acl'].push(new_resource.acl) + end + + if property_is_set?(:option) + haproxy_config_resource.variables['frontend'][new_resource.name]['option'] ||= [] + haproxy_config_resource.variables['frontend'][new_resource.name]['option'].push(new_resource.option) + end + + haproxy_config_resource.variables['frontend'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['frontend'] ||= {} + + haproxy_config_resource.variables['frontend'][new_resource.name] ||= {} + haproxy_config_resource.variables['frontend'].delete(new_resource.name) if haproxy_config_resource.variables['frontend'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/install.rb b/cookbooks/haproxy/resources/install.rb new file mode 100644 index 00000000..bf8d226c --- /dev/null +++ b/cookbooks/haproxy/resources/install.rb @@ -0,0 +1,182 @@ +include Haproxy::Cookbook::Helpers + +use 'partial/_config_file' + +property :install_type, String, + name_property: true, + equal_to: %w(package source), + description: 'Set the installation type' + +property :bin_prefix, String, + default: '/usr', + description: 'Set the source compile prefix' + +property :sensitive, [true, false], + default: true, + description: 'Ensure that sensitive resource data is not logged by the chef-client' + +# Package +property :package_name, String, + default: 'haproxy' + +property :package_version, [String, nil] + +property :enable_ius_repo, [true, false], + default: false, + description: 'Enables the IUS package repo for Centos to install versions >1.5' + +property :enable_epel_repo, [true, false], + default: true, + description: 'Enables the epel repo for RHEL based operating systems' + +# Source +property :source_version, String, + default: '2.2.4' + +property :source_url, String, + default: lazy { "https://www.haproxy.org/download/#{source_version.to_f}/src/haproxy-#{source_version}.tar.gz" } + +property :source_checksum, String, + default: '87a4d9d4ff8dc3094cb61bbed4a8eed2c40b5ac47b9604daebaf036d7b541be2' + +property :source_target_cpu, String, + default: lazy { node['kernel']['machine'] } + +property :source_target_arch, String + +property :source_target_os, String, + default: lazy { target_os(source_version) } + +property :use_libcrypt, [true, false], + default: true + +property :use_pcre, [true, false], + default: true + +property :use_promex, [true, false], + default: false + +property :use_openssl, [true, false], + default: true + +property :use_zlib, [true, false], + default: true + +property :use_linux_tproxy, [true, false], + default: true + +property :use_linux_splice, [true, false], + default: true + +property :use_lua, [true, false], + default: false + +property :lua_lib, String + +property :lua_inc, String + +property :ssl_lib, String + +property :ssl_inc, String + +property :use_systemd, [true, false], + default: lazy { source_version.to_f >= 1.8 }, + description: 'Evalues whether to use systemd based on the nodes init package' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action_class do + include Haproxy::Cookbook::Helpers + include Haproxy::Cookbook::ResourceHelpers + + def compile_make_boolean(bool) + bool ? '1' : '0' + end +end + +action :install do + case new_resource.install_type + when 'package' + case node['platform_family'] + when 'amazon' + include_recipe 'yum-epel' if new_resource.enable_epel_repo + when 'rhel' + include_recipe 'yum-epel' if new_resource.enable_epel_repo + + if new_resource.enable_ius_repo + if ius_platform_valid? + puts ius_package[:url] + + remote_file ::File.join(Chef::Config[:file_cache_path], ius_package[:name]) do + source ius_package[:url] + only_if { new_resource.enable_ius_repo } + end + + package ius_package[:name] do + source ::File.join(Chef::Config[:file_cache_path], ius_package[:name]) + only_if { new_resource.enable_ius_repo } + end + else + log 'This platform is not supported by IUS, ignoring enable_ius_repo property' do + level :warn + end + end + end + end + + package new_resource.package_name do + version new_resource.package_version if new_resource.package_version + end + when 'source' + build_essential 'compilation tools' + package source_package_list + + remote_file 'haproxy source file' do + path ::File.join(Chef::Config[:file_cache_path], "haproxy-#{new_resource.source_version}.tar.gz") + source new_resource.source_url + checksum new_resource.source_checksum if new_resource.source_checksum + action :create + end + + make_cmd = "make TARGET=#{new_resource.source_target_os}" + make_cmd << " CPU=#{new_resource.source_target_cpu}" if property_is_set?(:source_target_cpu) + make_cmd << " ARCH=#{new_resource.source_target_arch}" if property_is_set?(:source_target_arch) + make_cmd << " USE_LIBCRYPT=#{compile_make_boolean(new_resource.use_libcrypt)}" + make_cmd << " USE_PCRE=#{compile_make_boolean(new_resource.use_pcre)}" + make_cmd << " USE_OPENSSL=#{compile_make_boolean(new_resource.use_openssl)}" + make_cmd << " USE_ZLIB=#{compile_make_boolean(new_resource.use_zlib)}" + make_cmd << " USE_LINUX_TPROXY=#{compile_make_boolean(new_resource.use_linux_tproxy)}" + make_cmd << " USE_LINUX_SPLICE=#{compile_make_boolean(new_resource.use_linux_splice)}" + make_cmd << " USE_SYSTEMD=#{compile_make_boolean(new_resource.use_systemd)}" + make_cmd << " USE_LUA=#{compile_make_boolean(new_resource.use_lua)}" if new_resource.use_lua + make_cmd << " USE_PROMEX=#{compile_make_boolean(new_resource.use_promex)}" if new_resource.use_promex + make_cmd << " LUA_LIB=#{new_resource.lua_lib}" if property_is_set?(:lua_lib) + make_cmd << " LUA_INC=#{new_resource.lua_inc}" if property_is_set?(:lua_inc) + make_cmd << " SSL_LIB=#{new_resource.ssl_lib}" if property_is_set?(:ssl_lib) + make_cmd << " SSL_INC=#{new_resource.ssl_inc}" if property_is_set?(:ssl_inc) + extra_cmd = ' EXTRA=haproxy-systemd-wrapper' if new_resource.source_version.to_f < 1.8 + + bash 'compile_haproxy' do + cwd Chef::Config[:file_cache_path] + code <<-EOH + tar xzf haproxy-#{new_resource.source_version}.tar.gz + cd haproxy-#{new_resource.source_version} + #{make_cmd} && make install PREFIX=#{new_resource.bin_prefix} #{extra_cmd} + EOH + not_if "#{::File.join(new_resource.bin_prefix, 'sbin', 'haproxy')} -v | grep #{new_resource.source_version}" + end + end + + with_run_context :root do + group new_resource.group + + user new_resource.user do + home "/home/#{new_resource.user}" + group new_resource.group + end + end +end diff --git a/cookbooks/haproxy/resources/listen.rb b/cookbooks/haproxy/resources/listen.rb new file mode 100644 index 00000000..f7e145fa --- /dev/null +++ b/cookbooks/haproxy/resources/listen.rb @@ -0,0 +1,109 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :bind, [String, Hash], + default: '0.0.0.0:80', + description: 'String - sets as given. Hash - joins with a space' + +property :mode, String, + equal_to: %w(http tcp health), + description: 'Set the running mode or protocol of the instance' + +property :maxconn, Integer, + description: 'Sets the maximum per-process number of concurrent connections' + +property :stats, Hash, + description: 'Enable stats with various options' + +property :http_request, [Array, String], + coerce: proc { |p| Array(p).flatten }, + description: 'Switch to a specific backend if/unless an ACL-based condition is matched' + +property :http_response, String, + description: 'Switch to a specific backend if/unless an ACL-based condition is matched' + +property :reqrep, [Array, String], + coerce: proc { |p| Array(p).flatten }, + description: 'Replace a regular expression with a string in an HTTP request line' + +property :reqirep, [Array, String], + coerce: proc { |p| Array(p).flatten }, + description: 'reqrep ignoring case' + +property :default_backend, String, + description: 'Specify the backend to use when no "use_backend" rule has been matched' + +property :use_backend, Array, + description: 'Switch to a specific backend if/unless an ACL-based condition is matched' + +property :acl, Array, + description: 'Access control list items' + +property :server, Array, + description: 'Servers the listen section routes to' + +property :hash_type, String, + equal_to: %w(consistent map-based), + description: 'Specify a method to use for mapping hashes to servers' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['listen'] ||= {} + + haproxy_config_resource.variables['listen'][new_resource.name] ||= {} + haproxy_config_resource.variables['listen'][new_resource.name]['bind'] ||= [] + + if new_resource.bind.is_a?(Hash) + new_resource.bind.map do |addresses, ports| + Array(addresses).product(Array(ports)).each do |combo| + haproxy_config_resource.variables['listen'][new_resource.name]['bind'].push(combo.join(' ').strip) + end + end + else + haproxy_config_resource.variables['listen'][new_resource.name]['bind'].push(new_resource.bind) + end + + haproxy_config_resource.variables['listen'][new_resource.name]['mode'] = new_resource.mode if property_is_set?(:mode) + haproxy_config_resource.variables['listen'][new_resource.name]['maxconn'] = new_resource.maxconn.to_s if property_is_set?(:mode) + haproxy_config_resource.variables['listen'][new_resource.name]['stats'] = new_resource.stats if property_is_set?(:stats) + haproxy_config_resource.variables['listen'][new_resource.name]['http_request'] = new_resource.http_request if property_is_set?(:http_request) + haproxy_config_resource.variables['listen'][new_resource.name]['http_response'] = new_resource.http_response if property_is_set?(:http_response) + haproxy_config_resource.variables['listen'][new_resource.name]['reqrep'] = new_resource.reqrep if property_is_set?(:reqrep) + haproxy_config_resource.variables['listen'][new_resource.name]['reqirep'] = new_resource.reqirep if property_is_set?(:reqirep) + + if property_is_set?(:use_backend) + haproxy_config_resource.variables['listen'][new_resource.name]['use_backend'] ||= [] + haproxy_config_resource.variables['listen'][new_resource.name]['use_backend'].push(new_resource.use_backend) + end + + if property_is_set?(:acl) + haproxy_config_resource.variables['listen'][new_resource.name]['acl'] ||= [] + haproxy_config_resource.variables['listen'][new_resource.name]['acl'].push(new_resource.acl) + end + + haproxy_config_resource.variables['listen'][new_resource.name]['default_backend'] = new_resource.default_backend if property_is_set?(:default_backend) + + if property_is_set?(:server) + haproxy_config_resource.variables['listen'][new_resource.name]['server'] ||= [] + haproxy_config_resource.variables['listen'][new_resource.name]['server'].push(new_resource.server) + end + + haproxy_config_resource.variables['listen'][new_resource.name]['hash_type'] = new_resource.hash_type if property_is_set?(:hash_type) + haproxy_config_resource.variables['listen'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['listen'] ||= {} + + haproxy_config_resource.variables['listen'][new_resource.name] ||= {} + haproxy_config_resource.variables['listen'].delete(new_resource.name) if haproxy_config_resource.variables['listen'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/mailer.rb b/cookbooks/haproxy/resources/mailer.rb new file mode 100644 index 00000000..0d4b3c7b --- /dev/null +++ b/cookbooks/haproxy/resources/mailer.rb @@ -0,0 +1,33 @@ +use 'partial/_config_file' + +property :mailer, [String, Array], + coerce: proc { |p| Array(p).flatten }, + 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' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['mailer'] ||= {} + + haproxy_config_resource.variables['mailer'][new_resource.name] ||= {} + haproxy_config_resource.variables['mailer'][new_resource.name]['mailer'] = new_resource.mailer if property_is_set?(:mailer) + haproxy_config_resource.variables['mailer'][new_resource.name]['timeout'] = new_resource.timeout if property_is_set?(:timeout) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['mailer'] ||= {} + + haproxy_config_resource.variables['mailer'][new_resource.name] ||= {} + haproxy_config_resource.variables['mailer'].delete(new_resource.name) if haproxy_config_resource.variables['mailer'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/partial/_config_file.rb b/cookbooks/haproxy/resources/partial/_config_file.rb new file mode 100644 index 00000000..4a09b51a --- /dev/null +++ b/cookbooks/haproxy/resources/partial/_config_file.rb @@ -0,0 +1,35 @@ +property :user, String, + default: 'haproxy', + description: 'Set to override default haproxy user, defaults to haproxy' + +property :group, String, + default: 'haproxy', + description: 'Set to override default haproxy group, defaults to haproxy' + +property :config_dir, String, + default: '/etc/haproxy', + desired_state: false, + description: 'Set to override vault configuration directory' + +property :config_dir_mode, String, + default: '0750', + description: 'Set to override haproxy config dir mode, defaults to 0750' + +property :config_file, String, + default: lazy { ::File.join(config_dir, 'haproxy.cfg') }, + desired_state: false, + description: 'Set to override vault configuration file, defaults to /etc/{CONFIG_DIR}/haproxy.cfg' + +property :config_file_mode, String, + default: '0640', + description: 'Set to override default haproxy config file mode, defaults to 0640' + +property :cookbook, String, + default: 'haproxy', + desired_state: false, + description: 'Template source cookbook for the haproxy configuration file' + +property :template, String, + default: 'haproxy.cfg.erb', + desired_state: false, + description: 'Template source file for the haproxy configuration file' diff --git a/cookbooks/haproxy/resources/partial/_extra_options.rb b/cookbooks/haproxy/resources/partial/_extra_options.rb new file mode 100644 index 00000000..abccb58f --- /dev/null +++ b/cookbooks/haproxy/resources/partial/_extra_options.rb @@ -0,0 +1,2 @@ +property :extra_options, Hash, + description: 'Used for setting any HAProxy directives' diff --git a/cookbooks/haproxy/resources/peer.rb b/cookbooks/haproxy/resources/peer.rb new file mode 100644 index 00000000..c0c27c6b --- /dev/null +++ b/cookbooks/haproxy/resources/peer.rb @@ -0,0 +1,61 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :bind, [String, Hash], + description: 'String - sets as given. Hash - joins with a space. HAProxy version >= 2.0' + +property :state, String, + equal_to: %w(enabled disabled), + description: 'Set the state of the peers' + +property :server, Array, + description: 'Servers in the peer' + +property :default_bind, String, + description: 'Defines the binding parameters for the local peer, excepted its address' + +property :default_server, String, + description: 'Change default options for a server' + +property :table, Array, + description: 'Configure a stickiness table' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['peer'] ||= {} + + haproxy_config_resource.variables['peer'][new_resource.name] ||= {} + haproxy_config_resource.variables['peer'][new_resource.name]['bind'] = new_resource.bind if property_is_set?(:bind) + haproxy_config_resource.variables['peer'][new_resource.name]['state'] = new_resource.state if property_is_set?(:state) + + if property_is_set?(:server) + haproxy_config_resource.variables['peer'][new_resource.name]['server'] ||= [] + haproxy_config_resource.variables['peer'][new_resource.name]['server'].push(new_resource.server) + end + + haproxy_config_resource.variables['peer'][new_resource.name]['default_bind'] = new_resource.default_bind if property_is_set?(:default_bind) + haproxy_config_resource.variables['peer'][new_resource.name]['default_server'] = new_resource.default_server if property_is_set?(:default_server) + + if property_is_set?(:table) + haproxy_config_resource.variables['peer'][new_resource.name]['table'] ||= [] + haproxy_config_resource.variables['peer'][new_resource.name]['table'].push(new_resource.table) + end + + haproxy_config_resource.variables['peer'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['peer'] ||= {} + + haproxy_config_resource.variables['peer'][new_resource.name] ||= {} + haproxy_config_resource.variables['peer'].delete(new_resource.name) if haproxy_config_resource.variables['peer'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/resolver.rb b/cookbooks/haproxy/resources/resolver.rb new file mode 100644 index 00000000..7eee0458 --- /dev/null +++ b/cookbooks/haproxy/resources/resolver.rb @@ -0,0 +1,35 @@ +use 'partial/_config_file' +use 'partial/_extra_options' + +property :nameserver, Array, + description: 'DNS server description' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['resolvers'] ||= {} + + haproxy_config_resource.variables['resolvers'][new_resource.name] ||= {} + + if property_is_set?(:nameserver) + haproxy_config_resource.variables['resolvers'][new_resource.name]['nameserver'] ||= [] + haproxy_config_resource.variables['resolvers'][new_resource.name]['nameserver'].push(new_resource.nameserver) + end + + haproxy_config_resource.variables['resolvers'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['resolvers'] ||= {} + + haproxy_config_resource.variables['resolvers'][new_resource.name] ||= {} + haproxy_config_resource.variables['resolvers'].delete(new_resource.name) if haproxy_config_resource.variables['resolvers'].key?(new_resource.name) +end diff --git a/cookbooks/haproxy/resources/service.rb b/cookbooks/haproxy/resources/service.rb new file mode 100644 index 00000000..50314f0f --- /dev/null +++ b/cookbooks/haproxy/resources/service.rb @@ -0,0 +1,91 @@ +include Haproxy::Cookbook::Helpers + +use 'partial/_config_file' + +property :bin_prefix, String, + default: '/usr', + description: 'Bin location of the haproxy binary, defaults to /usr' + +property :service_name, String, + default: 'haproxy' + +property :systemd_unit_content, [String, Hash], + default: lazy { default_systemd_unit_content }, + description: 'HAProxy systemd unit contents' + +property :config_test, [true, false], + default: true, + description: 'Perform configuration file test before performing service action' + +property :config_test_fail_action, Symbol, + equal_to: %i(raise log), + default: :raise, + description: 'Action to perform upon configuration test failure.' + +unified_mode true + +action_class do + include Haproxy::Cookbook::Helpers + + def do_service_action(resource_action) + with_run_context(:root) do + if %i(start restart reload).include?(resource_action) + begin + if new_resource.config_test && ::File.exist?(new_resource.config_file) + log 'Running configuration test' + cmd = Mixlib::ShellOut.new("#{systemd_command(new_resource.bin_prefix)} -c -V -f #{new_resource.config_file}") + cmd.run_command.error! + Chef::Log.info("Configuration test passed, creating #{new_resource.service_name} #{new_resource.declared_type} resource with action #{resource_action}") + elsif new_resource.config_test && !::File.exist?(new_resource.config_file) + log 'Configuration test is enabled but configuration file does not exist, skipping test' do + level :warn + end + else + Chef::Log.info("Configuration test disabled, creating #{new_resource.service_name} #{new_resource.declared_type} resource with action #{resource_action}") + end + + declare_resource(:service, new_resource.service_name).delayed_action(resource_action) + rescue Mixlib::ShellOut::ShellCommandFailed + if new_resource.config_test_fail_action.eql?(:log) + Chef::Log.error("Configuration test failed, #{new_resource.service_name} #{resource_action} action aborted!\n\n"\ + "Error\n-----\n#{cmd.stderr}") + else + raise "Configuration test failed, #{new_resource.service_name} #{resource_action} action aborted!\n\n"\ + "Error\n-----\nAction: #{resource_action}\n#{cmd.stderr}" + end + end + else + declare_resource(:service, new_resource.service_name).delayed_action(resource_action) + end + end + end +end + +action :create do + with_run_context :root do + declare_resource(:cookbook_file, '/etc/default/haproxy') do + cookbook 'haproxy' + source 'haproxy-default' + owner 'root' + group 'root' + mode '0644' + end + + declare_resource(:systemd_unit, "#{new_resource.service_name}.service") do + content new_resource.systemd_unit_content + triggers_reload true + action :create + end + end +end + +action :delete do + with_run_context :root do + declare_resource(:cookbook_file, '/etc/default/haproxy').action(:delete) + declare_resource(:systemd_unit, "#{new_resource.service_name}.service").action(:delete) + end +end + +%i(start stop restart reload enable disable).each do |action_type| + send(:action, action_type) { do_service_action(action) } +end diff --git a/cookbooks/haproxy/resources/use_backend.rb b/cookbooks/haproxy/resources/use_backend.rb new file mode 100644 index 00000000..0464043e --- /dev/null +++ b/cookbooks/haproxy/resources/use_backend.rb @@ -0,0 +1,43 @@ +use 'partial/_config_file' + +property :use_backend, [String, Array], + name_property: true, + coerce: proc { |p| Array(p) }, + description: 'Switch to a specific backend if/unless an ACL-based condition is matched' + +property :section, String, + required: true, + equal_to: %w(frontend listen backend), + description: 'The section where the acl(s) should be applied' + +property :section_name, String, + required: true, + description: 'The name of the specific frontend, listen or backend section' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables[new_resource.section] ||= {} + + haproxy_config_resource.variables[new_resource.section][new_resource.section_name] ||= {} + + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'] ||= [] + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'].push(new_resource.use_backend) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables[new_resource.section] ||= {} + + haproxy_config_resource.variables[new_resource.section][new_resource.section_name] ||= {} + + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'] ||= [] + haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'].delete(new_resource.use_backend) +end diff --git a/cookbooks/haproxy/resources/userlist.rb b/cookbooks/haproxy/resources/userlist.rb new file mode 100644 index 00000000..5e9b2bdb --- /dev/null +++ b/cookbooks/haproxy/resources/userlist.rb @@ -0,0 +1,35 @@ +use 'partial/_config_file' + +property :group, Hash, + description: 'Adds group to the current userlist' + +property :user, Hash, + description: 'Adds user to the current userlist' + +unified_mode true + +action_class do + include Haproxy::Cookbook::ResourceHelpers +end + +action :create do + haproxy_config_resource_init + + haproxy_config_resource.variables['userlist'] ||= {} + haproxy_config_resource.variables['userlist'][new_resource.name] ||= {} + haproxy_config_resource.variables['userlist'][new_resource.name]['group'] ||= [] + haproxy_config_resource.variables['userlist'][new_resource.name]['group'].push(new_resource.group) if property_is_set?(:group) + haproxy_config_resource.variables['userlist'][new_resource.name]['user'] ||= [] + haproxy_config_resource.variables['userlist'][new_resource.name]['user'].push(new_resource.user) if property_is_set?(:user) +end + +action :delete do + haproxy_config_resource_init + + haproxy_config_resource.variables['userlist'] ||= {} + haproxy_config_resource.variables['userlist'][new_resource.name] ||= {} + haproxy_config_resource.variables['userlist'][new_resource.name]['group'] ||= [] + haproxy_config_resource.variables['userlist'][new_resource.name]['group'].delete(new_resource.group) + haproxy_config_resource.variables['userlist'][new_resource.name]['user'] ||= [] + haproxy_config_resource.variables['userlist'][new_resource.name]['user'].delete(new_resource.user) +end diff --git a/cookbooks/haproxy/templates/default/haproxy.cfg.erb b/cookbooks/haproxy/templates/default/haproxy.cfg.erb new file mode 100644 index 00000000..8744e2a2 --- /dev/null +++ b/cookbooks/haproxy/templates/default/haproxy.cfg.erb @@ -0,0 +1,462 @@ +<% unless nil_or_empty?(@global) %> +global + user <%= @global['user'] %> + group <%= @global['group'] %> +<% if @global['pid_file'] -%> + pidfile <%= @global['pid_file'] %> +<% end %> +<% if @global['log'] && @global['log'].is_a?(Array)-%> +<% @global['log'].each do | logvar | -%> +<% if logvar && logvar.is_a?(Array)-%> +<% logvar.each do | log | -%> + log <%= log %> +<% end -%> +<% else -%> + log <%= logvar %> +<% end -%> +<% end -%> +<% end -%> +<% if @global['log_tag'] -%> + log-tag <%= @global['log_tag'] %> +<% end -%> +<% if @global['chroot'] -%> + chroot <%= @global['chroot'] %> +<% end -%> +<% if @global['daemon'].eql? 'true' -%> + daemon +<% end -%> + <%= @global['debug_option'] %> +<% @global['stats']&.each do |option, value| -%> + stats <%= option %> <%= value %> +<% end -%> +<% unless nil_or_empty?(@global['maxconn']) -%> + maxconn <%= @global['maxconn'] %> +<% end -%> +<% if @global['pidfile'] -%> + pidfile <%= @global['pidfile'] %> +<% end -%> +<% unless nil_or_empty?(@global['tuning']) %> +<% @global['tuning'].each do | option, value | -%> + tune.<%= option %> <%= value %> +<% end -%> +<% end -%> +<% unless nil_or_empty?(@global['extra_options']) -%> +<% @global['extra_options'].each do | option, value | -%> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= option %> <%= array_element %> +<% end -%> +<% else %> + <%= option %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(@resolvers) %> +<% @resolvers.each do |resolver, r | %> + + +resolvers <%= resolver %> +<% unless nil_or_empty?(r['nameserver']) %> +<% r['nameserver'].each do | s |%> +<% s.each do |nameserver|%> + nameserver <%= nameserver %> +<% end -%> +<% end -%> +<% end -%> +<% r['extra_options'].each do | option, value | -%> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= option %> <%= array_element %> +<% end -%> +<% else %> + <%= option %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(@defaults) %> + + +defaults +<% @defaults['timeout'].each do | key, timeout | -%> + timeout <%= key %> <%= timeout %> +<% end -%> + log <%= @defaults['log'] %> + mode <%= @defaults['mode'] %> +<% unless nil_or_empty?(@defaults['balance']) -%> + balance <%= @defaults['balance'] %> +<% end -%> +<% if @defaults['hash_type'] -%> + hash-type <%= @defaults['hash_type'] %> +<% end -%> +<% @defaults['option'].each do | option | -%> + option <%= option %> +<% end -%> +<% unless nil_or_empty?(@defaults['maxconn']) -%> + maxconn <%= @defaults['maxconn'] %> +<% end -%> +<% unless nil_or_empty?(@defaults['retries']) -%> + retries <%= @defaults['retries'] %> +<% end -%> +<% @defaults['stats']&.each do |option, value| -%> + stats <%= option %> <%= value %> +<% end -%> +<% unless nil_or_empty?(@defaults['extra_options']) %> +<% @defaults['extra_options'].each do | option, value | -%> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= option %> <%= array_element %> +<% end -%> +<% else %> + <%= option %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(@cache) %> +<% @cache.each do |cache, c | %> + + +cache <%= cache %> +<% unless nil_or_empty?(c['total_max_size']) -%> + total-max-size <%= c['total_max_size'] %> +<% end -%> +<% unless nil_or_empty?(c['max_object_size']) %> + max-object-size <%= c['max_object_size'] %> +<% end -%> +<% unless nil_or_empty?(c['max_age']) %> + max-age <%= c['max_age'] %> +<% end -%> +<% end # cache loop -%> +<% end # cache -%> +<% unless nil_or_empty?(@userlist) %> +<% @userlist.each do |userlist, u| %> + + +userlist <%= userlist %> +<% u.each do |type,i| -%> +<% i.each do |item| -%> +<% item.each do |k,v| %> + <%= type %> <%=k%> <%= v %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(@peer) %> +<% @peer.each do |peer, pv | %> + +peers <%= peer %> +<% if pv['bind'].is_a?(Hash) -%> +<% pv['bind'].each do |k, v| -%> + bind <%= "#{k} #{v}".strip %> +<% end -%> +<% else -%> + bind <%= pv['bind'] %> +<% end -%> +<% unless nil_or_empty?(pv['state']) %> + <%= pv['state'] %> +<% end -%> +<% unless nil_or_empty?(pv['server']) %> +<% pv['server'].each do | s |%> +<% s.each do |server|%> + server <%= server %> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(pv['default_bind']) %> + default-bind <%= pv['default_bind'] %> +<% end -%> +<% unless nil_or_empty?(pv['default_server']) %> + default-server <%= pv['default_server'] %> +<% end -%> +<% unless nil_or_empty?(pv['table']) %> +<% pv['table'].each do | t |%> +<% t.each do |table|%> + table <%= table %> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(pv['extra_options']) %> +<% pv['extra_options'].each do | key, value |%> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end # peers loop -%> +<% end # peers -%> +<% unless nil_or_empty?(@mailer) %> +<% @mailer.each do |mailer, m | %> + +mailers <%= mailer %> +<% unless nil_or_empty?(m['mailer']) -%> +<% m['mailer'].each do |mail| -%> + mailer <%= mail %> +<% end -%> +<% end -%> +<% unless nil_or_empty?(m['timeout']) %> + timeout mail <%= m['timeout'] %> +<% end -%> +<% end # mailers loop -%> +<% end # mailers -%> +<% unless nil_or_empty?(@fastcgi) %> +<% @fastcgi.each do |fastcgi, f | %> + + +fcgi-app <%= fastcgi %> +<% unless nil_or_empty?(f['docroot']) %> + docroot <%= f['docroot'] %> +<% end -%> +<% unless nil_or_empty?(f['index']) %> + index <%= f['index'] %> +<% end -%> +<% unless nil_or_empty?(f['log_stderr']) %> + log-stderr <%= f['log_stderr'] %> +<% end -%> +<% unless nil_or_empty?(f['option']) %> +<% f['option'].each do | option |%> +<% option.each do | option | %> + option <%= option %> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(f['extra_options']) %> +<% f['extra_options'].each do | key, value | %> +<% unless key == 'http-request' %> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% end # fastcgi loop -%> +<% end # fastcgi -%> +<% unless nil_or_empty?(@frontend) %> +<% @frontend.each do |frontend, f | %> + + +frontend <%= frontend %> +<% unless nil_or_empty?(f['mode']) -%> + mode <%= f['mode'] %> +<% end -%> +<% unless nil_or_empty?(f['default_backend']) %> + default_backend <%= f['default_backend'] %> +<% end -%> +<% f['bind'].each do |binding| -%> + bind <%= binding %> +<% end -%> +<% unless nil_or_empty?(f['maxconn']) -%> + maxconn <%= f['maxconn'] %> +<% end -%> +<% f['stats']&.each do |option, value| -%> + stats <%= option %> <%= value %> +<% end -%> +<% unless nil_or_empty?(f['acl']) %> +<% f['acl'].flatten.uniq.each do | acl |%> + acl <%= acl %> +<% end -%> +<% end -%> +<% if f['reqrep'] -%> +<% f['reqrep'].each do |reqrep| %> + reqrep <%= reqrep %> +<% end -%> +<% end %> +<% if f['reqirep'] -%> +<% f['reqirep'].each do |reqirep| %> + reqirep <%= reqirep %> +<% end -%> +<% end %> +<% unless nil_or_empty?(f['extra_options']) %> +<% f['extra_options'].each do | key, value | %> +<% if key == 'http-request' %> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(f['use_backend']) %> +<% f['use_backend'].flatten.uniq.each do | backend |%> + use_backend <%= backend %> +<% end -%> +<% end -%> +<% unless nil_or_empty?(f['option']) %> +<% f['option'].each do | option |%> +<% option.each do | option | %> + option <%= option %> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(f['extra_options']) %> +<% f['extra_options'].each do | key, value | %> +<% unless key == 'http-request' %> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% end # frontend loop -%> +<% end # frontend -%> +<% unless nil_or_empty?(@backend) %> +<% @backend.each do | key, backend | %> + + +backend <%= key %> +<% unless nil_or_empty?(backend['mode']) -%> + mode <%= backend['mode'] %> +<% end -%> +<% unless nil_or_empty?(backend['server']) %> +<% backend['server'].each do | s |%> +<% s.each do |server|%> + server <%= server %> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(backend['acl']) %> +<% backend['acl'].flatten.uniq.each do | acl |%> + acl <%= acl %> +<% end -%> +<% end -%> +<% unless nil_or_empty?(backend['option']) %> +<% backend['option'].each do | option |%> +<% option.each do | option | %> + option <%= option %> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(backend['tcp_request']) %> +<% backend['tcp_request'].each do | tcp_request |%> +<% tcp_request.each do | tcp_request | %> + tcp-request <%= tcp_request %> +<% end -%> +<% end -%> +<% end -%> +<% if backend['hash_type'] -%> + hash-type <%= backend['hash_type'] %> +<% end -%> +<% if backend['reqrep'] -%> +<% backend['reqrep'].each do |reqrep| %> + reqrep <%= reqrep %> +<% end -%> +<% end %> +<% if backend['reqirep'] -%> +<% backend['reqirep'].each do |reqirep| %> + reqirep <%= reqirep %> +<% end -%> +<% end %> +<% unless nil_or_empty?(backend['extra_options']) %> +<% backend['extra_options'].each do | key, value |%> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end # backend loop -%> +<% end # backend -%> +<% unless nil_or_empty?(@listen) %> +<% @listen.each do | key, listen |%> + + +listen <%= key %> +<% unless nil_or_empty?(listen['mode']) -%> + mode <%= listen['mode']%> +<% end -%> +<% listen['bind'].each do |binding| -%> + bind <%= binding %> +<% end -%> +<% unless nil_or_empty?(listen['maxconn']) -%> + maxconn <%= listen['maxconn']%> +<% end -%> +<% listen['stats']&.each do |option, value| -%> + stats <%= option %> <%= value %> +<% end -%> +<% unless nil_or_empty?(listen['acl']) %> +<% listen['acl'].flatten.uniq.each do | acl |%> + acl <%= acl %> +<% end -%> +<% end -%> +<% if listen['http_request'] -%> +<% listen['http_request'].each do |http_request| %> + http-request <%= http_request %> +<% end -%> +<% end %> +<% if listen['http_response'] -%> + http-response <%= listen['http_response'] %> +<% end %> +<% if listen['reqrep'] -%> +<% listen['reqrep'].each do |reqrep| %> + reqrep <%= reqrep %> +<% end -%> +<% end %> +<% if listen['reqirep'] -%> +<% listen['reqirep'].each do |reqirep| %> + reqirep <%= reqirep %> +<% end -%> +<% end %> +<% if listen['default_backend'] -%> + default_backend <%= listen['default_backend'] %> +<% end %> +<% unless nil_or_empty?(listen['extra_options']) %> +<% listen['extra_options'].each do | key, value | %> +<% if key == 'http-request' %> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% unless nil_or_empty?(listen['use_backend']) %> +<% listen['use_backend'].flatten.uniq.each do | backend |%> + use_backend <%= backend %> +<% end -%> +<% end -%> +<% unless nil_or_empty?(listen['extra_options']) %> +<% listen['extra_options'].each do | key, value | %> +<% unless key == 'http-request' %> +<% if value.is_a?(Array) %> +<% value.each do | array_element | %> + <%= key %> <%= array_element %> +<% end -%> +<% else %> + <%= key %> <%= value %> +<% end -%> +<% end -%> +<% end -%> +<% end -%> +<% listen['server']&.each do | s |%> +<% s.each do |server|%> + server <%= server %> +<% end -%> +<% end -%> +<% if listen['hash_type'] -%> + hash-type <%= listen['hash_type'] %> +<% end -%> +<% end # listen loop -%> +<% end # listen -%> diff --git a/cookbooks/supervisor/recipes/default.rb b/cookbooks/supervisor/recipes/default.rb index 3450fb85..496bed66 100644 --- a/cookbooks/supervisor/recipes/default.rb +++ b/cookbooks/supervisor/recipes/default.rb @@ -26,7 +26,7 @@ end # Install supervisor based on Debian version -if platform?('debian') && (%w(12 13).include?(node['platform_version']) || %w(bookworm trixie).include?(node['lsb']['codename'])) +if platform?('debian') && (node['platform_version'] == '13' || node['lsb']['codename'] == 'trixie') execute 'pipx install supervisor' do command 'PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install supervisor --index=https://pypi.python.org/simple/' not_if { ::File.exist?('/usr/local/bin/supervisorctl') } From dd03d3ed95fadcc07016e12d987f81da841ccd8f Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 15:21:22 +0800 Subject: [PATCH 05/10] wip --- cookbooks/haproxy/.markdownlint.json | 6 - cookbooks/haproxy/CHANGELOG.md | 769 ------------------ cookbooks/haproxy/LICENSE | 201 ----- cookbooks/haproxy/README.md | 161 ---- cookbooks/haproxy/chefignore | 115 --- cookbooks/haproxy/files/haproxy-default | 0 cookbooks/haproxy/libraries/helpers.rb | 85 -- cookbooks/haproxy/libraries/resource.rb | 52 -- cookbooks/haproxy/libraries/template.rb | 9 - cookbooks/haproxy/metadata.json | 40 - cookbooks/haproxy/metadata.rb | 16 - cookbooks/haproxy/resources/acl.rb | 40 - cookbooks/haproxy/resources/backend.rb | 82 -- cookbooks/haproxy/resources/cache.rb | 40 - .../haproxy/resources/config_defaults.rb | 64 -- cookbooks/haproxy/resources/config_global.rb | 70 -- cookbooks/haproxy/resources/fastcgi.rb | 53 -- cookbooks/haproxy/resources/frontend.rb | 89 -- cookbooks/haproxy/resources/install.rb | 182 ----- cookbooks/haproxy/resources/listen.rb | 109 --- cookbooks/haproxy/resources/mailer.rb | 33 - .../haproxy/resources/partial/_config_file.rb | 35 - .../resources/partial/_extra_options.rb | 2 - cookbooks/haproxy/resources/peer.rb | 61 -- cookbooks/haproxy/resources/resolver.rb | 35 - cookbooks/haproxy/resources/service.rb | 91 --- cookbooks/haproxy/resources/use_backend.rb | 43 - cookbooks/haproxy/resources/userlist.rb | 35 - .../haproxy/templates/default/haproxy.cfg.erb | 462 ----------- 29 files changed, 2980 deletions(-) delete mode 100644 cookbooks/haproxy/.markdownlint.json delete mode 100644 cookbooks/haproxy/CHANGELOG.md delete mode 100644 cookbooks/haproxy/LICENSE delete mode 100644 cookbooks/haproxy/README.md delete mode 100644 cookbooks/haproxy/chefignore delete mode 100644 cookbooks/haproxy/files/haproxy-default delete mode 100644 cookbooks/haproxy/libraries/helpers.rb delete mode 100644 cookbooks/haproxy/libraries/resource.rb delete mode 100644 cookbooks/haproxy/libraries/template.rb delete mode 100644 cookbooks/haproxy/metadata.json delete mode 100644 cookbooks/haproxy/metadata.rb delete mode 100644 cookbooks/haproxy/resources/acl.rb delete mode 100644 cookbooks/haproxy/resources/backend.rb delete mode 100644 cookbooks/haproxy/resources/cache.rb delete mode 100644 cookbooks/haproxy/resources/config_defaults.rb delete mode 100644 cookbooks/haproxy/resources/config_global.rb delete mode 100644 cookbooks/haproxy/resources/fastcgi.rb delete mode 100644 cookbooks/haproxy/resources/frontend.rb delete mode 100644 cookbooks/haproxy/resources/install.rb delete mode 100644 cookbooks/haproxy/resources/listen.rb delete mode 100644 cookbooks/haproxy/resources/mailer.rb delete mode 100644 cookbooks/haproxy/resources/partial/_config_file.rb delete mode 100644 cookbooks/haproxy/resources/partial/_extra_options.rb delete mode 100644 cookbooks/haproxy/resources/peer.rb delete mode 100644 cookbooks/haproxy/resources/resolver.rb delete mode 100644 cookbooks/haproxy/resources/service.rb delete mode 100644 cookbooks/haproxy/resources/use_backend.rb delete mode 100644 cookbooks/haproxy/resources/userlist.rb delete mode 100644 cookbooks/haproxy/templates/default/haproxy.cfg.erb diff --git a/cookbooks/haproxy/.markdownlint.json b/cookbooks/haproxy/.markdownlint.json deleted file mode 100644 index 95b5094c..00000000 --- a/cookbooks/haproxy/.markdownlint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "MD024": { - "siblings_only": true - }, - "MD013":false -} diff --git a/cookbooks/haproxy/CHANGELOG.md b/cookbooks/haproxy/CHANGELOG.md deleted file mode 100644 index 68c407f1..00000000 --- a/cookbooks/haproxy/CHANGELOG.md +++ /dev/null @@ -1,769 +0,0 @@ -# haproxy Cookbook CHANGELOG - -This file is used to list changes made in each version of the haproxy cookbook. - -## 12.2.3 - *2022-04-21* - -- Remove delivery folder -- Standardise files with files in sous-chefs/repo-management -- Migrate to new workflow pipelines - -## 12.2.2 - *2021-10-05* - -- Update supported platforms in README.md - -## 12.2.1 - *2021-08-30* - -- Standardise files with files in sous-chefs/repo-management - -## 12.2.0 - *2021-08-11* - -- Add `use_promex` property to install.rb to support compiling with Prometheus Exporter support - [@Wicaeed](https://github.com/wicaeed) - -## 12.1.0 - *2021-06-14* - -- Add `ssl_lib` and `ssl_inc` properties to `haproxy_install` to support openssl - [@derekgroh](https://github.com/derekgroh) - -## 12.0.1 - *2021-06-01* - -- Standardise files with files in sous-chefs/repo-management - -## 12.0.0 - *2021-05-13* - -- Refactor to use resource partials -- Add delete action to most resources -- Convert `install` resource boolean strings to true/false -- Ensure section is created before adding an ACL - -## 11.0.0 - *2021-05-07* - -- Drop testing for Debian 8, Ubuntu 16.04 & Ubuntu 18.04 -- Add testing for Debian 9 Ubuntu 20.04 & Ubuntu 21.04 -- Fix the minimum Chef version to 15.3 - unified_mode was introduced in 15.3 -- Change kitchen to use the Bento provided Amazonlinux2 image -- Fix test suite - -## 10.0.1 - *2021-04-26* - -- Add missing configuration file properties to all resources - -## 10.0.0 - *2021-04-24* - -- Add configuration test function to the service resource - [@bmhughes](https://github.com/bmhughes) -- Fix generating multiple actions from the service resource - [@bmhughes](https://github.com/bmhughes) -- Kitchen test with CentOS 8/8 stream - [@bmhughes](https://github.com/bmhughes) -- Fix IUS repo causing a run failure on an unsupported platform - [@bmhughes](https://github.com/bmhughes) -- Move configuration resource creation into resource helper module - [@bmhughes](https://github.com/bmhughes) - -## [v9.1.0] (2020-10-07) - -### Added - -- testing for haproxy 2.2 - -### Removed - -- testing for haproxy 1.9 & 2.1 - -## [v9.0.1] (2020-09-15) - -### Added - -- added lua compilation flags to `haproxy_install` resource - -### Fixed - -- resolved cookstyle error: libraries/helpers.rb:19:24 refactor: `ChefCorrectness/InvalidPlatformFamilyInCase` -- Updated IUS repo url to `https://repo.ius.io/ius-release-el7.rpm` - -### Changed - -- Turn on unified_mode for all resources - -## [v9.0.0] (2020-02-21) - -### Changed - -- Removed `depends_on` build-essential, as this is now in Chef Core - -### Fixed - -- Cookstyle fixes for cookstyle version 5.20 - -## [v8.3.0] (2020-01-09) - -### Added - -- on `haproxy_install` epel is now a configurable option - -### Changed - -- Migrated testing to github actions - -### Fixed - -- ius repo will only echo out if enabled - -## [v8.2.0] (2019-12-23) - -### Added - -- `fastcgi` resource to support FastCGI applications - -### Changed - -- Default source install version is haproxy 2.1 - -### Fixed - -- Bug with single newline between resources when multiple of the same type are defined - -### Removed - -- `.foodcritic` as it is no longer run by deliver local. -- `.rubocop.yml` as no longer required. - -## [v8.1.1] (2019-10-02) - -### Changed - -- Updated `config_defaults` resourcce `stats` property default value to empty hash. -- Updated metadata.rb chef_version to >=13.9 due to resource `description`. - -## [v8.1.0] (2019-06-24) - -### Changed - -- Updated build target to linux-glibc for haproxy 2.0 compatibility. -- Updated integration tests to cover haproxy 2.0. -- Moved install resource target_os check to libraries. - -## [v8.0.0] (2019-05-29) - -### Added - -- The bind config hash joins with a space instead of a colon. -- The peer resource. -- The mailer resource. - -## [v7.1.0] (2019-04-16) - -### Changed - -- Clean up unused templates and files. - -### Fixed - -- Name conflict with systemd_unit in service resource. - -## [v7.0.0] (2019-04-10) - -### Added - -- `health` to allowed values for `mode` on `frontend`, `backend`, `listen`, `default`. -- `apt-update` for debian platforms. -- ius repo for CentOS and Redhat package installations (resolves #348). - -### Changed - -- Clean up unit and integration test content regular expressions. -- Move system command to a helper. -- Support only systemd init systems. - -### Removed - -- Remove `poise_service` dependency in favor of systemd_unit. - -### Fixed - -- Fix cookbook default value in `config_global`. - -## [v6.4.0] (2019-03-20) - -### Changed - -- Move resource documentation to dedicated folder with md per resource. -- Rename haproxy_cache `name` property as `cache_name`. - -### Fixed - -- Source installs on CentOS 6. - -## [v6.3.0] (2019-02-18) - -### Added - -- Haproxy_cache resource for caching small objects with HAProxy version >=1.8. - -### Changed - -- Expand integration test coverage to all stable and LTS HAProxy versions. -- Documentation - clarify extra_options hash string => array option. -- Clarify the supported platforms - add AmazonLinux 2, remove fedora & freebsd. - -## [v6.2.7] (2019-01-10) - -### Added - -- Test for appropriate spacing from start of line and end of line. -- `hash_type` param to `haproxy_backend`, `haproxy_listen`, and `haproxy_config_defaults` resources. -- `reqirep` and `reqrep` params to `haproxy_backend`, `haproxy_frontend`, and `haproxy_listen` resources. -- `sensitive` param to `haproxy_install`; set to false to show diff output during Chef run. - -### Changed - -- Allow passing an array to `haproxy_listen`'s `http_request` param. - -### Fixed - -- Fix ordering for `haproxy_listen`: `acl` directives should be applied before `http-request`. - -## [v6.2.6] (2018-11-05) - -### Changed - -- Put `http_request` rules before the `use_backend`. - -## [v6.2.5] (2018-10-09) - -### Added - -- rspec examples for resource usage. - -### Removed - -- Chef-12 support. -- CPU cookbook dependency. - -### Fixed - -- Systemd wrapper, the wrapper is no longer included with haproxy versions greater than 1.8. - -## [v6.2.4] (2018-09-19) - -### Added - -- Server property to listen resource and config template. - -## [v6.2.3] (2018-08-03) - -### Removed - -- A few resource default values so they can be specified in the haproxy.cfg default section and added service reload exmample to the readme for config changes. - -## [v6.2.2] (2018-08-03) - -### Changed - -- Made `haproxy_install` `source_url` property dynamic with `source_version` property and removed the need to specify checksum #307. - -## [v6.2.1] (2018-08-01) - -### Added - -- Compiling from source crypt support #305. - -## [v6.2.0] (2018-05-11) - -### Changed - -- Require Chef 12.20 or later. -- Uses the build_essential resource not the default recipe so the cookbook can be skipped entirely if running on Chef 14+. - -## [v6.1.0] (2018-04-12) - -### **Breaking changes** - -### Added - -- `haproxy_service` resource see test suites for usage. -- Support for haproxy 1.8. -- Test haproxy version 1.8.7 and 1.7.8. -- Test on chef-client version 13.87 and 14. -- Notes on how we generate the travis.yml list. - -### Changed - -- Require Chef 12.20 or later. -- Uses the build_essential resource not the default recipe so the cookbook can be skipped entirely if running on Chef 14+. -- Simplify the kitchen matrix. -- Use default action in tests (:create). -- Set the use_systemd property from the init package system. -- Adding in systemd for SUSE Linux. - -### Removed - -- `kitchen.dokken.yml` suites and inherit from kitchen.yml. -- Amazon tests until a new dokken image is produced that is reliable. - -### Fixed - -- Source comparison. - -## [v6.0.0] (2018-03-28) - -### Removed - -- `compat_resource` cookbok dependency and push the required Chef version to 12.20 - -## [v5.0.4] (2018-03-28) - -### Changed - -- Make 1.8.4 the default installed version (#279) -- Use dokken docker images -- Update tests for haproxy service -- tcplog is now a valid input for the `haproxy_config_defaults` resource (#284) -- bin prefix is now reflected in the service config. (#288, #289) - -## [v5.0.3] (2018-02-02) - -### Fixed - -- `foodcritic` warning for not defining `name_property`. - -## [v5.0.2] (2017-11-29) - -### Fixed - -- Typo in listen section, makes previously unprintable expressions, printable in http-request, http-response and `default_backend`. - -## [v5.0.1] (2017-08-10) - -### Removed - -- useless blank space in generated config file haproxy.cfg - -## [v5.0.0] (2017-08-07) - -### Added - -- Option for install only #251. - -### Changed - -- Updating service to use cookbook template. -- updating to haproxy 1.7.8, updating `source_version` in test files(kitchen,cookbook, etc) -- updating properties to use `new_resource` - -### Fixed - -- `log` `property` in `global` resource can now be of type `Array` or `String`. This fixes #252 -- fixing supports line #258 - -## [v4.6.1] (2017-08-02) - -### Changed - -- Reload instead of restart on config change -- Specify -sf argument last to support haproxy < 1.6.0 - -## [v4.6.0] (2017-07-13) - -### Added - -- `conf_template_source` -- `conf_cookbook` -- Support Array value for `extra_options` entries. (#245, #246) - -## [v4.5.0] (2017-06-29) - -### Added - -- `resolver` resource (#240) - -## [v4.4.0] (2017-06-28) - -### Added - -- `option` as an Array `property` for `backend` resource. This fixes #234 -- Synced Debian/Ubuntu init script with latest upstream package changes - -## [v4.3.1] (2017-06-13) - -### Added - -- Oracle Linux 6 support - -### Removed - -- Scientific linux support as we don't have a reliable image - -## [v4.3.0] (2017-05-31) - -### Added - -- Chefspec Matchers for the resources defined in this cookbook. -- `mode` property to `backend` and `frontend` resources. -- `maxconn` to `global` resource. - -### Removed - -- `default_backend` as a required property on the `frontend` resource. - -## [v4.2.0] (2017-05-04) - -### Added - -- In `acl` resource, usage: `test/fixtures/cookbooks/test/recipes/config_acl.rb` -- In `use_backend` resource, usage: `test/fixtures/cookbooks/test/recipes/config_acl.rb` -- `acl` and `use_backend` to `listen` resource. -- Amazon Linux as a supported platform. - -### Changed - -- Pinned `build-essential`, `>= 8.0.1` -- Pinned `poise-service`, `>= 1.5.1` -- Cleaned up arrays in `templates/default/haproxy.cfg.erb` - -### Fixed - -- Init script for Amazon Linux. - -### BREAKING CHANGES - -- This version removes `stats_socket`, `stats_uri` and `stats_timeout` properties from the `haproxy_global` and `haproxy_listen` resources in favour of using a hash to pass configuration options. - -## [v4.1.0] (2017-05-01) - -### Added - -- `userlist` resource, to see usage: `test/fixtures/cookbooks/test/recipes/config_1_userlist.rb` -- chef-search example in: `test/fixtures/cookbooks/test/recipes/config_backend_search.rb` -- Multiple addresses and ports on listener and frontend (#205) - -### Changed - -- Updating source install test to take node attributes as haproxy.org is slow. - -### Fixed - -- `haproxy_retries` in `haproxy_config_defaults` resource - -## [v4.0.2] (2017-04-21) - -### Fixed - -- haproxy service start on Ubuntu 14.04 (#199) -- Reload HAProxy when changing configuration (#197) - -## [v4.0.1] (2017-04-20) - -### Added - -- Updating README.md -- Adding compat_resource for chef-12 support -- Improvement when rendering the configuration file (#196) - -## [v4.0.0] (2017-04-18) - -### COMPATIBILIY WARNING - -- This version removes the existing recipes, attributes, and instance provider in favor of the new haproxy_install and haproxy_ configuration resources. Why not just leave them in place? Well unfortunately they were utterly broken for anything other than the most trivial usage. Rather than continue the user pain we've opted to remove them and point users to a more modern installation method. If you need the legacy installation methods simply pin to the 3.0.4 release. -- THIS IS GOING TO BREAK EVERYTHING YOU KNOW AND LOVE -- 12.5 or greater rewrite -- Custom Resource Only, no recipes - -## [v3.0.4] (2017-03-29) - -### Fixed - -- Bug introduced in (#174) (#182) - -## [v3.0.3] (2017-03-28) - -### Added - -- Multiple addresses and ports on listener and frontend (#174) -- Customize logging destination (#178) - -### Changed - -- Updating to use bats/serverspec (#179) - -## [v3.0.2] (2017-03-27) - -### Added - -- Allow server startup from `app_lb` recipe. (#171) -- Use Delivery instead of Rake -- Make this cookbook compatible with Chef-13, note: `params` option is now `parameters` (#175) - -## [v3.0.1] (2017-01-30) - -### Added - -- Reload haproxy configuration on changes (#152) -- Merging in generic socket conf (#107) -- Updating config to use facilities hash dynamically (#102) -- Adding `tproxy` and splice per (#98) - -### Removed - -- Members with nil ips from member array. (#79) - -## [v3.0.0] (2017-01-24) - -### Added - -- Configurable debug options -- CentOS7 compatibility (#123) -- Adding poise-service for service management - -### Changed - -- Updating source install to use Haproxy 1.7.2 -- Chef >= 12.1 required -- Use `['haproxy']['source']['target_cpu']` instead of `['haproxy']['source']['target_os']` to detect correct architecture. (#150) - -## [v2.0.2] (2016-12-30) - -### Fixed - -- Cookstyle -- The github URL for the repo in various locations - -### Changed - -- Travis testing updates -- Converted file modes to strings -- Updated the config resource to lazily evaluate node attribute values to better load the values when overridden in wrapper cookbooks - -## v2.0.1 (2016-12-08) - -### Fixed - -- Dynamic configuration to properly template out frontend and backend sections - -### Chnaged - -- Update Chef Brigade to Sous Chefs -- Updated contributing docs to remove the reference to the develop branch - -## v2.0.0 (2016-11-09) - -### Breaking Changes - -- The default recipe is now an empty recipe with manual configuration performed in the 'manual' recipe -- Remove Chef 10 compatibility code -- Switch from Librarian to Berksfile -- Updated the source recipe to install 1.6.9 by default - -### Added - -- Migrated this cookbook from Heavy Water to Chef Brigade so we can ensure more frequent releases and maintenance -- A code of conduct for the project. Read it. -- Several new syslog configuration attributes -- A new attribute for stats_socket_level -- A new attribute for retries -- A chefignore file to speed up syncs from the server -- Scientific and oracle as supported platforms in the metadata -- source_url, issues_url, and chef_version metadata -- Enabled why-run support in the default haproxy resource -- New haproxy_config resource -- Guardfile -- Testing in Travis CI with a Rakefile that runs cookstyle, foodcritic, and ChefSpec as well as a Kitchen Dokken config that does integration testing of the package install -- New node['haproxy']['pool_members'] and node['haproxy']['pool_members_option'] attributes - -### Changed - -- The haproxy config is now verified before the service restarts / reloads to prevent taking down haproxy with a bad config -- Update the Kitchen config file to use Bento boxes and new platforms -- Update ChefSpec matchers to use the latest format -- Broke search logic out into a new_discovery recipe - -### Removed - -- Attributes from the metadata file as these are redundant -- Broken tarball validation in the source recipe to prevented installs from completing - -### Fixed - -- Source installs not running if an older version was present on the node -- Resolved all cookstyle and foodcritic warnings - -## v1.6.7 - -### Added - -- ChefSpec matchers and test coverage - -### Changed - -- Replaced references to Opscode with Chef - -## v1.6.6 - -### Changed - -- Parameterize options for admin listener. -- Renamed templates/rhel to templates/redhat. -- Sort pool members by hostname to avoid needless restarts. -- Support amazon linux init script. -- Support to configure global options. - -### Fixed - -- CPU Tuning, corrects cpu_affinity resource triggers - -## v1.6.4 - -## v1.6.2 - -### Added - -- [COOK-3135](https://tickets.chef.io/browse/COOK-3135) - Allow setting of members with default recipe without changing the template. - -### Fixed - -- [COOK-3424](https://tickets.chef.io/browse/COOK-3424) - Haproxy cookbook attempts to alter an immutable attribute. - -## v1.6.0 - -### Added - -- Allow setting of members with default recipe without changing the template. - -## v1.5.0 - -### Added - -- [COOK-3660](https://tickets.chef.io/browse/COOK-3660) - Make haproxy socket default user group configurable -- [COOK-3537](https://tickets.chef.io/browse/COOK-3537) - Add OpenSSL and zlib source configurations -- [COOK-2384](https://tickets.chef.io/browse/COOK-2384) - Add LWRP for multiple haproxy sites/configs - -## v1.4.0 - -### Added - -- [COOK-3237](https://tickets.chef.io/browse/COOK-3237) - Enable cookie-based persistence in a backend -- [COOK-3216](https://tickets.chef.io/browse/COOK-3216) - Metadata attributes -- [COOK-3211](https://tickets.chef.io/browse/COOK-3211) - Support RHEL -- [COOK-3133](https://tickets.chef.io/browse/COOK-3133) - Allow configuration of a global stats socket - -## v1.3.2 - -### Fixed - -- [COOK-3046]: haproxy default recipe broken by COOK-2656. - -### Added - -- [COOK-2009]: Test-kitchen support to haproxy. - -## v1.3.0 - -### Changed - -- [COOK-2656]: Unify the haproxy.cfg with that from `app_lb`. - -### Added - -- [COOK-1488]: Provide an option to build haproxy from source. - -## v1.2.0 - -### Added - -- [COOK-1936] - use frontend / backend logic. -- [COOK-1937] - cleanup for configurations. -- [COOK-1938] - more flexibility for options. -- [COOK-1939] - reloading haproxy is better than restarting. -- [COOK-1940] - haproxy stats listen on 0.0.0.0 by default. -- [COOK-1944] - improve haproxy performance. - -## v1.1.4 - -### Added - -- [COOK-1839] - `httpchk` configuration to `app_lb` template. - -## v1.1.0 - -### Changed - -- [COOK-1275] - haproxy-default.erb should be a cookbook_file. - -### Fixed - -- [COOK-1594] - Template-Service ordering issue in `app_lb` recipe. - -## v1.0.6 - -### Changed - -- [COOK-1310] - Redispatch flag has changed. - -## v1.0.4 - -### Changed - -- [COOK-806] - Load balancer should include an SSL option. -- [COOK-805] - Fundamental haproxy load balancer options should be configurable. - -## v1.0.3 - -### Changed - -- [COOK-620] `haproxy::app_lb`'s template should use the member cloud private IP by default. - -## v1.0.2 - -### Fixed - -- Regression introduced in v1.0.1. - -## v1.0.1 - -### Added - -- Account for the case where load balancer is in the pool. - -## v1.0.0 - -### Changed - -- Use `node.chef_environment` instead of `node['app_environment']`. - -[10.0.0 - *2021-04-24*]: https://github.com/sous-chefs/haproxy/compare/v6.4.0...HEAD -[v3.0.0]: https://github.com/sous-chefs/haproxy/compare/v2.0.2...v3.0.0 -[v3.0.1]: https://github.com/sous-chefs/haproxy/compare/v3.0.0...v3.0.1 -[v3.0.2]: https://github.com/sous-chefs/haproxy/compare/v3.0.1...v3.0.2 -[v3.0.3]: https://github.com/sous-chefs/haproxy/compare/v3.0.2...v3.0.3 -[v3.0.4]: https://github.com/sous-chefs/haproxy/compare/v3.0.3...v3.0.4 -[v4.0.0]: https://github.com/sous-chefs/haproxy/compare/v3.0.4...v4.0.0 -[v4.0.1]: https://github.com/sous-chefs/haproxy/compare/v4.0.0...v4.0.1 -[v4.0.2]: https://github.com/sous-chefs/haproxy/compare/v4.0.1...v4.0.2 -[v4.1.0]: https://github.com/sous-chefs/haproxy/compare/v4.0.2...v4.1.0 -[v4.2.0]: https://github.com/sous-chefs/haproxy/compare/v4.1.0...v4.2.0 -[v4.3.0]: https://github.com/sous-chefs/haproxy/compare/v4.2.0...v4.3.0 -[v4.3.1]: https://github.com/sous-chefs/haproxy/compare/v4.3.0...v4.3.1 -[v4.4.0]: https://github.com/sous-chefs/haproxy/compare/v4.3.1...v4.4.0 -[v4.5.0]: https://github.com/sous-chefs/haproxy/compare/v4.4.0...v4.5.0 -[v4.6.0]: https://github.com/sous-chefs/haproxy/compare/v4.5.0...v4.6.0 -[v4.6.1]: https://github.com/sous-chefs/haproxy/compare/v4.6.0...v4.6.1 -[v5.0.0]: https://github.com/sous-chefs/haproxy/compare/v4.6.1...v5.0.0 -[v5.0.1]: https://github.com/sous-chefs/haproxy/compare/v5.0.0...v5.0.1 -[v5.0.2]: https://github.com/sous-chefs/haproxy/compare/v5.0.1...v5.0.2 -[v5.0.3]: https://github.com/sous-chefs/haproxy/compare/v5.0.2...v5.0.3 -[v5.0.4]: https://github.com/sous-chefs/haproxy/compare/v5.0.3...v5.0.4 -[v6.0.0]: https://github.com/sous-chefs/haproxy/compare/v5.0.4...v6.0.0 -[v6.1.0]: https://github.com/sous-chefs/haproxy/compare/v6.0.0...v6.1.0 -[v6.2.0]: https://github.com/sous-chefs/haproxy/compare/v6.1.0...v6.2.0 -[v6.2.1]: https://github.com/sous-chefs/haproxy/compare/v6.2.0...v6.2.1 -[v6.2.2]: https://github.com/sous-chefs/haproxy/compare/v6.2.1...v6.2.2 -[v6.2.3]: https://github.com/sous-chefs/haproxy/compare/v6.2.2...v6.2.3 -[v6.2.4]: https://github.com/sous-chefs/haproxy/compare/v6.2.3...v6.2.4 -[v6.2.5]: https://github.com/sous-chefs/haproxy/compare/v6.2.4...v6.2.5 -[v6.2.6]: https://github.com/sous-chefs/haproxy/compare/v6.2.5...v6.2.6 -[v6.2.7]: https://github.com/sous-chefs/haproxy/compare/v6.2.6...v6.2.7 -[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 -[v8.1.0]: https://github.com/sous-chefs/haproxy/compare/v8.0.0...v8.1.0 -[v8.1.1]: https://github.com/sous-chefs/haproxy/compare/v8.1.0...v8.1.1 -[v8.2.0]: https://github.com/sous-chefs/haproxy/compare/v8.1.1...v8.2.0 -[v8.3.0]: https://github.com/sous-chefs/haproxy/compare/v8.2.0...v8.3.0 diff --git a/cookbooks/haproxy/LICENSE b/cookbooks/haproxy/LICENSE deleted file mode 100644 index 11069edd..00000000 --- a/cookbooks/haproxy/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -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 - - http://www.apache.org/licenses/LICENSE-2.0 - -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. diff --git a/cookbooks/haproxy/README.md b/cookbooks/haproxy/README.md deleted file mode 100644 index 24017f8c..00000000 --- a/cookbooks/haproxy/README.md +++ /dev/null @@ -1,161 +0,0 @@ -# haproxy Cookbook - -[![CI State](https://github.com/sous-chefs/haproxy/workflows/ci/badge.svg)](https://github.com/sous-chefs/haproxy/actions?query=workflow%3Aci) -[![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.9+ - -### Platforms - -This cookbook officially supports and is tested against the following platforms: - -* debian: 9 & 10 -* ubuntu: 20.04 & 21.04 -* centos: 7 & 8 -* centos-stream: 8 -* fedora: latest -* amazonlinux: 2 - -PRs are welcome to add support for additional platforms. - -### Examples - -Please check for working examples in [TEST](./test/fixtures/cookbooks/test/) - -## Common Resource Features - -HAProxy has many configurable options available, this cookbook makes the most popular options available as resource properties. - -If you wish to use a HAProxy property that is not listed the `extra_options` hash is available to take in any number of additional values. - -For example, the ability to disable listeners is not provided out of the box. Further examples can be found in either `test/fixtures/recipes` or `spec/test/recipes`. If you have questions on how this works or would like to add more examples so it is easier to understand, please come talk to us on the [Chef Community Slack](http://community-slack.chef.io/) on the #sous-chefs channel. - -```ruby -haproxy_listen 'disabled' do - bind '0.0.0.0:1337' - mode 'http' - extra_options('disabled': '') -end -``` - -The `extra_options` hash is of `String => String` or `String => Array`. When an `Array` value is provided. The values are looped over mapping the key to each value in the config. - -For example: - -```ruby -haproxy_listen 'default' do - extra_options( - 'http-request' => [ 'set-header X-Public-User yes', 'del-header X-Bad-Header' ] - ) -end -``` - -Becomes: - -```haproxy -listen default - ... - http-request set-header X-Public-User yes - http-request del-header X-Bad-Header -``` - -## Resources - -* [haproxy_acl](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_acl.md) -* [haproxy_backend](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_backend.md) -* [haproxy_cache](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_cache.md) -* [haproxy_config_defaults](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_config_defaults.md) -* [haproxy_config_global](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_config_global.md) -* [haproxy_fastcgi](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_fastcgi.md) -* [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) -* [haproxy_userlist](https://github.com/sous-chefs/haproxy/tree/master/documentation/haproxy_userlist.md) - -## Configuration Validation - -The `haproxy.cfg` file has a few specific rule orderings that will generate validation errors if not loaded properly. If using any combination of the below rules, avoid the errors by loading the rules via `extra_options` to specify the top down order as noted below in config file. - -### frontend & listen - -```haproxy - tcp-request connection - tcp-request session - tcp-request content - monitor fail - block (deprecated) - http-request - reqxxx (any req excluding reqadd, e.g. reqdeny, reqallow) - reqadd - redirect - use_backend -``` - -```ruby - extra_options( - 'tcp-request' => 'connection set-src src,ipmask(24)', - 'reqdeny' => '^Host:\ .*\.local', - 'reqallow' => '^Host:\ www\.', - 'use_backend' => 'dynamic' - ) -``` - -### backend - -```haproxy - http-request - reqxxx (any req excluding reqadd, e.g. reqdeny, reqallow) - reqadd - redirect -``` - -```ruby - extra_options( - 'http-request' => 'set-path /%[hdr(host)]%[path]', - 'reqdeny' => '^Host:\ .*\.local', - 'reqallow' => '^Host:\ www\.', - 'redirect' => 'dynamic' - ) -``` - -## Contributors - -This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false) - -### Backers - -Thank you to all our backers! - -![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40) - -### 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) diff --git a/cookbooks/haproxy/chefignore b/cookbooks/haproxy/chefignore deleted file mode 100644 index a27b0b25..00000000 --- a/cookbooks/haproxy/chefignore +++ /dev/null @@ -1,115 +0,0 @@ -# Put files/directories that should be ignored in this file when uploading -# to a Chef Infra Server or Supermarket. -# Lines that start with '# ' are comments. - -# OS generated files # -###################### -.DS_Store -ehthumbs.db -Icon? -nohup.out -Thumbs.db -.envrc - -# EDITORS # -########### -.#* -.project -.settings -*_flymake -*_flymake.* -*.bak -*.sw[a-z] -*.tmproj -*~ -\#* -REVISION -TAGS* -tmtags -.vscode -.editorconfig - -## COMPILED ## -############## -*.class -*.com -*.dll -*.exe -*.o -*.pyc -*.so -*/rdoc/ -a.out -mkmf.log - -# Testing # -########### -.circleci/* -.codeclimate.yml -.delivery/* -.foodcritic -.kitchen* -.mdlrc -.overcommit.yml -.rspec -.rubocop.yml -.travis.yml -.watchr -.yamllint -azure-pipelines.yml -Dangerfile -examples/* -features/* -Guardfile -kitchen*.yml -mlc_config.json -Procfile -Rakefile -spec/* -test/* - -# SCM # -####### -.git -.gitattributes -.gitconfig -.github/* -.gitignore -.gitkeep -.gitmodules -.svn -*/.bzr/* -*/.git -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Bundler # -########### -vendor/* -Gemfile -Gemfile.lock - -# Policyfile # -############## -Policyfile.rb -Policyfile.lock.json - -# Documentation # -############# -CODE_OF_CONDUCT* -CONTRIBUTING* -documentation/* -TESTING* -UPGRADING* - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/cookbooks/haproxy/files/haproxy-default b/cookbooks/haproxy/files/haproxy-default deleted file mode 100644 index e69de29b..00000000 diff --git a/cookbooks/haproxy/libraries/helpers.rb b/cookbooks/haproxy/libraries/helpers.rb deleted file mode 100644 index a85f1246..00000000 --- a/cookbooks/haproxy/libraries/helpers.rb +++ /dev/null @@ -1,85 +0,0 @@ -module Haproxy - module Cookbook - module Helpers - def haproxy_version - v = Mixlib::ShellOut.new("haproxy -v | grep version | awk '{ print $3 }'") - v.run_command.stdout.to_f - end - - def source_package_list - case node['platform_family'] - when 'debian' - %w(libpcre3-dev libssl-dev zlib1g-dev libsystemd-dev) - when 'rhel', 'amazon', 'fedora' - %w(pcre-devel openssl-devel zlib-devel systemd-devel) - when 'suse' - %w(pcre-devel libopenssl-devel zlib-devel systemd-devel) - end - end - - def ius_package - { - name: 'ius-release.rpm', - url: 'https://repo.ius.io/ius-release-el7.rpm', - } - end - - def ius_platform_valid? - platform_family?('rhel') && (platform_version.to_i == 6 || platform_version.to_i == 7) - end - - def target_os(source_version) - major_revision = node['kernel']['release'].split('.')[0..1].join('.').to_f - minor_revision = node['kernel']['release'].split('.')[2].split('-').first.to_i - - if major_revision > 2.6 - source_version.chars.first == '1' ? 'linux2628' : 'linux-glibc' - elsif major_revision == 2.6 - if minor_revision >= 28 - source_version.chars.first == '1' ? 'linux2628' : 'linux-glibc' - else - 'linux26' - end - else - 'generic' - end - end - - def systemd_command(bin_prefix) - if haproxy_version < 1.8 - ::File.join(bin_prefix, 'sbin', 'haproxy-systemd-wrapper') - else - ::File.join(bin_prefix, 'sbin', 'haproxy') + ' -Ws' - end - end - - def default_systemd_unit_content - { - 'Unit' => { - 'Description' => 'HAProxy Load Balancer', - 'Documentation' => 'file:/usr/share/doc/haproxy/configuration.txt.gz', - 'After' => %w(network.target syslog.service), - }, - 'Service' => { - 'EnvironmentFile' => '-/etc/default/haproxy', - 'Environment' => "CONFIG=#{config_file} PIDFILE=/run/haproxy.pid", - 'ExecStartPre' => "#{bin_prefix}/sbin/haproxy -f $CONFIG -c -q", - 'ExecStart' => "#{systemd_command(bin_prefix)} -f $CONFIG -p $PIDFILE $OPTIONS", - 'ExecReload' => [ - "#{bin_prefix}/sbin/haproxy -f $CONFIG -c -q", - '/bin/kill -USR2 $MAINPID', - ], - 'KillSignal' => 'TERM', - 'User' => 'root', - 'WorkingDirectory' => '/', - 'KillMode' => 'mixed', - 'Restart' => 'always', - }, - 'Install' => { - 'WantedBy' => 'multi-user.target', - }, - } - end - end - end -end diff --git a/cookbooks/haproxy/libraries/resource.rb b/cookbooks/haproxy/libraries/resource.rb deleted file mode 100644 index 9d5f7c90..00000000 --- a/cookbooks/haproxy/libraries/resource.rb +++ /dev/null @@ -1,52 +0,0 @@ -module Haproxy - module Cookbook - module ResourceHelpers - def haproxy_config_resource_init - haproxy_config_resource_create unless haproxy_config_resource_exist? - end - - def haproxy_config_resource - return unless haproxy_config_resource_exist? - - find_resource!(:template, new_resource.config_file) - end - - private - - def haproxy_config_resource_exist? - !find_resource!(:template, new_resource.config_file).nil? - rescue Chef::Exceptions::ResourceNotFound - false - end - - def haproxy_config_resource_create - with_run_context(:root) do - declare_resource(:directory, ::File.dirname(new_resource.config_file)) do - owner new_resource.user - group new_resource.group - mode new_resource.config_dir_mode - - recursive true - - action :create - end - - declare_resource(:template, new_resource.config_file) do - cookbook new_resource.cookbook - source new_resource.template - - owner new_resource.user - group new_resource.group - mode new_resource.config_file_mode - sensitive new_resource.sensitive - - helpers(Haproxy::Cookbook::TemplateHelpers) - - action :nothing - delayed_action :create - end - end - end - end - end -end diff --git a/cookbooks/haproxy/libraries/template.rb b/cookbooks/haproxy/libraries/template.rb deleted file mode 100644 index 7b6d151e..00000000 --- a/cookbooks/haproxy/libraries/template.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Haproxy - module Cookbook - module TemplateHelpers - def nil_or_empty?(v) - v.nil? || (v.respond_to?(:empty?) && v.empty?) - end - end - end -end diff --git a/cookbooks/haproxy/metadata.json b/cookbooks/haproxy/metadata.json deleted file mode 100644 index bb64f0e9..00000000 --- a/cookbooks/haproxy/metadata.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "haproxy", - "description": "Installs and configures haproxy", - "long_description": "", - "maintainer": "Sous Chefs", - "maintainer_email": "help@sous-chefs.org", - "license": "Apache-2.0", - "platforms": { - "debian": ">= 0.0.0", - "ubuntu": ">= 0.0.0", - "centos": ">= 0.0.0", - "amazon": ">= 0.0.0", - "opensuseleap": ">= 0.0.0" - }, - "dependencies": { - "yum-epel": ">= 0.0.0" - }, - "providing": { - - }, - "recipes": { - - }, - "version": "12.2.3", - "source_url": "https://github.com/sous-chefs/haproxy", - "issues_url": "https://github.com/sous-chefs/haproxy/issues", - "privacy": false, - "chef_versions": [ - [ - ">= 16" - ] - ], - "ohai_versions": [ - - ], - "gems": [ - - ], - "eager_load_libraries": true -} diff --git a/cookbooks/haproxy/metadata.rb b/cookbooks/haproxy/metadata.rb deleted file mode 100644 index c63eebcf..00000000 --- a/cookbooks/haproxy/metadata.rb +++ /dev/null @@ -1,16 +0,0 @@ -name 'haproxy' -maintainer 'Sous Chefs' -maintainer_email 'help@sous-chefs.org' -license 'Apache-2.0' -description 'Installs and configures haproxy' -version '12.2.3' -source_url 'https://github.com/sous-chefs/haproxy' -issues_url 'https://github.com/sous-chefs/haproxy/issues' -chef_version '>= 16' - -supports 'debian' -supports 'ubuntu' -supports 'centos' -supports 'amazon' -supports 'opensuseleap' -depends 'yum-epel' diff --git a/cookbooks/haproxy/resources/acl.rb b/cookbooks/haproxy/resources/acl.rb deleted file mode 100644 index 1a88bcde..00000000 --- a/cookbooks/haproxy/resources/acl.rb +++ /dev/null @@ -1,40 +0,0 @@ -use 'partial/_config_file' - -property :acl, [String, Array], - name_property: true, - coerce: proc { |p| Array(p) }, - description: 'The access control list items' - -property :section, String, - required: true, - equal_to: %w(frontend listen backend), - description: 'The section where the acl(s) should be applied' - -property :section_name, String, - required: true, - description: 'The name of the specific frontend, listen or backend section' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables[new_resource.section] ||= {} - - haproxy_config_resource.variables[new_resource.section][new_resource.section_name] ||= {} - - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'] ||= [] - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'].push(new_resource.acl) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables[new_resource.section] ||= {} - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'] ||= [] - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['acl'].delete(new_resource.acl) -end diff --git a/cookbooks/haproxy/resources/backend.rb b/cookbooks/haproxy/resources/backend.rb deleted file mode 100644 index 496659f8..00000000 --- a/cookbooks/haproxy/resources/backend.rb +++ /dev/null @@ -1,82 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :mode, String, - equal_to: %w(http tcp health), - description: 'Set the running mode or protocol of the instance' - -property :server, [String, Array], - coerce: proc { |p| Array(p) }, - description: 'Servers the backend routes to' - -property :tcp_request, [String, Array], - coerce: proc { |p| Array(p) }, - description: 'HAProxy tcp-request settings' - -property :reqrep, [String, Array], - coerce: proc { |p| Array(p) }, - description: 'Replace a regular expression with a string in an HTTP request line' - -property :reqirep, [String, Array], - coerce: proc { |p| Array(p) }, - description: 'reqrep ignoring case' - -property :acl, Array, - description: 'Access control list items' - -property :option, Array, - description: 'Array of HAProxy option directives' - -property :hash_type, String, - equal_to: %w(consistent map-based), - description: 'Specify a method to use for mapping hashes to servers' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['backend'] ||= {} - - haproxy_config_resource.variables['backend'][new_resource.name] ||= {} - haproxy_config_resource.variables['backend'][new_resource.name]['mode'] = new_resource.mode if property_is_set?(:mode) - - if property_is_set?(:server) - haproxy_config_resource.variables['backend'][new_resource.name]['server'] ||= [] - haproxy_config_resource.variables['backend'][new_resource.name]['server'].push(new_resource.server) - end - - if property_is_set?(:tcp_request) - haproxy_config_resource.variables['backend'][new_resource.name]['tcp_request'] ||= [] - haproxy_config_resource.variables['backend'][new_resource.name]['tcp_request'].push(new_resource.tcp_request) - end - - haproxy_config_resource.variables['backend'][new_resource.name]['reqrep'] = new_resource.reqrep.flatten if property_is_set?(:reqrep) - haproxy_config_resource.variables['backend'][new_resource.name]['reqirep'] = new_resource.reqirep.flatten if property_is_set?(:reqirep) - - if property_is_set?(:acl) - haproxy_config_resource.variables['backend'][new_resource.name]['acl'] ||= [] - haproxy_config_resource.variables['backend'][new_resource.name]['acl'].push(new_resource.acl) - end - - if property_is_set?(:option) - haproxy_config_resource.variables['backend'][new_resource.name]['option'] ||= [] - haproxy_config_resource.variables['backend'][new_resource.name]['option'].push(new_resource.option) - end - - haproxy_config_resource.variables['backend'][new_resource.name]['hash_type'] = new_resource.hash_type if property_is_set?(:hash_type) - haproxy_config_resource.variables['backend'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['backend'] ||= {} - - haproxy_config_resource.variables['backend'][new_resource.name] ||= {} - haproxy_config_resource.variables['backend'].delete(new_resource.name) if haproxy_config_resource.variables['backend'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/cache.rb b/cookbooks/haproxy/resources/cache.rb deleted file mode 100644 index 8e7b7d23..00000000 --- a/cookbooks/haproxy/resources/cache.rb +++ /dev/null @@ -1,40 +0,0 @@ -use 'partial/_config_file' - -property :cache_name, String, - name_property: true, - description: 'Name of the cache' - -property :total_max_size, Integer, - description: 'Define the size in RAM of the cache in megabytes' - -property :max_object_size, Integer, - description: 'Define the maximum size of the objects to be cached' - -property :max_age, Integer, - description: 'Define the maximum expiration duration in seconds' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['cache'] ||= {} - - haproxy_config_resource.variables['cache'][new_resource.cache_name] ||= {} - haproxy_config_resource.variables['cache'][new_resource.cache_name]['total_max_size'] = new_resource.total_max_size if property_is_set?(:total_max_size) - haproxy_config_resource.variables['cache'][new_resource.cache_name]['max_object_size'] = new_resource.max_object_size if property_is_set?(:max_object_size) - haproxy_config_resource.variables['cache'][new_resource.cache_name]['max_age'] = new_resource.max_age if property_is_set?(:max_age) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['cache'] ||= {} - - haproxy_config_resource.variables['cache'][new_resource.cache_name] ||= {} - haproxy_config_resource.variables['cache'].delete(new_resource.cache_name) if haproxy_config_resource.variables['cache'].key?(new_resource.cache_name) -end diff --git a/cookbooks/haproxy/resources/config_defaults.rb b/cookbooks/haproxy/resources/config_defaults.rb deleted file mode 100644 index 501880b9..00000000 --- a/cookbooks/haproxy/resources/config_defaults.rb +++ /dev/null @@ -1,64 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :timeout, Hash, - default: { client: '10s', server: '10s', connect: '10s' }, - description: 'Default HAProxy timeout values' - -property :log, String, - default: 'global', - description: 'Enable per-instance logging of events and traffic' - -property :mode, String, - default: 'http', - equal_to: %w(http tcp health), - description: 'Set the running mode or protocol of the instance' - -property :balance, String, - default: 'roundrobin', - equal_to: %w(roundrobin static-rr leastconn first source uri url_param header rdp-cookie), - description: 'Define the load balancing algorithm to be used in a backend' - -property :option, Array, - default: %w(httplog dontlognull redispatch tcplog), - description: 'Array of HAProxy option directives' - -property :stats, Hash, - default: {}, - description: 'Enable HAProxy statistics' - -property :maxconn, Integer, - description: 'Sets the maximum per-process number of concurrent connections' - -property :haproxy_retries, Integer, - description: 'Set the number of retries to perform on a server after a connection failure' - -property :hash_type, [String, nil], - equal_to: ['consistent', 'map-based', nil], - description: 'Specify a method to use for mapping hashes to servers' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['defaults'] ||= {} - - haproxy_config_resource.variables['defaults']['timeout'] = new_resource.timeout - haproxy_config_resource.variables['defaults']['log'] = new_resource.log - haproxy_config_resource.variables['defaults']['mode'] = new_resource.mode - haproxy_config_resource.variables['defaults']['balance'] = new_resource.balance - - haproxy_config_resource.variables['defaults']['option'] ||= [] - haproxy_config_resource.variables['defaults']['option'].push(new_resource.option).flatten! - - haproxy_config_resource.variables['defaults']['stats'] = new_resource.stats - haproxy_config_resource.variables['defaults']['maxconn'] = new_resource.maxconn.to_s if property_is_set?(:maxconn) - haproxy_config_resource.variables['defaults']['retries'] = new_resource.haproxy_retries.to_s if property_is_set?(:haproxy_retries) - haproxy_config_resource.variables['defaults']['hash_type'] = new_resource.hash_type if property_is_set?(:hash_type) - haproxy_config_resource.variables['defaults']['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end diff --git a/cookbooks/haproxy/resources/config_global.rb b/cookbooks/haproxy/resources/config_global.rb deleted file mode 100644 index 827f5c97..00000000 --- a/cookbooks/haproxy/resources/config_global.rb +++ /dev/null @@ -1,70 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :pidfile, String, - default: '/var/run/haproxy.pid', - description: 'Writes PIDs of all daemons into file ' - -property :log, [String, Array], - default: '/dev/log syslog info', - description: 'Adds a global syslog server' - -property :daemon, [true, false], - default: true, - description: 'Makes the process fork into background' - -property :debug_option, String, - default: 'quiet', - equal_to: %w(quiet debug), - description: 'Sets the debugging mode' - -property :stats, Hash, - default: lazy { - { - socket: "/var/run/haproxy.sock user #{user} group #{group}", - timeout: '2m', - } - }, - description: 'Enable stats with various options' - -property :maxconn, [Integer, String], - default: 4096, - description: 'Sets the maximum per-process number of concurrent connections' - -property :chroot, String, - description: 'Changes current directory to and performs a chroot() there before dropping privileges' - -property :log_tag, String, - default: 'haproxy', - description: 'Specifies the log tag to use for all outgoing logs' - -property :tuning, Hash, - description: 'A hash of tune.' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['global'] ||= {} - - haproxy_config_resource.variables['global']['user'] = new_resource.user - haproxy_config_resource.variables['global']['group'] = new_resource.group - haproxy_config_resource.variables['global']['pidfile'] = new_resource.pidfile - - haproxy_config_resource.variables['global']['log'] ||= [] - haproxy_config_resource.variables['global']['log'].push(new_resource.log) - - haproxy_config_resource.variables['global']['log_tag'] = new_resource.log_tag - haproxy_config_resource.variables['global']['chroot'] = new_resource.chroot if property_is_set?(:chroot) - haproxy_config_resource.variables['global']['daemon'] = new_resource.daemon.to_s - haproxy_config_resource.variables['global']['debug_option'] = new_resource.debug_option - haproxy_config_resource.variables['global']['maxconn'] = new_resource.maxconn - haproxy_config_resource.variables['global']['stats'] = new_resource.stats - haproxy_config_resource.variables['global']['tuning'] = new_resource.tuning if property_is_set?(:tuning) - haproxy_config_resource.variables['global']['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end diff --git a/cookbooks/haproxy/resources/fastcgi.rb b/cookbooks/haproxy/resources/fastcgi.rb deleted file mode 100644 index 70729dbb..00000000 --- a/cookbooks/haproxy/resources/fastcgi.rb +++ /dev/null @@ -1,53 +0,0 @@ -use 'partial/_config_file' - -property :fastcgi, String, - name_property: true, - description: 'Name property - sets the fcgi-app name' - -property :docroot, String, - description: 'Define the document root on the remote host' - -property :index, String, - description: 'Define the script name that will be appended after an URI that ends with a slash' - -property :log_stderr, String, - description: 'Enable logging of STDERR messages reported by the FastCGI application' - -property :option, Array, - description: 'Array of HAProxy option directives' - -property :extra_options, Hash, - description: 'Used for setting any HAProxy directives' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['fastcgi'] ||= {} - - haproxy_config_resource.variables['fastcgi'][new_resource.name] ||= {} - haproxy_config_resource.variables['fastcgi'][new_resource.name]['docroot'] = new_resource.docroot if property_is_set?(:docroot) - haproxy_config_resource.variables['fastcgi'][new_resource.name]['index'] = new_resource.index if property_is_set?(:index) - haproxy_config_resource.variables['fastcgi'][new_resource.name]['log_stderr'] = new_resource.log_stderr if property_is_set?(:log_stderr) - - if property_is_set?(:option) - haproxy_config_resource.variables['fastcgi'][new_resource.name]['option'] ||= [] - haproxy_config_resource.variables['fastcgi'][new_resource.name]['option'].push(new_resource.option) - end - - haproxy_config_resource.variables['fastcgi'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['fastcgi'] ||= {} - - haproxy_config_resource.variables['fastcgi'][new_resource.name] ||= {} - haproxy_config_resource.variables['fastcgi'].delete(new_resource.name) if haproxy_config_resource.variables['fastcgi'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/frontend.rb b/cookbooks/haproxy/resources/frontend.rb deleted file mode 100644 index 13746ded..00000000 --- a/cookbooks/haproxy/resources/frontend.rb +++ /dev/null @@ -1,89 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :bind, [String, Hash], - default: '0.0.0.0:80', - description: 'String - sets as given. Hash - joins with a space' - -property :mode, String, - equal_to: %w(http tcp health), - description: 'Set the running mode or protocol of the instance' - -property :maxconn, [Integer, String], - coerce: proc { |p| p.to_s }, - description: 'Sets the maximum per-process number of concurrent connections' - -property :reqrep, [Array, String], - description: 'Replace a regular expression with a string in an HTTP request line' - -property :reqirep, [Array, String], - description: 'reqrep ignoring case' - -property :default_backend, String, - description: 'Specify the backend to use when no "use_backend" rule has been matched' - -property :use_backend, Array, - description: 'Switch to a specific backend if/unless an ACL-based condition is matched' - -property :acl, Array, - description: 'Access control list items' - -property :option, Array, - description: 'Array of HAProxy option directives' - -property :stats, Hash, - description: 'Enable stats with various options' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['frontend'] ||= {} - - haproxy_config_resource.variables['frontend'][new_resource.name] ||= {} - haproxy_config_resource.variables['frontend'][new_resource.name]['bind'] = [] - - if new_resource.bind.is_a?(Hash) - new_resource.bind.map do |addresses, ports| - Array(addresses).product(Array(ports)).each do |combo| - haproxy_config_resource.variables['frontend'][new_resource.name]['bind'].push(combo.join(' ').strip) - end - end - else - haproxy_config_resource.variables['frontend'][new_resource.name]['bind'].push(new_resource.bind) - end - - haproxy_config_resource.variables['frontend'][new_resource.name]['default_backend'] = new_resource.default_backend if property_is_set?(:default_backend) - haproxy_config_resource.variables['frontend'][new_resource.name]['mode'] = new_resource.mode if property_is_set?(:mode) - haproxy_config_resource.variables['frontend'][new_resource.name]['stats'] = new_resource.stats if property_is_set?(:stats) - haproxy_config_resource.variables['frontend'][new_resource.name]['maxconn'] = new_resource.maxconn if property_is_set?(:maxconn) - haproxy_config_resource.variables['frontend'][new_resource.name]['reqrep'] = [new_resource.reqrep].flatten if property_is_set?(:reqrep) - haproxy_config_resource.variables['frontend'][new_resource.name]['reqirep'] = [new_resource.reqirep].flatten if property_is_set?(:reqirep) - haproxy_config_resource.variables['frontend'][new_resource.name]['use_backend'] = new_resource.use_backend if property_is_set?(:use_backend) - - if property_is_set?(:acl) - haproxy_config_resource.variables['frontend'][new_resource.name]['acl'] ||= [] - haproxy_config_resource.variables['frontend'][new_resource.name]['acl'].push(new_resource.acl) - end - - if property_is_set?(:option) - haproxy_config_resource.variables['frontend'][new_resource.name]['option'] ||= [] - haproxy_config_resource.variables['frontend'][new_resource.name]['option'].push(new_resource.option) - end - - haproxy_config_resource.variables['frontend'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['frontend'] ||= {} - - haproxy_config_resource.variables['frontend'][new_resource.name] ||= {} - haproxy_config_resource.variables['frontend'].delete(new_resource.name) if haproxy_config_resource.variables['frontend'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/install.rb b/cookbooks/haproxy/resources/install.rb deleted file mode 100644 index bf8d226c..00000000 --- a/cookbooks/haproxy/resources/install.rb +++ /dev/null @@ -1,182 +0,0 @@ -include Haproxy::Cookbook::Helpers - -use 'partial/_config_file' - -property :install_type, String, - name_property: true, - equal_to: %w(package source), - description: 'Set the installation type' - -property :bin_prefix, String, - default: '/usr', - description: 'Set the source compile prefix' - -property :sensitive, [true, false], - default: true, - description: 'Ensure that sensitive resource data is not logged by the chef-client' - -# Package -property :package_name, String, - default: 'haproxy' - -property :package_version, [String, nil] - -property :enable_ius_repo, [true, false], - default: false, - description: 'Enables the IUS package repo for Centos to install versions >1.5' - -property :enable_epel_repo, [true, false], - default: true, - description: 'Enables the epel repo for RHEL based operating systems' - -# Source -property :source_version, String, - default: '2.2.4' - -property :source_url, String, - default: lazy { "https://www.haproxy.org/download/#{source_version.to_f}/src/haproxy-#{source_version}.tar.gz" } - -property :source_checksum, String, - default: '87a4d9d4ff8dc3094cb61bbed4a8eed2c40b5ac47b9604daebaf036d7b541be2' - -property :source_target_cpu, String, - default: lazy { node['kernel']['machine'] } - -property :source_target_arch, String - -property :source_target_os, String, - default: lazy { target_os(source_version) } - -property :use_libcrypt, [true, false], - default: true - -property :use_pcre, [true, false], - default: true - -property :use_promex, [true, false], - default: false - -property :use_openssl, [true, false], - default: true - -property :use_zlib, [true, false], - default: true - -property :use_linux_tproxy, [true, false], - default: true - -property :use_linux_splice, [true, false], - default: true - -property :use_lua, [true, false], - default: false - -property :lua_lib, String - -property :lua_inc, String - -property :ssl_lib, String - -property :ssl_inc, String - -property :use_systemd, [true, false], - default: lazy { source_version.to_f >= 1.8 }, - description: 'Evalues whether to use systemd based on the nodes init package' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action_class do - include Haproxy::Cookbook::Helpers - include Haproxy::Cookbook::ResourceHelpers - - def compile_make_boolean(bool) - bool ? '1' : '0' - end -end - -action :install do - case new_resource.install_type - when 'package' - case node['platform_family'] - when 'amazon' - include_recipe 'yum-epel' if new_resource.enable_epel_repo - when 'rhel' - include_recipe 'yum-epel' if new_resource.enable_epel_repo - - if new_resource.enable_ius_repo - if ius_platform_valid? - puts ius_package[:url] - - remote_file ::File.join(Chef::Config[:file_cache_path], ius_package[:name]) do - source ius_package[:url] - only_if { new_resource.enable_ius_repo } - end - - package ius_package[:name] do - source ::File.join(Chef::Config[:file_cache_path], ius_package[:name]) - only_if { new_resource.enable_ius_repo } - end - else - log 'This platform is not supported by IUS, ignoring enable_ius_repo property' do - level :warn - end - end - end - end - - package new_resource.package_name do - version new_resource.package_version if new_resource.package_version - end - when 'source' - build_essential 'compilation tools' - package source_package_list - - remote_file 'haproxy source file' do - path ::File.join(Chef::Config[:file_cache_path], "haproxy-#{new_resource.source_version}.tar.gz") - source new_resource.source_url - checksum new_resource.source_checksum if new_resource.source_checksum - action :create - end - - make_cmd = "make TARGET=#{new_resource.source_target_os}" - make_cmd << " CPU=#{new_resource.source_target_cpu}" if property_is_set?(:source_target_cpu) - make_cmd << " ARCH=#{new_resource.source_target_arch}" if property_is_set?(:source_target_arch) - make_cmd << " USE_LIBCRYPT=#{compile_make_boolean(new_resource.use_libcrypt)}" - make_cmd << " USE_PCRE=#{compile_make_boolean(new_resource.use_pcre)}" - make_cmd << " USE_OPENSSL=#{compile_make_boolean(new_resource.use_openssl)}" - make_cmd << " USE_ZLIB=#{compile_make_boolean(new_resource.use_zlib)}" - make_cmd << " USE_LINUX_TPROXY=#{compile_make_boolean(new_resource.use_linux_tproxy)}" - make_cmd << " USE_LINUX_SPLICE=#{compile_make_boolean(new_resource.use_linux_splice)}" - make_cmd << " USE_SYSTEMD=#{compile_make_boolean(new_resource.use_systemd)}" - make_cmd << " USE_LUA=#{compile_make_boolean(new_resource.use_lua)}" if new_resource.use_lua - make_cmd << " USE_PROMEX=#{compile_make_boolean(new_resource.use_promex)}" if new_resource.use_promex - make_cmd << " LUA_LIB=#{new_resource.lua_lib}" if property_is_set?(:lua_lib) - make_cmd << " LUA_INC=#{new_resource.lua_inc}" if property_is_set?(:lua_inc) - make_cmd << " SSL_LIB=#{new_resource.ssl_lib}" if property_is_set?(:ssl_lib) - make_cmd << " SSL_INC=#{new_resource.ssl_inc}" if property_is_set?(:ssl_inc) - extra_cmd = ' EXTRA=haproxy-systemd-wrapper' if new_resource.source_version.to_f < 1.8 - - bash 'compile_haproxy' do - cwd Chef::Config[:file_cache_path] - code <<-EOH - tar xzf haproxy-#{new_resource.source_version}.tar.gz - cd haproxy-#{new_resource.source_version} - #{make_cmd} && make install PREFIX=#{new_resource.bin_prefix} #{extra_cmd} - EOH - not_if "#{::File.join(new_resource.bin_prefix, 'sbin', 'haproxy')} -v | grep #{new_resource.source_version}" - end - end - - with_run_context :root do - group new_resource.group - - user new_resource.user do - home "/home/#{new_resource.user}" - group new_resource.group - end - end -end diff --git a/cookbooks/haproxy/resources/listen.rb b/cookbooks/haproxy/resources/listen.rb deleted file mode 100644 index f7e145fa..00000000 --- a/cookbooks/haproxy/resources/listen.rb +++ /dev/null @@ -1,109 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :bind, [String, Hash], - default: '0.0.0.0:80', - description: 'String - sets as given. Hash - joins with a space' - -property :mode, String, - equal_to: %w(http tcp health), - description: 'Set the running mode or protocol of the instance' - -property :maxconn, Integer, - description: 'Sets the maximum per-process number of concurrent connections' - -property :stats, Hash, - description: 'Enable stats with various options' - -property :http_request, [Array, String], - coerce: proc { |p| Array(p).flatten }, - description: 'Switch to a specific backend if/unless an ACL-based condition is matched' - -property :http_response, String, - description: 'Switch to a specific backend if/unless an ACL-based condition is matched' - -property :reqrep, [Array, String], - coerce: proc { |p| Array(p).flatten }, - description: 'Replace a regular expression with a string in an HTTP request line' - -property :reqirep, [Array, String], - coerce: proc { |p| Array(p).flatten }, - description: 'reqrep ignoring case' - -property :default_backend, String, - description: 'Specify the backend to use when no "use_backend" rule has been matched' - -property :use_backend, Array, - description: 'Switch to a specific backend if/unless an ACL-based condition is matched' - -property :acl, Array, - description: 'Access control list items' - -property :server, Array, - description: 'Servers the listen section routes to' - -property :hash_type, String, - equal_to: %w(consistent map-based), - description: 'Specify a method to use for mapping hashes to servers' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['listen'] ||= {} - - haproxy_config_resource.variables['listen'][new_resource.name] ||= {} - haproxy_config_resource.variables['listen'][new_resource.name]['bind'] ||= [] - - if new_resource.bind.is_a?(Hash) - new_resource.bind.map do |addresses, ports| - Array(addresses).product(Array(ports)).each do |combo| - haproxy_config_resource.variables['listen'][new_resource.name]['bind'].push(combo.join(' ').strip) - end - end - else - haproxy_config_resource.variables['listen'][new_resource.name]['bind'].push(new_resource.bind) - end - - haproxy_config_resource.variables['listen'][new_resource.name]['mode'] = new_resource.mode if property_is_set?(:mode) - haproxy_config_resource.variables['listen'][new_resource.name]['maxconn'] = new_resource.maxconn.to_s if property_is_set?(:mode) - haproxy_config_resource.variables['listen'][new_resource.name]['stats'] = new_resource.stats if property_is_set?(:stats) - haproxy_config_resource.variables['listen'][new_resource.name]['http_request'] = new_resource.http_request if property_is_set?(:http_request) - haproxy_config_resource.variables['listen'][new_resource.name]['http_response'] = new_resource.http_response if property_is_set?(:http_response) - haproxy_config_resource.variables['listen'][new_resource.name]['reqrep'] = new_resource.reqrep if property_is_set?(:reqrep) - haproxy_config_resource.variables['listen'][new_resource.name]['reqirep'] = new_resource.reqirep if property_is_set?(:reqirep) - - if property_is_set?(:use_backend) - haproxy_config_resource.variables['listen'][new_resource.name]['use_backend'] ||= [] - haproxy_config_resource.variables['listen'][new_resource.name]['use_backend'].push(new_resource.use_backend) - end - - if property_is_set?(:acl) - haproxy_config_resource.variables['listen'][new_resource.name]['acl'] ||= [] - haproxy_config_resource.variables['listen'][new_resource.name]['acl'].push(new_resource.acl) - end - - haproxy_config_resource.variables['listen'][new_resource.name]['default_backend'] = new_resource.default_backend if property_is_set?(:default_backend) - - if property_is_set?(:server) - haproxy_config_resource.variables['listen'][new_resource.name]['server'] ||= [] - haproxy_config_resource.variables['listen'][new_resource.name]['server'].push(new_resource.server) - end - - haproxy_config_resource.variables['listen'][new_resource.name]['hash_type'] = new_resource.hash_type if property_is_set?(:hash_type) - haproxy_config_resource.variables['listen'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['listen'] ||= {} - - haproxy_config_resource.variables['listen'][new_resource.name] ||= {} - haproxy_config_resource.variables['listen'].delete(new_resource.name) if haproxy_config_resource.variables['listen'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/mailer.rb b/cookbooks/haproxy/resources/mailer.rb deleted file mode 100644 index 0d4b3c7b..00000000 --- a/cookbooks/haproxy/resources/mailer.rb +++ /dev/null @@ -1,33 +0,0 @@ -use 'partial/_config_file' - -property :mailer, [String, Array], - coerce: proc { |p| Array(p).flatten }, - 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' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['mailer'] ||= {} - - haproxy_config_resource.variables['mailer'][new_resource.name] ||= {} - haproxy_config_resource.variables['mailer'][new_resource.name]['mailer'] = new_resource.mailer if property_is_set?(:mailer) - haproxy_config_resource.variables['mailer'][new_resource.name]['timeout'] = new_resource.timeout if property_is_set?(:timeout) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['mailer'] ||= {} - - haproxy_config_resource.variables['mailer'][new_resource.name] ||= {} - haproxy_config_resource.variables['mailer'].delete(new_resource.name) if haproxy_config_resource.variables['mailer'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/partial/_config_file.rb b/cookbooks/haproxy/resources/partial/_config_file.rb deleted file mode 100644 index 4a09b51a..00000000 --- a/cookbooks/haproxy/resources/partial/_config_file.rb +++ /dev/null @@ -1,35 +0,0 @@ -property :user, String, - default: 'haproxy', - description: 'Set to override default haproxy user, defaults to haproxy' - -property :group, String, - default: 'haproxy', - description: 'Set to override default haproxy group, defaults to haproxy' - -property :config_dir, String, - default: '/etc/haproxy', - desired_state: false, - description: 'Set to override vault configuration directory' - -property :config_dir_mode, String, - default: '0750', - description: 'Set to override haproxy config dir mode, defaults to 0750' - -property :config_file, String, - default: lazy { ::File.join(config_dir, 'haproxy.cfg') }, - desired_state: false, - description: 'Set to override vault configuration file, defaults to /etc/{CONFIG_DIR}/haproxy.cfg' - -property :config_file_mode, String, - default: '0640', - description: 'Set to override default haproxy config file mode, defaults to 0640' - -property :cookbook, String, - default: 'haproxy', - desired_state: false, - description: 'Template source cookbook for the haproxy configuration file' - -property :template, String, - default: 'haproxy.cfg.erb', - desired_state: false, - description: 'Template source file for the haproxy configuration file' diff --git a/cookbooks/haproxy/resources/partial/_extra_options.rb b/cookbooks/haproxy/resources/partial/_extra_options.rb deleted file mode 100644 index abccb58f..00000000 --- a/cookbooks/haproxy/resources/partial/_extra_options.rb +++ /dev/null @@ -1,2 +0,0 @@ -property :extra_options, Hash, - description: 'Used for setting any HAProxy directives' diff --git a/cookbooks/haproxy/resources/peer.rb b/cookbooks/haproxy/resources/peer.rb deleted file mode 100644 index c0c27c6b..00000000 --- a/cookbooks/haproxy/resources/peer.rb +++ /dev/null @@ -1,61 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :bind, [String, Hash], - description: 'String - sets as given. Hash - joins with a space. HAProxy version >= 2.0' - -property :state, String, - equal_to: %w(enabled disabled), - description: 'Set the state of the peers' - -property :server, Array, - description: 'Servers in the peer' - -property :default_bind, String, - description: 'Defines the binding parameters for the local peer, excepted its address' - -property :default_server, String, - description: 'Change default options for a server' - -property :table, Array, - description: 'Configure a stickiness table' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['peer'] ||= {} - - haproxy_config_resource.variables['peer'][new_resource.name] ||= {} - haproxy_config_resource.variables['peer'][new_resource.name]['bind'] = new_resource.bind if property_is_set?(:bind) - haproxy_config_resource.variables['peer'][new_resource.name]['state'] = new_resource.state if property_is_set?(:state) - - if property_is_set?(:server) - haproxy_config_resource.variables['peer'][new_resource.name]['server'] ||= [] - haproxy_config_resource.variables['peer'][new_resource.name]['server'].push(new_resource.server) - end - - haproxy_config_resource.variables['peer'][new_resource.name]['default_bind'] = new_resource.default_bind if property_is_set?(:default_bind) - haproxy_config_resource.variables['peer'][new_resource.name]['default_server'] = new_resource.default_server if property_is_set?(:default_server) - - if property_is_set?(:table) - haproxy_config_resource.variables['peer'][new_resource.name]['table'] ||= [] - haproxy_config_resource.variables['peer'][new_resource.name]['table'].push(new_resource.table) - end - - haproxy_config_resource.variables['peer'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['peer'] ||= {} - - haproxy_config_resource.variables['peer'][new_resource.name] ||= {} - haproxy_config_resource.variables['peer'].delete(new_resource.name) if haproxy_config_resource.variables['peer'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/resolver.rb b/cookbooks/haproxy/resources/resolver.rb deleted file mode 100644 index 7eee0458..00000000 --- a/cookbooks/haproxy/resources/resolver.rb +++ /dev/null @@ -1,35 +0,0 @@ -use 'partial/_config_file' -use 'partial/_extra_options' - -property :nameserver, Array, - description: 'DNS server description' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['resolvers'] ||= {} - - haproxy_config_resource.variables['resolvers'][new_resource.name] ||= {} - - if property_is_set?(:nameserver) - haproxy_config_resource.variables['resolvers'][new_resource.name]['nameserver'] ||= [] - haproxy_config_resource.variables['resolvers'][new_resource.name]['nameserver'].push(new_resource.nameserver) - end - - haproxy_config_resource.variables['resolvers'][new_resource.name]['extra_options'] = new_resource.extra_options if property_is_set?(:extra_options) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['resolvers'] ||= {} - - haproxy_config_resource.variables['resolvers'][new_resource.name] ||= {} - haproxy_config_resource.variables['resolvers'].delete(new_resource.name) if haproxy_config_resource.variables['resolvers'].key?(new_resource.name) -end diff --git a/cookbooks/haproxy/resources/service.rb b/cookbooks/haproxy/resources/service.rb deleted file mode 100644 index 50314f0f..00000000 --- a/cookbooks/haproxy/resources/service.rb +++ /dev/null @@ -1,91 +0,0 @@ -include Haproxy::Cookbook::Helpers - -use 'partial/_config_file' - -property :bin_prefix, String, - default: '/usr', - description: 'Bin location of the haproxy binary, defaults to /usr' - -property :service_name, String, - default: 'haproxy' - -property :systemd_unit_content, [String, Hash], - default: lazy { default_systemd_unit_content }, - description: 'HAProxy systemd unit contents' - -property :config_test, [true, false], - default: true, - description: 'Perform configuration file test before performing service action' - -property :config_test_fail_action, Symbol, - equal_to: %i(raise log), - default: :raise, - description: 'Action to perform upon configuration test failure.' - -unified_mode true - -action_class do - include Haproxy::Cookbook::Helpers - - def do_service_action(resource_action) - with_run_context(:root) do - if %i(start restart reload).include?(resource_action) - begin - if new_resource.config_test && ::File.exist?(new_resource.config_file) - log 'Running configuration test' - cmd = Mixlib::ShellOut.new("#{systemd_command(new_resource.bin_prefix)} -c -V -f #{new_resource.config_file}") - cmd.run_command.error! - Chef::Log.info("Configuration test passed, creating #{new_resource.service_name} #{new_resource.declared_type} resource with action #{resource_action}") - elsif new_resource.config_test && !::File.exist?(new_resource.config_file) - log 'Configuration test is enabled but configuration file does not exist, skipping test' do - level :warn - end - else - Chef::Log.info("Configuration test disabled, creating #{new_resource.service_name} #{new_resource.declared_type} resource with action #{resource_action}") - end - - declare_resource(:service, new_resource.service_name).delayed_action(resource_action) - rescue Mixlib::ShellOut::ShellCommandFailed - if new_resource.config_test_fail_action.eql?(:log) - Chef::Log.error("Configuration test failed, #{new_resource.service_name} #{resource_action} action aborted!\n\n"\ - "Error\n-----\n#{cmd.stderr}") - else - raise "Configuration test failed, #{new_resource.service_name} #{resource_action} action aborted!\n\n"\ - "Error\n-----\nAction: #{resource_action}\n#{cmd.stderr}" - end - end - else - declare_resource(:service, new_resource.service_name).delayed_action(resource_action) - end - end - end -end - -action :create do - with_run_context :root do - declare_resource(:cookbook_file, '/etc/default/haproxy') do - cookbook 'haproxy' - source 'haproxy-default' - owner 'root' - group 'root' - mode '0644' - end - - declare_resource(:systemd_unit, "#{new_resource.service_name}.service") do - content new_resource.systemd_unit_content - triggers_reload true - action :create - end - end -end - -action :delete do - with_run_context :root do - declare_resource(:cookbook_file, '/etc/default/haproxy').action(:delete) - declare_resource(:systemd_unit, "#{new_resource.service_name}.service").action(:delete) - end -end - -%i(start stop restart reload enable disable).each do |action_type| - send(:action, action_type) { do_service_action(action) } -end diff --git a/cookbooks/haproxy/resources/use_backend.rb b/cookbooks/haproxy/resources/use_backend.rb deleted file mode 100644 index 0464043e..00000000 --- a/cookbooks/haproxy/resources/use_backend.rb +++ /dev/null @@ -1,43 +0,0 @@ -use 'partial/_config_file' - -property :use_backend, [String, Array], - name_property: true, - coerce: proc { |p| Array(p) }, - description: 'Switch to a specific backend if/unless an ACL-based condition is matched' - -property :section, String, - required: true, - equal_to: %w(frontend listen backend), - description: 'The section where the acl(s) should be applied' - -property :section_name, String, - required: true, - description: 'The name of the specific frontend, listen or backend section' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables[new_resource.section] ||= {} - - haproxy_config_resource.variables[new_resource.section][new_resource.section_name] ||= {} - - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'] ||= [] - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'].push(new_resource.use_backend) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables[new_resource.section] ||= {} - - haproxy_config_resource.variables[new_resource.section][new_resource.section_name] ||= {} - - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'] ||= [] - haproxy_config_resource.variables[new_resource.section][new_resource.section_name]['use_backend'].delete(new_resource.use_backend) -end diff --git a/cookbooks/haproxy/resources/userlist.rb b/cookbooks/haproxy/resources/userlist.rb deleted file mode 100644 index 5e9b2bdb..00000000 --- a/cookbooks/haproxy/resources/userlist.rb +++ /dev/null @@ -1,35 +0,0 @@ -use 'partial/_config_file' - -property :group, Hash, - description: 'Adds group to the current userlist' - -property :user, Hash, - description: 'Adds user to the current userlist' - -unified_mode true - -action_class do - include Haproxy::Cookbook::ResourceHelpers -end - -action :create do - haproxy_config_resource_init - - haproxy_config_resource.variables['userlist'] ||= {} - haproxy_config_resource.variables['userlist'][new_resource.name] ||= {} - haproxy_config_resource.variables['userlist'][new_resource.name]['group'] ||= [] - haproxy_config_resource.variables['userlist'][new_resource.name]['group'].push(new_resource.group) if property_is_set?(:group) - haproxy_config_resource.variables['userlist'][new_resource.name]['user'] ||= [] - haproxy_config_resource.variables['userlist'][new_resource.name]['user'].push(new_resource.user) if property_is_set?(:user) -end - -action :delete do - haproxy_config_resource_init - - haproxy_config_resource.variables['userlist'] ||= {} - haproxy_config_resource.variables['userlist'][new_resource.name] ||= {} - haproxy_config_resource.variables['userlist'][new_resource.name]['group'] ||= [] - haproxy_config_resource.variables['userlist'][new_resource.name]['group'].delete(new_resource.group) - haproxy_config_resource.variables['userlist'][new_resource.name]['user'] ||= [] - haproxy_config_resource.variables['userlist'][new_resource.name]['user'].delete(new_resource.user) -end diff --git a/cookbooks/haproxy/templates/default/haproxy.cfg.erb b/cookbooks/haproxy/templates/default/haproxy.cfg.erb deleted file mode 100644 index 8744e2a2..00000000 --- a/cookbooks/haproxy/templates/default/haproxy.cfg.erb +++ /dev/null @@ -1,462 +0,0 @@ -<% unless nil_or_empty?(@global) %> -global - user <%= @global['user'] %> - group <%= @global['group'] %> -<% if @global['pid_file'] -%> - pidfile <%= @global['pid_file'] %> -<% end %> -<% if @global['log'] && @global['log'].is_a?(Array)-%> -<% @global['log'].each do | logvar | -%> -<% if logvar && logvar.is_a?(Array)-%> -<% logvar.each do | log | -%> - log <%= log %> -<% end -%> -<% else -%> - log <%= logvar %> -<% end -%> -<% end -%> -<% end -%> -<% if @global['log_tag'] -%> - log-tag <%= @global['log_tag'] %> -<% end -%> -<% if @global['chroot'] -%> - chroot <%= @global['chroot'] %> -<% end -%> -<% if @global['daemon'].eql? 'true' -%> - daemon -<% end -%> - <%= @global['debug_option'] %> -<% @global['stats']&.each do |option, value| -%> - stats <%= option %> <%= value %> -<% end -%> -<% unless nil_or_empty?(@global['maxconn']) -%> - maxconn <%= @global['maxconn'] %> -<% end -%> -<% if @global['pidfile'] -%> - pidfile <%= @global['pidfile'] %> -<% end -%> -<% unless nil_or_empty?(@global['tuning']) %> -<% @global['tuning'].each do | option, value | -%> - tune.<%= option %> <%= value %> -<% end -%> -<% end -%> -<% unless nil_or_empty?(@global['extra_options']) -%> -<% @global['extra_options'].each do | option, value | -%> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= option %> <%= array_element %> -<% end -%> -<% else %> - <%= option %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(@resolvers) %> -<% @resolvers.each do |resolver, r | %> - - -resolvers <%= resolver %> -<% unless nil_or_empty?(r['nameserver']) %> -<% r['nameserver'].each do | s |%> -<% s.each do |nameserver|%> - nameserver <%= nameserver %> -<% end -%> -<% end -%> -<% end -%> -<% r['extra_options'].each do | option, value | -%> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= option %> <%= array_element %> -<% end -%> -<% else %> - <%= option %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(@defaults) %> - - -defaults -<% @defaults['timeout'].each do | key, timeout | -%> - timeout <%= key %> <%= timeout %> -<% end -%> - log <%= @defaults['log'] %> - mode <%= @defaults['mode'] %> -<% unless nil_or_empty?(@defaults['balance']) -%> - balance <%= @defaults['balance'] %> -<% end -%> -<% if @defaults['hash_type'] -%> - hash-type <%= @defaults['hash_type'] %> -<% end -%> -<% @defaults['option'].each do | option | -%> - option <%= option %> -<% end -%> -<% unless nil_or_empty?(@defaults['maxconn']) -%> - maxconn <%= @defaults['maxconn'] %> -<% end -%> -<% unless nil_or_empty?(@defaults['retries']) -%> - retries <%= @defaults['retries'] %> -<% end -%> -<% @defaults['stats']&.each do |option, value| -%> - stats <%= option %> <%= value %> -<% end -%> -<% unless nil_or_empty?(@defaults['extra_options']) %> -<% @defaults['extra_options'].each do | option, value | -%> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= option %> <%= array_element %> -<% end -%> -<% else %> - <%= option %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(@cache) %> -<% @cache.each do |cache, c | %> - - -cache <%= cache %> -<% unless nil_or_empty?(c['total_max_size']) -%> - total-max-size <%= c['total_max_size'] %> -<% end -%> -<% unless nil_or_empty?(c['max_object_size']) %> - max-object-size <%= c['max_object_size'] %> -<% end -%> -<% unless nil_or_empty?(c['max_age']) %> - max-age <%= c['max_age'] %> -<% end -%> -<% end # cache loop -%> -<% end # cache -%> -<% unless nil_or_empty?(@userlist) %> -<% @userlist.each do |userlist, u| %> - - -userlist <%= userlist %> -<% u.each do |type,i| -%> -<% i.each do |item| -%> -<% item.each do |k,v| %> - <%= type %> <%=k%> <%= v %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(@peer) %> -<% @peer.each do |peer, pv | %> - -peers <%= peer %> -<% if pv['bind'].is_a?(Hash) -%> -<% pv['bind'].each do |k, v| -%> - bind <%= "#{k} #{v}".strip %> -<% end -%> -<% else -%> - bind <%= pv['bind'] %> -<% end -%> -<% unless nil_or_empty?(pv['state']) %> - <%= pv['state'] %> -<% end -%> -<% unless nil_or_empty?(pv['server']) %> -<% pv['server'].each do | s |%> -<% s.each do |server|%> - server <%= server %> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(pv['default_bind']) %> - default-bind <%= pv['default_bind'] %> -<% end -%> -<% unless nil_or_empty?(pv['default_server']) %> - default-server <%= pv['default_server'] %> -<% end -%> -<% unless nil_or_empty?(pv['table']) %> -<% pv['table'].each do | t |%> -<% t.each do |table|%> - table <%= table %> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(pv['extra_options']) %> -<% pv['extra_options'].each do | key, value |%> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end # peers loop -%> -<% end # peers -%> -<% unless nil_or_empty?(@mailer) %> -<% @mailer.each do |mailer, m | %> - -mailers <%= mailer %> -<% unless nil_or_empty?(m['mailer']) -%> -<% m['mailer'].each do |mail| -%> - mailer <%= mail %> -<% end -%> -<% end -%> -<% unless nil_or_empty?(m['timeout']) %> - timeout mail <%= m['timeout'] %> -<% end -%> -<% end # mailers loop -%> -<% end # mailers -%> -<% unless nil_or_empty?(@fastcgi) %> -<% @fastcgi.each do |fastcgi, f | %> - - -fcgi-app <%= fastcgi %> -<% unless nil_or_empty?(f['docroot']) %> - docroot <%= f['docroot'] %> -<% end -%> -<% unless nil_or_empty?(f['index']) %> - index <%= f['index'] %> -<% end -%> -<% unless nil_or_empty?(f['log_stderr']) %> - log-stderr <%= f['log_stderr'] %> -<% end -%> -<% unless nil_or_empty?(f['option']) %> -<% f['option'].each do | option |%> -<% option.each do | option | %> - option <%= option %> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(f['extra_options']) %> -<% f['extra_options'].each do | key, value | %> -<% unless key == 'http-request' %> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% end # fastcgi loop -%> -<% end # fastcgi -%> -<% unless nil_or_empty?(@frontend) %> -<% @frontend.each do |frontend, f | %> - - -frontend <%= frontend %> -<% unless nil_or_empty?(f['mode']) -%> - mode <%= f['mode'] %> -<% end -%> -<% unless nil_or_empty?(f['default_backend']) %> - default_backend <%= f['default_backend'] %> -<% end -%> -<% f['bind'].each do |binding| -%> - bind <%= binding %> -<% end -%> -<% unless nil_or_empty?(f['maxconn']) -%> - maxconn <%= f['maxconn'] %> -<% end -%> -<% f['stats']&.each do |option, value| -%> - stats <%= option %> <%= value %> -<% end -%> -<% unless nil_or_empty?(f['acl']) %> -<% f['acl'].flatten.uniq.each do | acl |%> - acl <%= acl %> -<% end -%> -<% end -%> -<% if f['reqrep'] -%> -<% f['reqrep'].each do |reqrep| %> - reqrep <%= reqrep %> -<% end -%> -<% end %> -<% if f['reqirep'] -%> -<% f['reqirep'].each do |reqirep| %> - reqirep <%= reqirep %> -<% end -%> -<% end %> -<% unless nil_or_empty?(f['extra_options']) %> -<% f['extra_options'].each do | key, value | %> -<% if key == 'http-request' %> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(f['use_backend']) %> -<% f['use_backend'].flatten.uniq.each do | backend |%> - use_backend <%= backend %> -<% end -%> -<% end -%> -<% unless nil_or_empty?(f['option']) %> -<% f['option'].each do | option |%> -<% option.each do | option | %> - option <%= option %> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(f['extra_options']) %> -<% f['extra_options'].each do | key, value | %> -<% unless key == 'http-request' %> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% end # frontend loop -%> -<% end # frontend -%> -<% unless nil_or_empty?(@backend) %> -<% @backend.each do | key, backend | %> - - -backend <%= key %> -<% unless nil_or_empty?(backend['mode']) -%> - mode <%= backend['mode'] %> -<% end -%> -<% unless nil_or_empty?(backend['server']) %> -<% backend['server'].each do | s |%> -<% s.each do |server|%> - server <%= server %> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(backend['acl']) %> -<% backend['acl'].flatten.uniq.each do | acl |%> - acl <%= acl %> -<% end -%> -<% end -%> -<% unless nil_or_empty?(backend['option']) %> -<% backend['option'].each do | option |%> -<% option.each do | option | %> - option <%= option %> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(backend['tcp_request']) %> -<% backend['tcp_request'].each do | tcp_request |%> -<% tcp_request.each do | tcp_request | %> - tcp-request <%= tcp_request %> -<% end -%> -<% end -%> -<% end -%> -<% if backend['hash_type'] -%> - hash-type <%= backend['hash_type'] %> -<% end -%> -<% if backend['reqrep'] -%> -<% backend['reqrep'].each do |reqrep| %> - reqrep <%= reqrep %> -<% end -%> -<% end %> -<% if backend['reqirep'] -%> -<% backend['reqirep'].each do |reqirep| %> - reqirep <%= reqirep %> -<% end -%> -<% end %> -<% unless nil_or_empty?(backend['extra_options']) %> -<% backend['extra_options'].each do | key, value |%> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end # backend loop -%> -<% end # backend -%> -<% unless nil_or_empty?(@listen) %> -<% @listen.each do | key, listen |%> - - -listen <%= key %> -<% unless nil_or_empty?(listen['mode']) -%> - mode <%= listen['mode']%> -<% end -%> -<% listen['bind'].each do |binding| -%> - bind <%= binding %> -<% end -%> -<% unless nil_or_empty?(listen['maxconn']) -%> - maxconn <%= listen['maxconn']%> -<% end -%> -<% listen['stats']&.each do |option, value| -%> - stats <%= option %> <%= value %> -<% end -%> -<% unless nil_or_empty?(listen['acl']) %> -<% listen['acl'].flatten.uniq.each do | acl |%> - acl <%= acl %> -<% end -%> -<% end -%> -<% if listen['http_request'] -%> -<% listen['http_request'].each do |http_request| %> - http-request <%= http_request %> -<% end -%> -<% end %> -<% if listen['http_response'] -%> - http-response <%= listen['http_response'] %> -<% end %> -<% if listen['reqrep'] -%> -<% listen['reqrep'].each do |reqrep| %> - reqrep <%= reqrep %> -<% end -%> -<% end %> -<% if listen['reqirep'] -%> -<% listen['reqirep'].each do |reqirep| %> - reqirep <%= reqirep %> -<% end -%> -<% end %> -<% if listen['default_backend'] -%> - default_backend <%= listen['default_backend'] %> -<% end %> -<% unless nil_or_empty?(listen['extra_options']) %> -<% listen['extra_options'].each do | key, value | %> -<% if key == 'http-request' %> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% unless nil_or_empty?(listen['use_backend']) %> -<% listen['use_backend'].flatten.uniq.each do | backend |%> - use_backend <%= backend %> -<% end -%> -<% end -%> -<% unless nil_or_empty?(listen['extra_options']) %> -<% listen['extra_options'].each do | key, value | %> -<% unless key == 'http-request' %> -<% if value.is_a?(Array) %> -<% value.each do | array_element | %> - <%= key %> <%= array_element %> -<% end -%> -<% else %> - <%= key %> <%= value %> -<% end -%> -<% end -%> -<% end -%> -<% end -%> -<% listen['server']&.each do | s |%> -<% s.each do |server|%> - server <%= server %> -<% end -%> -<% end -%> -<% if listen['hash_type'] -%> - hash-type <%= listen['hash_type'] %> -<% end -%> -<% end # listen loop -%> -<% end # listen -%> From 3495182ed8b613422dc7bcf63de56af3b3bc391e Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 18:58:50 +0800 Subject: [PATCH 06/10] wip --- .../libraries/docker_installation_package.rb | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cookbooks/docker/libraries/docker_installation_package.rb b/cookbooks/docker/libraries/docker_installation_package.rb index 4c357867..54691bbc 100644 --- a/cookbooks/docker/libraries/docker_installation_package.rb +++ b/cookbooks/docker/libraries/docker_installation_package.rb @@ -50,6 +50,11 @@ def bullseye? false end + def trixie? + return true if platform?('debian') && node['platform_version'].to_i == 13 + false + end + def bionic? return true if platform?('ubuntu') && node['platform_version'] == '18.04' false @@ -69,6 +74,8 @@ def version_string(v) 'buster' elsif bullseye? # deb 11 'bullseye' + elsif trixie? # deb 13 + 'trixie' elsif bionic? # ubuntu 18.04 'bionic' elsif focal? # ubuntu 20.04 @@ -129,11 +136,27 @@ def version_string(v) package 'apt-transport-https' + # Debian 13 (trixie) and modern apt no longer ship `apt-key`. + # Install the Docker GPG key into a dedicated keyring and reference + # it via the `signed-by` option instead of the deprecated apt-key flow. + directory '/etc/apt/keyrings' do + mode '0755' + recursive true + end + + docker_apt_keyring = '/etc/apt/keyrings/docker.asc' + + remote_file docker_apt_keyring do + source "https://download.docker.com/linux/#{node['platform']}/gpg" + mode '0644' + end + apt_repository 'Docker' do components Array(new_resource.repo_channel) uri "https://download.docker.com/linux/#{node['platform']}" arch deb_arch - key "https://download.docker.com/linux/#{node['platform']}/gpg" + key false + options "signed-by=#{docker_apt_keyring}" action :add end else From 4f2cc2f84ce3537d626e12f1aca615c9625ed5f0 Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 19:48:23 +0800 Subject: [PATCH 07/10] wip --- cookbooks/docker/libraries/docker_installation_package.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/cookbooks/docker/libraries/docker_installation_package.rb b/cookbooks/docker/libraries/docker_installation_package.rb index 54691bbc..3b86b4f2 100644 --- a/cookbooks/docker/libraries/docker_installation_package.rb +++ b/cookbooks/docker/libraries/docker_installation_package.rb @@ -155,7 +155,6 @@ def version_string(v) components Array(new_resource.repo_channel) uri "https://download.docker.com/linux/#{node['platform']}" arch deb_arch - key false options "signed-by=#{docker_apt_keyring}" action :add end From afdd680f3ee6eea76f2cc64421373319217af9c9 Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 20:35:51 +0800 Subject: [PATCH 08/10] wip --- cookbooks/docker/libraries/docker_installation_package.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cookbooks/docker/libraries/docker_installation_package.rb b/cookbooks/docker/libraries/docker_installation_package.rb index 3b86b4f2..87d99b4d 100644 --- a/cookbooks/docker/libraries/docker_installation_package.rb +++ b/cookbooks/docker/libraries/docker_installation_package.rb @@ -68,6 +68,14 @@ def focal? # https://github.com/chef/chef/issues/4103 def version_string(v) return if v.nil? + + # If the caller already provides a fully-qualified Docker package version + # (e.g. "5:28.5.2-1~debian.13~trixie"), use it verbatim. The heuristics + # below only know how to build the legacy "~ce~3-0~debian-" + # style strings, which no longer match the packages published for newer + # Debian releases such as trixie. + return v if v =~ /~debian\.\d+~|~ubuntu\.\d+~|~ce/ || v.include?(':') + codename = if stretch? # deb 9 'stretch' elsif buster? # deb 10 From 2693287a71babdcdd6458c109f5b8db8d7dc9a0d Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Thu, 3 Sep 2026 21:46:37 +0800 Subject: [PATCH 09/10] wip --- .../docker/libraries/docker_installation_package.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cookbooks/docker/libraries/docker_installation_package.rb b/cookbooks/docker/libraries/docker_installation_package.rb index 87d99b4d..1b1f5c0f 100644 --- a/cookbooks/docker/libraries/docker_installation_package.rb +++ b/cookbooks/docker/libraries/docker_installation_package.rb @@ -173,6 +173,19 @@ def version_string(v) version = new_resource.package_version || version_string(new_resource.version) + # On Debian/Ubuntu, explicitly install the CLI (and containerd) in addition + # to the docker-ce (daemon) package. Relying solely on docker-ce's + # dependency resolution can leave /usr/bin/docker (docker-ce-cli) missing + # when apt pin priorities force specific versions, which produces a golden + # image whose `docker` command is absent even though the daemon converged. + if debuntu? + package 'docker-ce-cli' do + version version + options new_resource.package_options + action :install + end + end + package new_resource.package_name do version version options new_resource.package_options From 99608fda9025cbc2197ea2ca49c2d103b0d96ee5 Mon Sep 17 00:00:00 2001 From: Ikechukwu Date: Fri, 4 Sep 2026 06:36:17 +0800 Subject: [PATCH 10/10] wip --- cookbooks/docker/libraries/docker_installation_package.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cookbooks/docker/libraries/docker_installation_package.rb b/cookbooks/docker/libraries/docker_installation_package.rb index 1b1f5c0f..53f617f0 100644 --- a/cookbooks/docker/libraries/docker_installation_package.rb +++ b/cookbooks/docker/libraries/docker_installation_package.rb @@ -182,6 +182,8 @@ def version_string(v) package 'docker-ce-cli' do version version options new_resource.package_options + retries 6 + retry_delay 15 action :install end end @@ -189,6 +191,8 @@ def version_string(v) package new_resource.package_name do version version options new_resource.package_options + retries 6 + retry_delay 15 action :install end end