Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
455dc47916
|
||
|
|
911080ae81
|
||
|
|
edd7cc44de
|
||
|
|
671ee2eae0
|
||
|
|
9e78939f1e
|
||
|
|
d4ff2a42db
|
||
|
|
0310f08d14
|
||
|
|
aa5bebe52a
|
||
|
|
26a5d92239
|
||
|
|
aa8e550406
|
||
|
|
7a9d114d9f
|
@@ -4,7 +4,7 @@ source 'https://supermarket.chef.io'
|
||||
|
||||
cookbook 'elasticsearch', '~> 5.1.3'
|
||||
cookbook 'firewall', '~> 6.2.16'
|
||||
cookbook 'redisio', '~> 6.4.1'
|
||||
cookbook 'redisio', '~> 8.0.0'
|
||||
cookbook 'ruby_build', '~> 2.5.0'
|
||||
|
||||
cookbook 'ipfs',
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ DEPENDENCIES
|
||||
git: https://gitea.kosmos.org/kosmos/postfix-cookbook.git
|
||||
revision: dd6598572a775ae73f17527260ec8097b52d385b
|
||||
ref: bugfix/
|
||||
redisio (~> 6.4.1)
|
||||
redisio (~> 8.0.0)
|
||||
ruby_build (~> 2.5.0)
|
||||
timezone_iii (= 1.0.4)
|
||||
ulimit (~> 1.0.0)
|
||||
@@ -96,12 +96,12 @@ GRAPH
|
||||
php (8.0.1)
|
||||
yum-epel (>= 0.0.0)
|
||||
postfix (6.4.1)
|
||||
redisio (6.4.1)
|
||||
redisio (8.0.0)
|
||||
selinux (>= 0.0.0)
|
||||
ruby_build (2.5.0)
|
||||
homebrew (>= 0.0.0)
|
||||
yum-epel (>= 0.0.0)
|
||||
selinux (6.1.12)
|
||||
selinux (6.2.4)
|
||||
seven_zip (4.2.2)
|
||||
timezone_iii (1.0.4)
|
||||
ulimit (1.0.0)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "sockethub-1",
|
||||
"public_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0DbJHhPvJTaKfPHoOa+i\nr49DPFVvAgUVsbVUsgRvnAW/ngoRwhSHTaHBIfmuvNI/6yoSTy2xZzIgsDGZDeEe\n/gSlmUjbh4Udex9pZ3fotdPjTpqDQMk8KpmCjF9SWstfYwYhcx2oLiImdeSLvn6l\nyMrpx/rieDHn8rEs/cvqkrCCPLtOxLByC92iy5wkz64PouU0/VUud0G7o02pTXd4\n0WULNpehRGl3paNmqCQmShUxeRMkJYOYspHyc13qwQHD35hOBk7A6QDDRHMRbcoI\nLE36q5Mkyh2YGbDhSemoyh+lwqYOHfYJy9gWrIvPEbg6us0yXK1xq1kifPKB9zQj\n4QIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
}
|
||||
@@ -3,3 +3,7 @@ config:
|
||||
line-length: false # MD013
|
||||
no-duplicate-heading: false # MD024
|
||||
reference-links-images: false # MD052
|
||||
no-multiple-blanks:
|
||||
maximum: 2
|
||||
ignores:
|
||||
- .github/copilot-instructions.md
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
".": "8.0.0"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
# Agent Notes
|
||||
|
||||
## Dependency Management
|
||||
|
||||
This cookbook uses `Policyfile.rb` for dependency resolution. Run `chef install Policyfile.rb`
|
||||
before ChefSpec or Kitchen work.
|
||||
|
||||
Kitchen suites use Policyfile named run lists that match the suite names:
|
||||
|
||||
* `default` runs `test::default`
|
||||
* `sentinel` runs `test::sentinel`
|
||||
* `multisentinel` runs `test::multisentinel`
|
||||
|
||||
The `selinux` dependency is sourced from the Sous Chefs GitHub repository to avoid Supermarket
|
||||
availability issues during CI and local resolution.
|
||||
|
||||
## Package Availability
|
||||
|
||||
### APT (Debian/Ubuntu)
|
||||
|
||||
* Ubuntu 22.04 and 24.04 are explicitly tested by Redis upstream and supported by the official APT repository at `https://packages.redis.io/deb`.
|
||||
* Debian 12 and 13 are explicitly tested by Redis upstream and supported by the official APT repository at `https://packages.redis.io/deb`.
|
||||
* The official APT repository provides `redis`, `redis-server`, `redis-sentinel`, and `redis-tools`, with architecture-specific packages such as `amd64`.
|
||||
|
||||
### RPM (RHEL family)
|
||||
|
||||
* Redis upstream publishes official RPM repository instructions for Rocky Linux 8 and 9 and AlmaLinux 8 and 9.
|
||||
* This cookbook CI targets Rocky Linux 9 only.
|
||||
* Amazon Linux 2023 does not have an official Redis upstream repository in the Redis installation docs. For Amazon Linux 2023, package availability comes from the distro package set or from source builds.
|
||||
|
||||
## Architecture Limitations
|
||||
|
||||
* Redis upstream documents tested Linux platforms but does not promise identical package availability across every architecture in the install guide.
|
||||
* The official APT examples show architecture-specific package indexes such as `amd64`.
|
||||
* The cookbook CI validates Linux platform support, not every architecture permutation.
|
||||
|
||||
## Source/Compiled Installation
|
||||
|
||||
### Build Dependencies
|
||||
|
||||
| Platform Family | Packages |
|
||||
|-----------------|-----------------------------------------------------------------|
|
||||
| Debian/Ubuntu | `tar`, `gcc`, `g++`, `make`, `libc6-dev`, `libssl-dev` |
|
||||
| Rocky/Amazon | `tar`, `gcc`, `gcc-c++`, `make`, `glibc-devel`, `openssl-devel` |
|
||||
|
||||
* Redis upstream documents source builds for Linux and macOS using a C compiler and `libc`, with OpenSSL development libraries required for TLS builds.
|
||||
* This cookbook preserves source installs primarily as a compatibility path where package installs are not suitable.
|
||||
|
||||
## Known Issues
|
||||
|
||||
* Amazon Linux 2023 ships `redis6` in the distro package set rather than matching the package names used by Debian, Ubuntu, and Rocky Linux.
|
||||
* Amazon Linux 2023 package support for Redis 6 is time-bounded by Amazon Linux package support, so current package installs there lag the upstream Redis release stream.
|
||||
* Rocky Linux 8 remains in security support but is no longer in active support; this cookbook narrows CI to Rocky Linux 9.
|
||||
+330
-256
@@ -1,417 +1,491 @@
|
||||
|
||||
# redisio
|
||||
|
||||
This file is used to list changes made in each version of the redisio cookbook.
|
||||
|
||||
## 6.4.1 - *2023-05-16*
|
||||
## [8.0.0](https://github.com/sous-chefs/redisio/compare/7.2.4...v8.0.0) (2026-08-11)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* prepare Redisio 8 release ([#532](https://github.com/sous-chefs/redisio/issues/532))
|
||||
* migrate redisio to Chef 16 resources ([#519](https://github.com/sous-chefs/redisio/issues/519))
|
||||
|
||||
### Features
|
||||
|
||||
* migrate redisio to Chef 16 resources ([#519](https://github.com/sous-chefs/redisio/issues/519)) ([c26030e](https://github.com/sous-chefs/redisio/commit/c26030ea34c4559f14e240031d8f4adc245bac7f))
|
||||
* prepare Redisio 8 release ([#532](https://github.com/sous-chefs/redisio/issues/532)) ([057dc7b](https://github.com/sous-chefs/redisio/commit/057dc7ba25a61119ad223cd2141a0db962fb8786))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ci:** Update workflows to use release pipeline ([#514](https://github.com/sous-chefs/redisio/issues/514)) ([5703855](https://github.com/sous-chefs/redisio/commit/570385541ab982d92c9ea0d4ff385bd6fd14082e))
|
||||
|
||||
## 7.2.4 - *2025-09-04*
|
||||
|
||||
## 7.2.3 - *2024-11-18*
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 7.2.0 - *2024-04-30*
|
||||
|
||||
* Add option to specify `cluster-port`
|
||||
|
||||
## 7.1.1 - *2024-04-21*
|
||||
|
||||
* Fix default `tls*` attribute names
|
||||
|
||||
## 7.1.0 - *2024-04-18*
|
||||
|
||||
* Add an option to manage all TLS related attributes
|
||||
|
||||
## 7.0.0 - *2024-04-04*
|
||||
|
||||
* Breaking: support only Redis v6+
|
||||
* Removed obsolete version checks
|
||||
* Removed option to configure Virtual Memory, deprecated in 2.4
|
||||
* Removed deprecated options `list-max-ziplist-entries`, `list-max-ziplist-value`
|
||||
* Renamed references from "slave" to "replica" across configuration attribute names to align with Redis terminology updates
|
||||
* Removed redis-package test suite, most of Linux distributions does not provide packages for Redis v6+
|
||||
* Set default Redis version to 6.2.14
|
||||
* Extend CI workflow to verify multiple Redis versions
|
||||
* Upgrade suidelines:
|
||||
* Ensure all Redis instances are upgraded to version 6.2.14 or higher.
|
||||
* Update configuration files to reflect the terminology change from "slave" to "replica."
|
||||
* Remove any references to deprecated options `list-max-ziplist-entries` and `list-max-ziplist-value`.
|
||||
* Test the compatibility of your Chef cookbook with Redis v6+ before deploying the upgrade.
|
||||
|
||||
## 6.7.1 - *2024-01-11*
|
||||
|
||||
* Add `includes` option to sentinel configuration file.
|
||||
|
||||
## 6.7.0 - *2024-01-04*
|
||||
|
||||
* Add `aclfile` option to sentinel configuration file.
|
||||
* Update Github Actions
|
||||
|
||||
## 6.6.0 - *2023-11-11*
|
||||
|
||||
* Add `aclfile` option to redis configuration file.
|
||||
|
||||
## 6.5.0 - *2023-10-31*
|
||||
|
||||
* Add `maxclients` option to sentinel configuration file.
|
||||
|
||||
## 6.4.0 - *2023-04-26*
|
||||
|
||||
- Simplify `configure` and `sentinel` resources, making them idempotent
|
||||
* Simplify `configure` and `sentinel` resources, making them idempotent
|
||||
|
||||
## 6.3.7 - *2023-04-25*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.6 - *2023-04-04*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.5 - *2023-04-01*
|
||||
|
||||
- Update workflows
|
||||
* Update workflows
|
||||
|
||||
## 6.3.5 - *2023-04-01*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.5 - *2023-04-01*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.4 - *2023-03-15*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.3 - *2023-02-15*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.2 - *2023-02-14*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.1 - *2022-12-06*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.3.0 - *2022-09-10*
|
||||
|
||||
- Version check fix for some Redis default settings to support Redis v4 and above.
|
||||
* Version check fix for some Redis default settings to support Redis v4 and above.
|
||||
|
||||
## 6.2.4 - *2022-08-13*
|
||||
|
||||
- Fix systemd entry to ensure listening on all network interfaces ([#440](https://github.com/brianbianco/redisio/pull/440))
|
||||
* Fix systemd entry to ensure listening on all network interfaces ([#440](https://github.com/brianbianco/redisio/pull/440))
|
||||
|
||||
## 6.2.3 - *2022-08-12*
|
||||
|
||||
- Fix grammar in README.md
|
||||
- Use latest instead of current channel with dokken
|
||||
* Fix grammar in README.md
|
||||
* Use latest instead of current channel with dokken
|
||||
|
||||
## 6.2.2 - *2022-04-25*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.2.1 - *2022-04-25*
|
||||
|
||||
- Fixes configdir permissions. Similar to [451](https://github.com/sous-chefs/redisio/pull/451)
|
||||
- Deprecated `.foodcritic` configfile removed
|
||||
* Fixes configdir permissions. Similar to [451](https://github.com/sous-chefs/redisio/pull/451)
|
||||
* Deprecated `.foodcritic` configfile removed
|
||||
|
||||
## 6.2.0 - *2022-02-14*
|
||||
|
||||
- Adds support for Rocky Linux
|
||||
* Adds support for Rocky Linux
|
||||
|
||||
## 6.1.3 - *2022-02-04*
|
||||
|
||||
- Remove references to selinux_policy cookbook
|
||||
* Remove references to selinux_policy cookbook
|
||||
|
||||
## 6.1.2 - *2022-02-03*
|
||||
|
||||
- Fixes configdir permissions preventing Sentinel to update the config file
|
||||
* Fixes configdir permissions preventing Sentinel to update the config file
|
||||
|
||||
## 6.1.1 - *2022-02-03*
|
||||
|
||||
- Remove delivery and move to calling RSpec directly via a reusable workflow
|
||||
* Remove delivery and move to calling RSpec directly via a reusable workflow
|
||||
|
||||
## 6.1.0 - *2021-09-15*
|
||||
|
||||
- Add protected mode to sentinel configuration file
|
||||
* Add protected mode to sentinel configuration file
|
||||
|
||||
## 6.0.0 - *2021-09-09*
|
||||
|
||||
- Set unified_mode true for Chef 17+ support
|
||||
- Require Chef 15.3+ for unified_mode
|
||||
- Require Chef 16 for user_ulimit resource
|
||||
- Remove dependency on the ulimit cookbook
|
||||
- Switch from using the selinux_policy cookbook to the selinux cookbook
|
||||
- The selinux_policy cookbook is now deprecated. The resources have been moved
|
||||
* Set unified_mode true for Chef 17+ support
|
||||
* Require Chef 15.3+ for unified_mode
|
||||
* Require Chef 16 for user_ulimit resource
|
||||
* Remove dependency on the ulimit cookbook
|
||||
* Switch from using the selinux_policy cookbook to the selinux cookbook
|
||||
* The selinux_policy cookbook is now deprecated. The resources have been moved
|
||||
to the selinux cookbook
|
||||
|
||||
## 5.0.0 - *2021-09-08*
|
||||
|
||||
- resolved cookstyle error: attributes/default.rb:74:40 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
|
||||
* resolved cookstyle error: attributes/default.rb:74:40 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
|
||||
|
||||
## 4.3.2 - *2021-08-30*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 4.3.1 - *2021-06-01*
|
||||
|
||||
- Standardise files with files in sous-chefs/repo-management
|
||||
* Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 4.3.0 - *2021-05-19*
|
||||
|
||||
- Fix disable recipe service naming for systemd
|
||||
* Fix disable recipe service naming for systemd
|
||||
|
||||
## 4.2.0 (2020-09-14)
|
||||
|
||||
- New server option 'permissions' to override default (0644) unix permissions on config file
|
||||
* New server option 'permissions' to override default (0644) unix permissions on config file
|
||||
|
||||
## 4.1.2 (2020-09-11)
|
||||
|
||||
- Pull the disable_os_default recipe from the default one
|
||||
* Pull the disable_os_default recipe from the default one
|
||||
|
||||
## 4.1.1 (2020-08-14)
|
||||
|
||||
- Properly perform version check when needed in redis.conf template
|
||||
* Properly perform version check when needed in redis.conf template
|
||||
|
||||
## 4.1.0 (2020-05-05)
|
||||
|
||||
- Simplify platform check logic
|
||||
- Remove the deprecated ChefSpec coverage report
|
||||
- Migrate to actions for testing
|
||||
* Simplify platform check logic
|
||||
* Remove the deprecated ChefSpec coverage report
|
||||
* Migrate to actions for testing
|
||||
|
||||
## 4.0.0 (2019-09-19)
|
||||
|
||||
- Enable testing in CircleCI
|
||||
- Removed build essentials cookbook dependancy
|
||||
- Minimum Chef is now 14
|
||||
- Removed tests for Debian 8
|
||||
- Added support for chef 15
|
||||
- configure recipe now sets `['redisio']['servers']` using override instead of normal in line with new chef best practices
|
||||
* Enable testing in CircleCI
|
||||
* Removed build essentials cookbook dependancy
|
||||
* Minimum Chef is now 14
|
||||
* Removed tests for Debian 8
|
||||
* Added support for chef 15
|
||||
* configure recipe now sets `['redisio']['servers']` using override instead of normal in line with new chef best practices
|
||||
|
||||
## 3.0.0 (2018-11-27)
|
||||
|
||||
- This cookbook is now maintained by the Sous Chefs. If you're interested in helping with maintenance or learning more check out <https://sous-chefs.org/> Thank you Brian Bianco for the work you've done over the years on this cookbook. We'll be sure to take good care of it.
|
||||
- This cookbook now requires Chef 13 or later
|
||||
- Incompatibilities with the latest selinux_policy cookbook have been resolved by using Chef's built in selinux helpers
|
||||
- All Chefstyle warnings have been resolved
|
||||
- Contributing.md and CODE_OF_CONDUCT.md files have been added
|
||||
- The build_essential resource is now directly used so that the built in resource in Chef 14+ can be used. This increases the required build-essential cookbook to 5.0+
|
||||
- Duplicate dependencies in the Berksfile have been removed
|
||||
- The chefignore file has been updated to prevent more unnecessary files from being uploaded to the chef server
|
||||
- Data bags are now loaded with the data_bag_item helper instead of Chef::EncryptedDataBagItem.load directly
|
||||
- Testing has been updated to use Delivery Local Mode which is built into ChefDK. The legacy Rakefile, Vagrantfile, Thorfile, and Cheffile have been removed
|
||||
- Platforms in Test Kitchen configurations have been updated and dokken images are now used in dokken
|
||||
* This cookbook is now maintained by the Sous Chefs. If you're interested in helping with maintenance or learning more check out <https://sous-chefs.org/> Thank you Brian Bianco for the work you've done over the years on this cookbook. We'll be sure to take good care of it.
|
||||
* This cookbook now requires Chef 13 or later
|
||||
* Incompatibilities with the latest selinux_policy cookbook have been resolved by using Chef's built in selinux helpers
|
||||
* All Chefstyle warnings have been resolved
|
||||
* Contributing.md and CODE_OF_CONDUCT.md files have been added
|
||||
* The build_essential resource is now directly used so that the built in resource in Chef 14+ can be used. This increases the required build-essential cookbook to 5.0+
|
||||
* Duplicate dependencies in the Berksfile have been removed
|
||||
* The chefignore file has been updated to prevent more unnecessary files from being uploaded to the chef server
|
||||
* Data bags are now loaded with the data_bag_item helper instead of Chef::EncryptedDataBagItem.load directly
|
||||
* Testing has been updated to use Delivery Local Mode which is built into ChefDK. The legacy Rakefile, Vagrantfile, Thorfile, and Cheffile have been removed
|
||||
* Platforms in Test Kitchen configurations have been updated and dokken images are now used in dokken
|
||||
|
||||
## 2.7.2 (2018-09-30)
|
||||
|
||||
- fixes sentinal cluster init script by providing missing LSB statements ([#374])
|
||||
* fixes sentinal cluster init script by providing missing LSB statements ([#374])
|
||||
|
||||
## 2.7.1 (2018-03-30)
|
||||
|
||||
- fixes sentinal config where `announce-ip` was being given the value of `announce-port` improperly ([#354])
|
||||
* fixes sentinal config where `announce-ip` was being given the value of `announce-port` improperly ([#354])
|
||||
|
||||
## 2.7.0 (2018-03-28)
|
||||
|
||||
- enables diskless replication configuration for versions `~> 2.6 || ~> 3.0` [#340](https://github.com/brianbianco/redisio/pull/340)
|
||||
- adds chef 13 compatability [#350](https://github.com/brianbianco/redisio/pull/350)
|
||||
* enables diskless replication configuration for versions `~> 2.6 || ~> 3.0` [#340](https://github.com/brianbianco/redisio/pull/340)
|
||||
* adds chef 13 compatability [#350](https://github.com/brianbianco/redisio/pull/350)
|
||||
|
||||
## 2.6.1 (2017-05-10)
|
||||
|
||||
- Restrict aof-load-truncated to redis 3+ ([#343](https://github.com/brianbianco/redisio/pull/343))
|
||||
- Fix Redis 2.4.x config ([#344](https://github.com/brianbianco/redisio/pull/344))
|
||||
* Restrict aof-load-truncated to redis 3+ ([#343](https://github.com/brianbianco/redisio/pull/343))
|
||||
* Fix Redis 2.4.x config ([#344](https://github.com/brianbianco/redisio/pull/344))
|
||||
|
||||
## 2.6.0 (2017-05-09)
|
||||
|
||||
- Update 'bind' config comments ([#293](https://github.com/brianbianco/redisio/pull/293))
|
||||
- Add disable_os_default recipe ([#224](https://github.com/brianbianco/redisio/pull/224))
|
||||
- Use the config's ulimits if set and is > max_clients ([#234](https://github.com/brianbianco/redisio/pull/234))
|
||||
- Add Travis config ([#299](https://github.com/brianbianco/redisio/pull/299))
|
||||
- Fix test failures (FoodCritic and Rubocop) ([#298](https://github.com/brianbianco/redisio/pull/298))
|
||||
- Fix TravisCI builds ([#300](https://github.com/brianbianco/redisio/pull/300))
|
||||
- Add repl-backlog-size, repl-backlog-ttl, and aof-load-truncated options ([#278](https://github.com/brianbianco/redisio/pull/278))
|
||||
- Add sentinel_bind to bind sentinel to different IPs ([#306](https://github.com/brianbianco/redisio/pull/306))
|
||||
- Cleanup deprecation warnings ([#301](https://github.com/brianbianco/redisio/pull/301))
|
||||
- Fix version detection with epoch version numbers from deb/ubuntu ([#294](https://github.com/brianbianco/redisio/pull/294))
|
||||
- Restrict VM redis config to <= 2.4 ([#322](https://github.com/brianbianco/redisio/pull/322))
|
||||
- Rename_commands should be checked for nil before empty ([#311](https://github.com/brianbianco/redisio/pull/311))
|
||||
- Fixup foodcritic, rubocop, and kitchen testing ([#324](https://github.com/brianbianco/redisio/pull/324))
|
||||
- Note: this drops support for Chef < 11
|
||||
- Add min-slaves redis options ([#313](https://github.com/brianbianco/redisio/pull/313))
|
||||
- Allow /etc/init start after sigterm from system or user ([#310](https://github.com/brianbianco/redisio/pull/310))
|
||||
- Check user existence with Etc, not ohai node attributes ([#303](https://github.com/brianbianco/redisio/pull/303))
|
||||
- Various systemd-related improvements ([#302](https://github.com/brianbianco/redisio/pull/302))
|
||||
- Update serverspec testing with correct OS's for systemd ([#329](https://github.com/brianbianco/redisio/pull/329))
|
||||
- Add kitchen-dokken testing to Travis ([#330](https://github.com/brianbianco/redisio/pull/330))
|
||||
- Add fedora-25 to kitchen testing and clean up kitchen config ([#331](https://github.com/brianbianco/redisio/pull/331))
|
||||
- Fix systemd paths for sentinel service ([#332](https://github.com/brianbianco/redisio/pull/332))
|
||||
- Add redis-package and sentinel to Travis kitchen verify ([#334](https://github.com/brianbianco/redisio/pull/334))
|
||||
- Add breadcrumb-file creation condition as attribute ([#268](https://github.com/brianbianco/redisio/pull/268))
|
||||
- Fix cluster options in README ([#333](https://github.com/brianbianco/redisio/pull/333))
|
||||
- Fix systemd loader to use descriptors instead of max_clients+32 ([#338](https://github.com/brianbianco/redisio/pull/338))
|
||||
- Add SELinux support ([#305](https://github.com/brianbianco/redisio/pull/305))
|
||||
- Make source of redis.conf template configurable ([#341](https://github.com/brianbianco/redisio/pull/341))
|
||||
- Support sentinel notification-script and client-reconfig-script ([#342](https://github.com/brianbianco/redisio/pull/342))
|
||||
* Update 'bind' config comments ([#293](https://github.com/brianbianco/redisio/pull/293))
|
||||
* Add disable_os_default recipe ([#224](https://github.com/brianbianco/redisio/pull/224))
|
||||
* Use the config's ulimits if set and is > max_clients ([#234](https://github.com/brianbianco/redisio/pull/234))
|
||||
* Add Travis config ([#299](https://github.com/brianbianco/redisio/pull/299))
|
||||
* Fix test failures (FoodCritic and Rubocop) ([#298](https://github.com/brianbianco/redisio/pull/298))
|
||||
* Fix TravisCI builds ([#300](https://github.com/brianbianco/redisio/pull/300))
|
||||
* Add repl-backlog-size, repl-backlog-ttl, and aof-load-truncated options ([#278](https://github.com/brianbianco/redisio/pull/278))
|
||||
* Add sentinel_bind to bind sentinel to different IPs ([#306](https://github.com/brianbianco/redisio/pull/306))
|
||||
* Cleanup deprecation warnings ([#301](https://github.com/brianbianco/redisio/pull/301))
|
||||
* Fix version detection with epoch version numbers from deb/ubuntu ([#294](https://github.com/brianbianco/redisio/pull/294))
|
||||
* Restrict VM redis config to <= 2.4 ([#322](https://github.com/brianbianco/redisio/pull/322))
|
||||
* Rename_commands should be checked for nil before empty ([#311](https://github.com/brianbianco/redisio/pull/311))
|
||||
* Fixup foodcritic, rubocop, and kitchen testing ([#324](https://github.com/brianbianco/redisio/pull/324))
|
||||
* Note: this drops support for Chef < 11
|
||||
* Add min-slaves redis options ([#313](https://github.com/brianbianco/redisio/pull/313))
|
||||
* Allow /etc/init start after sigterm from system or user ([#310](https://github.com/brianbianco/redisio/pull/310))
|
||||
* Check user existence with Etc, not ohai node attributes ([#303](https://github.com/brianbianco/redisio/pull/303))
|
||||
* Various systemd-related improvements ([#302](https://github.com/brianbianco/redisio/pull/302))
|
||||
* Update serverspec testing with correct OS's for systemd ([#329](https://github.com/brianbianco/redisio/pull/329))
|
||||
* Add kitchen-dokken testing to Travis ([#330](https://github.com/brianbianco/redisio/pull/330))
|
||||
* Add fedora-25 to kitchen testing and clean up kitchen config ([#331](https://github.com/brianbianco/redisio/pull/331))
|
||||
* Fix systemd paths for sentinel service ([#332](https://github.com/brianbianco/redisio/pull/332))
|
||||
* Add redis-package and sentinel to Travis kitchen verify ([#334](https://github.com/brianbianco/redisio/pull/334))
|
||||
* Add breadcrumb-file creation condition as attribute ([#268](https://github.com/brianbianco/redisio/pull/268))
|
||||
* Fix cluster options in README ([#333](https://github.com/brianbianco/redisio/pull/333))
|
||||
* Fix systemd loader to use descriptors instead of max_clients+32 ([#338](https://github.com/brianbianco/redisio/pull/338))
|
||||
* Add SELinux support ([#305](https://github.com/brianbianco/redisio/pull/305))
|
||||
* Make source of redis.conf template configurable ([#341](https://github.com/brianbianco/redisio/pull/341))
|
||||
* Support sentinel notification-script and client-reconfig-script ([#342](https://github.com/brianbianco/redisio/pull/342))
|
||||
|
||||
## 2.5.0 (2016-09-15)
|
||||
|
||||
- Ubuntu 14 added as tested platform. (#264)
|
||||
- FreeBSD-10.3 support added. (#279)
|
||||
- installation from source is not supported
|
||||
- setting ulimits is not supported
|
||||
- Encrypted databag support added. (#228)
|
||||
- Systemd nofile limit fixed. (#228)
|
||||
- Announce-ip and announce-port directives for sentinel added. (#228)
|
||||
- Disabling safe_install in the install recipe allowed. (#284)
|
||||
- Protected-mode added as optional (#275, #289)
|
||||
- Fixes nil exception when installing sentinel on non-debian and non-rhel platforms (#288)
|
||||
* Ubuntu 14 added as tested platform. (#264)
|
||||
* FreeBSD-10.3 support added. (#279)
|
||||
* installation from source is not supported
|
||||
* setting ulimits is not supported
|
||||
* Encrypted databag support added. (#228)
|
||||
* Systemd nofile limit fixed. (#228)
|
||||
* Announce-ip and announce-port directives for sentinel added. (#228)
|
||||
* Disabling safe_install in the install recipe allowed. (#284)
|
||||
* Protected-mode added as optional (#275, #289)
|
||||
* Fixes nil exception when installing sentinel on non-debian and non-rhel platforms (#288)
|
||||
|
||||
## 2.4.2 (2016-04-08)
|
||||
|
||||
- Created a 2.4.1 tag but somehow the metadata file wasn't updated. Instead
|
||||
* Created a 2.4.1 tag but somehow the metadata file wasn't updated. Instead
|
||||
of deleting a pushed tag, creating a new tag and updating metdatafile. Aside
|
||||
from the version number, this is an identical release to 2.4.1
|
||||
|
||||
## 2.4.1
|
||||
|
||||
- Increases default clusternodetimeout value from 5 to 5000
|
||||
- Allows you to set version for package based install
|
||||
- Sets UID of redis data directory if it is present
|
||||
- Install resource should now only notify when an installation actually occurs
|
||||
- Adds config options
|
||||
- tcpbacklog
|
||||
- rdbcompression
|
||||
- rdbchecksum
|
||||
- dbfilename
|
||||
- slavereadyonly
|
||||
- repldisabletcpnodelay
|
||||
- slavepriority
|
||||
- listmaxziplistentries
|
||||
- listmaxziplistvalue
|
||||
- hllsparsemaxbytes
|
||||
- Add CentOS 7 support with systemd configs
|
||||
- Fixes bug in ulimit resource guard
|
||||
- Fixes bug in sentinel required parameters sanity check
|
||||
- Adds --no-same-owner to untar command during install to fix NFS related issues
|
||||
- Adds support for rename_commands config option
|
||||
- Adds option to stop chef from managing sentinel configs after writing once
|
||||
- Adds config option rename_commands
|
||||
- Allow instance 'save' to be string or array
|
||||
- Adds sources_url and issues_url with guards to be Chef 12 compatible
|
||||
- Bumps Redis source version to 2.8.20
|
||||
- Fixes cluster settings with wrong attribute names
|
||||
- Monitor multiple masters with sentinel
|
||||
- Add support in sentinel resource for an array of masters to monitor, with backwards compatibility for the older attributes, fixes #73. Replaces #87.
|
||||
- Introduce a test-kitchen test for sentinel watching multiple masters.
|
||||
- Incidentally, fixes #193 as well, since it adds a master name attribute for each master.
|
||||
- Fixes path for pidfile in sentinel init script
|
||||
- Additional error checking and backwards compatibility for sentinel attribute keys
|
||||
* Increases default clusternodetimeout value from 5 to 5000
|
||||
* Allows you to set version for package based install
|
||||
* Sets UID of redis data directory if it is present
|
||||
* Install resource should now only notify when an installation actually occurs
|
||||
* Adds config options
|
||||
* tcpbacklog
|
||||
* rdbcompression
|
||||
* rdbchecksum
|
||||
* dbfilename
|
||||
* slavereadyonly
|
||||
* repldisabletcpnodelay
|
||||
* slavepriority
|
||||
* listmaxziplistentries
|
||||
* listmaxziplistvalue
|
||||
* hllsparsemaxbytes
|
||||
* Add CentOS 7 support with systemd configs
|
||||
* Fixes bug in ulimit resource guard
|
||||
* Fixes bug in sentinel required parameters sanity check
|
||||
* Adds --no-same-owner to untar command during install to fix NFS related issues
|
||||
* Adds support for rename_commands config option
|
||||
* Adds option to stop chef from managing sentinel configs after writing once
|
||||
* Adds config option rename_commands
|
||||
* Allow instance 'save' to be string or array
|
||||
* Adds sources_url and issues_url with guards to be Chef 12 compatible
|
||||
* Bumps Redis source version to 2.8.20
|
||||
* Fixes cluster settings with wrong attribute names
|
||||
* Monitor multiple masters with sentinel
|
||||
* Add support in sentinel resource for an array of masters to monitor, with backwards compatibility for the older attributes, fixes #73. Replaces #87.
|
||||
* Introduce a test-kitchen test for sentinel watching multiple masters.
|
||||
* Incidentally, fixes #193 as well, since it adds a master name attribute for each master.
|
||||
* Fixes path for pidfile in sentinel init script
|
||||
* Additional error checking and backwards compatibility for sentinel attribute keys
|
||||
|
||||
## 2.3.0 (2015-04-08)
|
||||
|
||||
- Add support for installing by distribution package for CentOS (#180)
|
||||
- Add conditionals to check for redis 3 that was released recently (#183)
|
||||
- Prevent `usermod: user redis is currently logged in` (#176)
|
||||
- Use correct sentinel port in default sentinel instance (#157)
|
||||
- Sentinel instances attribute (`node['redisio']['sentinels']`) should behave like Redis instances attribute (#160)
|
||||
- Add Rakefile and unit tests for verifying issues fixed are actually resolved (#158)
|
||||
- Fix serverspec tests to properly use sysv-init scripts on systemd distributions (#185)
|
||||
- Update documentation to reflect correct current redis version used for source installs (#151)
|
||||
- Update documentation to indicate that ulimit and build-essential are both dependencies (#165)
|
||||
- Update documentation to reflect that uninstall recipe is no longer available
|
||||
- Update documentation to reflect correct mirror in README.md, change was from 2.1.0 (#175)
|
||||
- Update documentation to reflect that cookbook uses `node['redisio']`, not `node['redis']` (#174)
|
||||
- Markdown formatting improvements in the README.md (#168, #172)
|
||||
* Add support for installing by distribution package for CentOS (#180)
|
||||
* Add conditionals to check for redis 3 that was released recently (#183)
|
||||
* Prevent `usermod: user redis is currently logged in` (#176)
|
||||
* Use correct sentinel port in default sentinel instance (#157)
|
||||
* Sentinel instances attribute (`node['redisio']['sentinels']`) should behave like Redis instances attribute (#160)
|
||||
* Add Rakefile and unit tests for verifying issues fixed are actually resolved (#158)
|
||||
* Fix serverspec tests to properly use sysv-init scripts on systemd distributions (#185)
|
||||
* Update documentation to reflect correct current redis version used for source installs (#151)
|
||||
* Update documentation to indicate that ulimit and build-essential are both dependencies (#165)
|
||||
* Update documentation to reflect that uninstall recipe is no longer available
|
||||
* Update documentation to reflect correct mirror in README.md, change was from 2.1.0 (#175)
|
||||
* Update documentation to reflect that cookbook uses `node['redisio']`, not `node['redis']` (#174)
|
||||
* Markdown formatting improvements in the README.md (#168, #172)
|
||||
|
||||
## 2.2.4 (2014-10-04)
|
||||
|
||||
- Updates installed version of redis to the latest stable (2.8.17)
|
||||
- Fixes backwards compatability bug with older version of redis (namely 2.6.x series) related to keyspaces
|
||||
* Updates installed version of redis to the latest stable (2.8.17)
|
||||
* Fixes backwards compatability bug with older version of redis (namely 2.6.x series) related to keyspaces
|
||||
|
||||
## 2.2.3 (2014-08-25)
|
||||
|
||||
- Bug Fix: Repackages the chef supermarket releaes with gnutar instead of BSD tar
|
||||
* Bug Fix: Repackages the chef supermarket releaes with gnutar instead of BSD tar
|
||||
|
||||
## 2.2.2 (2014-08-22)
|
||||
|
||||
- Please refer to changelog for 2.0.0.
|
||||
- If moving from 1.7.x this release has many breaking changes. You will likely need to update your wrapper cookbook or role.
|
||||
- Added test-kitchen and serverspec coverage for both redis and redis_sentinel
|
||||
- Added cookbook testing information to readme
|
||||
- Bug fix for a fix that was introduced to resolve foodcritic rule fc002
|
||||
- Fix init script to use su instead of sudo for ubuntu debian fedora
|
||||
- Fix sentinel_enable recipe to properly run if using default attributes
|
||||
- Save property for redis config now is defined by using an array
|
||||
- Small changes to default configuration options to bring in line with redis defaults.
|
||||
- Added options for the following
|
||||
- tcp-keepalive
|
||||
* Please refer to changelog for 2.0.0.
|
||||
* If moving from 1.7.x this release has many breaking changes. You will likely need to update your wrapper cookbook or role.
|
||||
* Added test-kitchen and serverspec coverage for both redis and redis_sentinel
|
||||
* Added cookbook testing information to readme
|
||||
* Bug fix for a fix that was introduced to resolve foodcritic rule fc002
|
||||
* Fix init script to use su instead of sudo for ubuntu debian fedora
|
||||
* Fix sentinel_enable recipe to properly run if using default attributes
|
||||
* Save property for redis config now is defined by using an array
|
||||
* Small changes to default configuration options to bring in line with redis defaults.
|
||||
* Added options for the following
|
||||
* tcp-keepalive
|
||||
|
||||
## 2.2.1
|
||||
|
||||
- Allow sentinel to control both redis and redis-sentinel configs depending on attribute `redisio.sentinel.manage_config` state.
|
||||
* Allow sentinel to control both redis and redis-sentinel configs depending on attribute `redisio.sentinel.manage_config` state.
|
||||
|
||||
## 2.2.0
|
||||
|
||||
- Adds behavior to allow the cookbook to NOT manage the redis config files as redis itself will write to them now if you are using sentinel
|
||||
* Adds behavior to allow the cookbook to NOT manage the redis config files as redis itself will write to them now if you are using sentinel
|
||||
|
||||
## 2.1.0
|
||||
|
||||
- Adds options for the following
|
||||
- lua-time-limit
|
||||
- slowlog-logs-slower-than
|
||||
- slowlog-max-len
|
||||
- notify-keyspace-events
|
||||
- client-output-buffer-limit
|
||||
- hz
|
||||
- aof-rewrite-incremental-fsync
|
||||
- Removes the uninstall recipe and resource.
|
||||
- Adds the ability to skip the default recipe calling install and configure by setting redisio bypass_setup attribute to true
|
||||
- Adds support for redis sentinel [Thanks to rcleere, Ryan Walker]
|
||||
- Splits up the install resource into separate install and configure resources [Thanks to rcleere]
|
||||
- By default now calls _install_prereqs, install, and configure in the default recipe.
|
||||
- Changes default version of redis to install to 2.8.5
|
||||
- Now depends on the build-essential cookbook.
|
||||
- Fixes issue #76 - Default settings save as empty string breaks install
|
||||
- Switches mirror server from googlefiles to redis.io. If you are using version of redis before 2.6.16 you will need to override the mirror server attribute
|
||||
* Adds options for the following
|
||||
* lua-time-limit
|
||||
* slowlog-logs-slower-than
|
||||
* slowlog-max-len
|
||||
* notify-keyspace-events
|
||||
* client-output-buffer-limit
|
||||
* hz
|
||||
* aof-rewrite-incremental-fsync
|
||||
* Removes the uninstall recipe and resource.
|
||||
* Adds the ability to skip the default recipe calling install and configure by setting redisio bypass_setup attribute to true
|
||||
* Adds support for redis sentinel [Thanks to rcleere, Ryan Walker]
|
||||
* Splits up the install resource into separate install and configure resources [Thanks to rcleere]
|
||||
* By default now calls _install_prereqs, install, and configure in the default recipe.
|
||||
* Changes default version of redis to install to 2.8.5
|
||||
* Now depends on the build-essential cookbook.
|
||||
* Fixes issue #76 - Default settings save as empty string breaks install
|
||||
* Switches mirror server from googlefiles to redis.io. If you are using version of redis before 2.6.16 you will need to override the mirror server attribute
|
||||
to use the old site with archived versions.
|
||||
- Adds a Vagrant file!
|
||||
- maxmemory will be rounded when calculated as a percentage
|
||||
- Add stop-writes-on-bgsave-error config option
|
||||
- Changes default log level from verbose to notice
|
||||
- Adds configuration options for ziplists and active rehashing
|
||||
- Adds support for passing the address attribute as an array. This is to support the redis 2.8 series which allows binding to multiple addresses
|
||||
- Fixes a bug where multiple redis instances were using the same swapfile (only for version of redis 2.4 and below)
|
||||
- Changes the job_control per instance attribute to a global one.
|
||||
- Adds a status command to the init.d script, uses this in the initd based service for checking status
|
||||
* Adds a Vagrant file!
|
||||
* maxmemory will be rounded when calculated as a percentage
|
||||
* Add stop-writes-on-bgsave-error config option
|
||||
* Changes default log level from verbose to notice
|
||||
* Adds configuration options for ziplists and active rehashing
|
||||
* Adds support for passing the address attribute as an array. This is to support the redis 2.8 series which allows binding to multiple addresses
|
||||
* Fixes a bug where multiple redis instances were using the same swapfile (only for version of redis 2.4 and below)
|
||||
* Changes the job_control per instance attribute to a global one.
|
||||
* Adds a status command to the init.d script, uses this in the initd based service for checking status
|
||||
|
||||
## 2.0.0
|
||||
|
||||
! THIS RELEASE HAS MANY BREAKING CHANGES !
|
||||
! Your old role file will most likely not work !
|
||||
|
||||
- Supports redis 2.8 and its use of the empty string for stdout in the logfile option
|
||||
- Allows the user to specify required_start and required_start when using the init scripts
|
||||
- Warns a user if they have syslogenabled set to yes and also have logfile set
|
||||
* Supports redis 2.8 and its use of the empty string for stdout in the logfile option
|
||||
* Allows the user to specify required_start and required_start when using the init scripts
|
||||
* Warns a user if they have syslogenabled set to yes and also have logfile set
|
||||
|
||||
## 1.7.1 (2014-02-10)
|
||||
|
||||
- Bumps default version of redis to 2.6.17
|
||||
- Changes the redis download mirror to redis.io
|
||||
- Fixes #76 - Default settings save as empty string breaks install. [Thanks to astlock]
|
||||
- Fixes bug with nil file resource for logfile. [Thanks to chrismoos]
|
||||
* Bumps default version of redis to 2.6.17
|
||||
* Changes the redis download mirror to redis.io
|
||||
* Fixes #76 - Default settings save as empty string breaks install. [Thanks to astlock]
|
||||
* Fixes bug with nil file resource for logfile. [Thanks to chrismoos]
|
||||
|
||||
## 1.7.0 (2013-07-25)
|
||||
|
||||
- Adds support for address attribute as an array or string. This is to support the feature that will be introduced in redis 2.8
|
||||
* Adds support for address attribute as an array or string. This is to support the feature that will be introduced in redis 2.8
|
||||
|
||||
## 1.6.0 (2013-06-27)
|
||||
|
||||
- Fixes a bug when using a percentage for max memory. [Thanks to organicveggie]
|
||||
- Allows installation of redis into custom directory. [Thanks to organicveggie, rcleere]
|
||||
- Bumps the default installed version of redis to the new stable, 2.6.14
|
||||
* Fixes a bug when using a percentage for max memory. [Thanks to organicveggie]
|
||||
* Allows installation of redis into custom directory. [Thanks to organicveggie, rcleere]
|
||||
* Bumps the default installed version of redis to the new stable, 2.6.14
|
||||
|
||||
## 1.5.0 (2013-03-30)
|
||||
|
||||
- Forces maxmemory to a string inside of install provider so it will not explode if you pass in an int. [Thanks to sprack]
|
||||
- Strips leading directory from downloaded tarball, and extracts into a newly created directory. This allows more versatility for where the package can be installed from (Github / BitBucket) [Thanks to dim]
|
||||
- Adds options for Redis Cluster [Thanks to jrallison]
|
||||
- Adds a call to ulimit into the init script, it was not honoring the limits set by the ulimit cookbook for some users. [Thanks to mike-yesware]
|
||||
* Forces maxmemory to a string inside of install provider so it will not explode if you pass in an int. [Thanks to sprack]
|
||||
* Strips leading directory from downloaded tarball, and extracts into a newly created directory. This allows more versatility for where the package can be installed from (Github / BitBucket) [Thanks to dim]
|
||||
* Adds options for Redis Cluster [Thanks to jrallison]
|
||||
* Adds a call to ulimit into the init script, it was not honoring the limits set by the ulimit cookbook for some users. [Thanks to mike-yesware]
|
||||
|
||||
## 1.4.1 (2013-02-27)
|
||||
|
||||
- Removes left over debugging statement
|
||||
* Removes left over debugging statement
|
||||
|
||||
## 1.4.0 (2013-02-27)
|
||||
|
||||
- ACTUALLY fixes the use of upstart and redis. Redis no longer daemonizes itself when using job_control type upstart and allows upstart to handle this
|
||||
- Adds dependency on the ulimit cookbook and allows you to set the ulimits for the redis instance users.
|
||||
- Adds associated node attribute for the ulimit. It defaults to the special value 0, which causes the cookbook to use maxclients + 32. 32 is the number of file descriptors redis needs itself
|
||||
- You can disable the use of the ulimits by setting the node attribute for it to "false" or "nil"
|
||||
- Comments out the start on by default in the upstart script. This will get uncommented by the upstart provider when the :enable action is called on it
|
||||
* ACTUALLY fixes the use of upstart and redis. Redis no longer daemonizes itself when using job_control type upstart and allows upstart to handle this
|
||||
* Adds dependency on the ulimit cookbook and allows you to set the ulimits for the redis instance users.
|
||||
* Adds associated node attribute for the ulimit. It defaults to the special value 0, which causes the cookbook to use maxclients + 32. 32 is the number of file descriptors redis needs itself
|
||||
* You can disable the use of the ulimits by setting the node attribute for it to "false" or "nil"
|
||||
* Comments out the start on by default in the upstart script. This will get uncommented by the upstart provider when the :enable action is called on it
|
||||
|
||||
## 1.3.2 (2013-02-26)
|
||||
|
||||
- Changes calls to Chef::ShellOut to Mixlib::ShellOut
|
||||
* Changes calls to Chef::ShellOut to Mixlib::ShellOut
|
||||
|
||||
## 1.3.1 (2013-02-26)
|
||||
|
||||
- Fixes bug in upstart script to create pid directory if it does not exist
|
||||
* Fixes bug in upstart script to create pid directory if it does not exist
|
||||
|
||||
## 1.3.0 (2013-02-20)
|
||||
|
||||
- Adds upstart support. This was a much requested feature.
|
||||
- Fixes bug in uninstall resource that would have prevented it from uninstalling named servers.
|
||||
- Reworks the init script to take into account the IP redis is listening on, and if it is listening on a socket.
|
||||
- Adds an attribute called "shutdown_save" which will explicitly call save on redis shutdown
|
||||
- Updates the README.md with a shorter and hopefully equally as useful usage section
|
||||
- maxmemory attribute now allows the use of percentages. You must include a % sign after the value.
|
||||
- Bumps default version of redis to install to the current stable, 2.6.10
|
||||
* Adds upstart support. This was a much requested feature.
|
||||
* Fixes bug in uninstall resource that would have prevented it from uninstalling named servers.
|
||||
* Reworks the init script to take into account the IP redis is listening on, and if it is listening on a socket.
|
||||
* Adds an attribute called "shutdown_save" which will explicitly call save on redis shutdown
|
||||
* Updates the README.md with a shorter and hopefully equally as useful usage section
|
||||
* maxmemory attribute now allows the use of percentages. You must include a % sign after the value.
|
||||
* Bumps default version of redis to install to the current stable, 2.6.10
|
||||
|
||||
## 1.2.0 (2013-02-06)
|
||||
|
||||
- Fixes bug related to where the template source resides when using the LWRP outside of the redisio cookbook
|
||||
- Fixes bug where the version method was not properly parsing version strings in redis 2.6.x, as the version string from redis-server -v changed
|
||||
- Fixes bug in default attributes for fedora default redis data directory
|
||||
- Now uses chefs service resource for each redis instance instead of using a custom redisio_service resource. This cleans up many issues, including a lack of updated_by_last_action
|
||||
- The use of the redisio_service resource is deprecated. Use the redis port_number instead.
|
||||
- The default version of redis has been bumped to the current stable, which is 2.6.9
|
||||
- Adds metadata.json to the gitignore file so that the cookbook can be submoduled.
|
||||
- Adds the ability to handle non standard bind address in the init scripts stop command
|
||||
- Adds attributes to allow redis to listen on a socket
|
||||
- Adds an attribute to allow redis service accounts to be created as system users, defaults this to true
|
||||
- Adds a per server "name" attribute that allows a server to use that instead of the port for its configuration files, service resource, and init script.
|
||||
- Shifts the responsbility for handling the case of default redis instances into the install recipe due to the behavior of arrays and deep merge
|
||||
* Fixes bug related to where the template source resides when using the LWRP outside of the redisio cookbook
|
||||
* Fixes bug where the version method was not properly parsing version strings in redis 2.6.x, as the version string from redis-server -v changed
|
||||
* Fixes bug in default attributes for fedora default redis data directory
|
||||
* Now uses chefs service resource for each redis instance instead of using a custom redisio_service resource. This cleans up many issues, including a lack of updated_by_last_action
|
||||
* The use of the redisio_service resource is deprecated. Use the redis port_number instead.
|
||||
* The default version of redis has been bumped to the current stable, which is 2.6.9
|
||||
* Adds metadata.json to the gitignore file so that the cookbook can be submoduled.
|
||||
* Adds the ability to handle non standard bind address in the init scripts stop command
|
||||
* Adds attributes to allow redis to listen on a socket
|
||||
* Adds an attribute to allow redis service accounts to be created as system users, defaults this to true
|
||||
* Adds a per server "name" attribute that allows a server to use that instead of the port for its configuration files, service resource, and init script.
|
||||
* Shifts the responsbility for handling the case of default redis instances into the install recipe due to the behavior of arrays and deep merge
|
||||
|
||||
## 1.1.0 (2012-08-21)
|
||||
|
||||
@@ -419,41 +493,41 @@ This file is used to list changes made in each version of the redisio cookbook.
|
||||
of this cookbook, it will not be able to stop your instance properly via the redis service provider, or the init script.
|
||||
If this happens to you, you can always log into the server and manually send a SIGTERM to redis
|
||||
|
||||
- Changed the init script to run redis as the specified redis user
|
||||
- Updated the default version of redis to 2.4.16
|
||||
- Setup a new directory structure for redis pid files. The install provider will now nest its pid directories in base_piddir/port number/redis_port.pid.
|
||||
- Added a RedisioHelper module in libraries. The recipe_eval method inside is used to wrap nested resources to allow for the proper resource update propigation. The install provider uses this.
|
||||
- The init script now properly respects the configdir attribute
|
||||
- Changed the redis data directories to be 775 instead of 755 (this allows multiple instances with different owners to write their data to the same shared dir so long as they are in a common group)
|
||||
- Changed default for maxclients to be 10000 instead of 0. This is to account for the fact that maxclients no longer supports 0 as 'unlimited' in the 2.6 series
|
||||
- Added logic to replace hash-max-ziplist-entries, hash-max-ziplist-value with hash-max-zipmap-entires, hash-max-zipmap-value when using 2.6 series
|
||||
- Added the ability to log to any file, not just syslog. Please do make sure after you set your file with the logfile attribute you also set syslogenabled to 'no'
|
||||
* Changed the init script to run redis as the specified redis user
|
||||
* Updated the default version of redis to 2.4.16
|
||||
* Setup a new directory structure for redis pid files. The install provider will now nest its pid directories in base_piddir/port number/redis_port.pid.
|
||||
* Added a RedisioHelper module in libraries. The recipe_eval method inside is used to wrap nested resources to allow for the proper resource update propigation. The install provider uses this.
|
||||
* The init script now properly respects the configdir attribute
|
||||
* Changed the redis data directories to be 775 instead of 755 (this allows multiple instances with different owners to write their data to the same shared dir so long as they are in a common group)
|
||||
* Changed default for maxclients to be 10000 instead of 0. This is to account for the fact that maxclients no longer supports 0 as 'unlimited' in the 2.6 series
|
||||
* Added logic to replace hash-max-ziplist-entries, hash-max-ziplist-value with hash-max-zipmap-entires, hash-max-zipmap-value when using 2.6 series
|
||||
* Added the ability to log to any file, not just syslog. Please do make sure after you set your file with the logfile attribute you also set syslogenabled to 'no'
|
||||
|
||||
## 1.0.3 (2012-05-02)
|
||||
|
||||
- Added changelog.md
|
||||
- Added a bunch more configuration options that were left out (default values left as they were before):
|
||||
- databases
|
||||
- slaveservestaledata
|
||||
- replpingslaveperiod
|
||||
- repltimeout
|
||||
- maxmemorysamples
|
||||
- noappendfsynconwrite
|
||||
- aofrewritepercentage
|
||||
- aofrewriteminsize
|
||||
* Added changelog.md
|
||||
* Added a bunch more configuration options that were left out (default values left as they were before):
|
||||
* databases
|
||||
* slaveservestaledata
|
||||
* replpingslaveperiod
|
||||
* repltimeout
|
||||
* maxmemorysamples
|
||||
* noappendfsynconwrite
|
||||
* aofrewritepercentage
|
||||
* aofrewriteminsize
|
||||
|
||||
It is worth nothing that since there is a configurable option for conf include files, and the fact that redis uses the most recently read configuration option... even if a new option where to show up, or and old one was not included they could be added using that pattern.
|
||||
|
||||
## 1.0.2 (2012-04-25)
|
||||
|
||||
- Merged in pull request from meskyanichi which improved the README.md and added a .gitignore
|
||||
- Added a "safe_install" node attribute which will prevent redis from installing anything if it exists already. Defaults to true.
|
||||
- Addedd a "redis_gem" recipe which will install the redis gem from ruby gems, added associated attributes. See README for me
|
||||
* Merged in pull request from meskyanichi which improved the README.md and added a .gitignore
|
||||
* Added a "safe_install" node attribute which will prevent redis from installing anything if it exists already. Defaults to true.
|
||||
* Addedd a "redis_gem" recipe which will install the redis gem from ruby gems, added associated attributes. See README for me
|
||||
|
||||
## 1.0.1 (2012-04-08)
|
||||
|
||||
- Added some prequisite checks for RHEL based distributions
|
||||
- Minor typos and formatting fixes in metadata.rb and README.md
|
||||
* Added some prequisite checks for RHEL based distributions
|
||||
* Minor typos and formatting fixes in metadata.rb and README.md
|
||||
|
||||
## 1.0.0 (2012-04-08)
|
||||
|
||||
|
||||
+57
-470
@@ -1,513 +1,100 @@
|
||||
# Redisio Cookbook
|
||||
|
||||
[](https://supermarket.chef.io/cookbooks/redisio)
|
||||
[](https://circleci.com/gh/sous-chefs/redisio)
|
||||
[](#backers)
|
||||
[](#sponsors)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
Please read the changelog when upgrading from the 1.x series to the 2.x series
|
||||
`redisio` is a resource-first Sous Chefs cookbook for installing Redis and managing Redis server and Sentinel instances with systemd.
|
||||
|
||||
## Description
|
||||
Upgrading from version 7 requires recipe and attribute migrations. Read the [version 8 upgrade guide](UPGRADING.md) before changing the cookbook constraint.
|
||||
|
||||
Website:: [https://github.com/sous-chefs/redisio](https://github.com/sous-chefs/redisio)
|
||||
## Supported Platforms
|
||||
|
||||
Installs and configures Redis server instances
|
||||
- Amazon Linux 2023
|
||||
- Debian 12 and 13
|
||||
- Rocky Linux 9
|
||||
- Ubuntu 22.04 and 24.04
|
||||
|
||||
## Maintainers
|
||||
## Resources
|
||||
|
||||
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).
|
||||
### Preferred resources
|
||||
|
||||
## Requirements
|
||||
- `redisio_install`
|
||||
- `redisio_server`
|
||||
- `redisio_sentinel_instance`
|
||||
|
||||
This cookbook builds redis from source or install it from packages, so it should work on any architecture for the supported distributions. Init scripts are installed into /etc/init.d/
|
||||
### Compatibility wrappers
|
||||
|
||||
It depends on the ulimit cookbook: [https://github.com/bmhatfield/chef-ulimit](https://github.com/bmhatfield/chef-ulimit) and the build-essentials cookbook: [https://github.com/chef-cookbooks/build-essential](https://github.com/opscode-cookbooks/build-essential)
|
||||
- `redisio_configure`
|
||||
- `redisio_sentinel`
|
||||
|
||||
### Platforms
|
||||
The compatibility wrappers preserve the old aggregate `servers` and `sentinels` payload shapes while delegating to the new per-instance resources.
|
||||
|
||||
* Debian, Ubuntu
|
||||
* CentOS, Red Hat, Fedora, Scientific Linux
|
||||
* FreeBSD
|
||||
## Basic Usage
|
||||
|
||||
### Testing
|
||||
|
||||
This cookbook is tested with Delivery's local mode run under Chef-DK and Test Kitchen
|
||||
|
||||
* delivery local all
|
||||
* kitchen test
|
||||
|
||||
Tested on:
|
||||
|
||||
* Centos 6
|
||||
* Centos 7
|
||||
* Debian 8
|
||||
* Fedora 28
|
||||
* Ubuntu 16.04
|
||||
|
||||
## Usage
|
||||
|
||||
The redisio cookbook contains LWRP for installing, configuring and managing redis and redis_sentinel.
|
||||
|
||||
The install recipe can build, compile and install redis from sources or install from packages. The configure recipe will configure redis and set up service resources. These resources will be named for the port of the redis server, unless a "name" attribute was specified. Example names would be: service["redis6379"] or service["redismaster"] if the name attribute was "master".
|
||||
_NOTE: currently installation from source is not supported for FreeBSD_
|
||||
|
||||
The most common use case for the redisio cookbook is to use the default recipe, followed by the enable recipe.
|
||||
|
||||
Another common use case is to use the default, and then call the service resources created by it from another cookbook.
|
||||
|
||||
It is important to note that changing the configuration options of redis does not make them take effect on the next chef run. Due to how redis works, you cannot reload a configuration without restarting the redis service. Redis does not offer a reload option, in order to have new options be used redis must be stopped and started.
|
||||
|
||||
You should make sure to set the ulimit for the user you want to run redis as to be higher than the max connections you allow.
|
||||
_NOTE: setting ulimit is not supported on FreeBSD since the ulimit cookbook doesn't support FreeBSD_
|
||||
|
||||
The disable recipe just stops redis and removes it from run levels.
|
||||
|
||||
The cookbook also contains a recipe to allow for the installation of the redis ruby gem.
|
||||
|
||||
Redis-sentinel will write configuration and state data back into its configuration file. This creates obvious problems when that config is managed by chef. By default, this cookbook will create the config file once, and then leave a breadcrumb that will guard against the file from being updated again.
|
||||
|
||||
### Recipes
|
||||
|
||||
* configure - This recipe is used to configure redis.
|
||||
* default - This is used to install the pre-requisites for building redis, and to make the LWRPs available
|
||||
* disable - This recipe can be used to disable the redis service and remove it from runlevels
|
||||
* enable - This recipe can be used to enable the redis services and add it to runlevels
|
||||
* install - This recipe is used to install redis.
|
||||
* redis_gem - This recipe can be used to install the redis ruby gem
|
||||
* sentinel - This recipe can be used to install and configure sentinel
|
||||
* sentinel_enable - This recipe can be used to enable the sentinel service(s)
|
||||
* disable_os_default - This recipe can be used to disable the default OS redis init script
|
||||
|
||||
### Role File Examples
|
||||
|
||||
#### Install redis and set up an instance with default settings on default port, and start the service through a role file
|
||||
### Install Redis from packages and start one instance
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
redisio_install 'default' do
|
||||
package_install true
|
||||
end
|
||||
|
||||
default_attributes({})
|
||||
```
|
||||
|
||||
##### Install redis with packages and set up an instance with default settings on default port, and start the service through a role file
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
package_install: true
|
||||
version:
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Install redis, give the instance a name, and use a unix socket
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'servers' => [
|
||||
{'name' => 'master', 'port' => '6379', 'unixsocket' => '/tmp/redis.sock', 'unixsocketperm' => '755'},
|
||||
]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Install redis and pull the password from an encrypted data bag
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'servers' => [
|
||||
{'data_bag_name' => 'redis', 'data_bag_item' => 'auth', 'data_bag_key' => 'password'},
|
||||
]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
###### Data Bag
|
||||
|
||||
```ruby
|
||||
{
|
||||
"id": "auth",
|
||||
"password": "abcdefghijklmnopqrstuvwxyz"
|
||||
}
|
||||
```
|
||||
|
||||
##### Install redis and set up two instances on the same server, on different ports, with one slaved to the other through a role file
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'servers' => [
|
||||
{'port' => '6379'},
|
||||
{'port' => '6380', 'slaveof' => { 'address' => '127.0.0.1', 'port' => '6379' }}
|
||||
]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Install redis and set up two instances, on the same server, on different ports, with the default data directory changed to /mnt/redis, and the second instance named
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'default_settings' => {'datadir' => '/mnt/redis'},
|
||||
'servers' => [{'port' => '6379'}, {'port' => '6380', 'name' => "MyInstance"}]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Install redis and set up three instances on the same server, changing the default data directory to /mnt/redis, each instance will use a different backup type, and one instance will use a different data dir
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'default_settings' => { 'datadir' => '/mnt/redis/'},
|
||||
'servers' => [
|
||||
{'port' => '6379','backuptype' => 'aof'},
|
||||
{'port' => '6380','backuptype' => 'both'},
|
||||
{'port' => '6381','backuptype' => 'rdb', 'datadir' => '/mnt/redis6381'}
|
||||
]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Install redis 2.4.11 (lower than the default version) and turn safe install off, for the event where redis is already installed This will use the default settings. Keep in mind the redis version will not actually be updated until you restart the service (either through the LWRP or manually)
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'safe_install' => false,
|
||||
'version' => '2.4.11'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
##### Install a single redis-sentinel to listen for a master on localhost and default port number
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio::sentinel]
|
||||
recipe[redisio::sentinel_enable]
|
||||
]
|
||||
```
|
||||
|
||||
#### Install redis and set up two instances, on the same server, on different ports, the second instance configuration file will be overwriten by chef
|
||||
|
||||
```ruby
|
||||
run_list *%w[
|
||||
recipe[redisio]
|
||||
recipe[redisio::enable]
|
||||
]
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'servers' => [{'port' => '6379'}, {'port' => '6380', 'breadcrumb' => false}]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## LWRP Examples
|
||||
|
||||
Instead of using my provided recipes, you can simply depend on the redisio cookbook in your metadata and use the LWRP's yourself. I will show a few examples of ways to use the LWRPS, detailed breakdown of options are below
|
||||
in the resources/providers section
|
||||
|
||||
### Install Resource
|
||||
|
||||
It is important to note that this call has certain expectations for example, it expects the redis package to be in the format `redis-VERSION.tar.gz'.
|
||||
|
||||
```ruby
|
||||
redisio_install "redis-installation" do
|
||||
version '2.6.9'
|
||||
download_url 'http://redis.googlecode.com/files/redis-2.6.9.tar.gz'
|
||||
safe_install false
|
||||
install_dir '/usr/local/'
|
||||
redisio_server '6379' do
|
||||
package_install true
|
||||
end
|
||||
```
|
||||
|
||||
### Configure Resource
|
||||
|
||||
The servers resource expects an array of hashes where each hash is required to contain at a key-value pair of 'port' => 'port numbers'.
|
||||
### Create a named secondary instance
|
||||
|
||||
```ruby
|
||||
redisio_configure "redis-servers" do
|
||||
version '2.6.9'
|
||||
default_settings node['redisio']['default_settings']
|
||||
servers node['redisio']['servers']
|
||||
base_piddir node['redisio']['base_piddir']
|
||||
redisio_server 'savetest' do
|
||||
package_install true
|
||||
port 16_379
|
||||
permissions '0640'
|
||||
save ['3600 1', '300 100', '60 10000']
|
||||
logfile '/var/log/redis/redis-16379.log'
|
||||
end
|
||||
```
|
||||
|
||||
### Sentinel Resource
|
||||
|
||||
The sentinel resource installs and configures all of your redis_sentinels defined in sentinel_instances
|
||||
|
||||
Using the sentinel resources:
|
||||
### Create a Sentinel instance
|
||||
|
||||
```ruby
|
||||
redisio_sentinel "redis-sentinels" do
|
||||
version '2.6.9'
|
||||
sentinel_defaults node['redisio']['sentinel_defaults']
|
||||
sentinels sentinel_instances
|
||||
base_piddir node['redisio']['base_piddir']
|
||||
end
|
||||
```
|
||||
|
||||
## Attributes
|
||||
|
||||
Configuration options, each option corresponds to the same-named configuration option in the redis configuration file; default values listed
|
||||
|
||||
* `redisio['mirror']` - mirror server with path to download redis package, default is [http://download.redis.io/releases/](http://download.redis.io/releases/)
|
||||
* `redisio['base_name']` - the base name of the redis package to be downloaded (the part before the version), default is 'redis-'
|
||||
* `redisio['artifact_type']` - the file extension of the package. currently only .tar.gz and .tgz are supported, default is 'tar.gz'
|
||||
* `redisio['version']` - the version number of redis to install (also appended to the `base_name` for downloading), default is '2.8.17'
|
||||
* `redisio['safe_install']` - prevents redis from installing itself if another version of redis is installed, default is true
|
||||
* `redisio['base_piddir']` - This is the directory that redis pidfile directories and pidfiles will be placed in. Since redis can run as non root, it needs to have proper
|
||||
permissions to the directory to create its pid. Since each instance can run as a different user, these directories will all be nested inside this base one.
|
||||
* `redisio['bypass_setup']` - This attribute allows users to prevent the default recipe from calling the install and configure recipes.
|
||||
* `redisio['job_control']` - This deteremines what job control type will be used. Currently supports 'initd' or 'upstart' options. Defaults to 'initd'.
|
||||
|
||||
Default settings is a hash of default settings to be applied to to ALL instances. These can be overridden for each individual server in the servers attribute. If you are going to set logfile to a specific file, make sure to set syslog-enabled to no.
|
||||
|
||||
* `redisio['default_settings']` - { 'redis-option' => 'option setting' }
|
||||
|
||||
Available options and their defaults
|
||||
|
||||
```config
|
||||
'user' => 'redis' - the user to own the redis datadir, redis will also run under this user
|
||||
'group' => 'redis' - the group to own the redis datadir
|
||||
'permissions' => '0644' - the unix permissions applied to the server config file
|
||||
'homedir' => Home directory of the user. Varies on distribution, check attributes file
|
||||
'shell' => Users shell. Varies on distribution, check attributes file
|
||||
'systemuser' => true - Sets up the instances user as a system user
|
||||
'ulimit' => 0 - 0 is a special value causing the ulimit to be maxconnections +32. Set to nil or false to disable setting ulimits
|
||||
'configdir' => '/etc/redis' - configuration directory
|
||||
'name' => nil, Allows you to name the server with something other than port. Useful if you want to use unix sockets
|
||||
'tcpbacklog' => '511',
|
||||
'address' => nil, Can accept a single string or an array. When using an array, the FIRST value will be used by the init script for connecting to redis
|
||||
'databases' => '16',
|
||||
'backuptype' => 'rdb',
|
||||
'datadir' => '/var/lib/redis',
|
||||
'unixsocket' => nil - The location of the unix socket to use,
|
||||
'unixsocketperm' => nil - The permissions of the unix socket,
|
||||
'timeout' => '0',
|
||||
'keepalive' => '0',
|
||||
'loglevel' => 'notice',
|
||||
'logfile' => nil,
|
||||
'syslogenabled' => 'yes',
|
||||
'syslogfacility' => 'local0',
|
||||
'shutdown_save' => false,
|
||||
'save' => nil, # Defaults to ['900 1','300 10','60 10000'] inside of template. Needed due to lack of hash subtraction
|
||||
'stopwritesonbgsaveerror' => 'yes',
|
||||
'rdbcompression' => 'yes',
|
||||
'rdbchecksum' => 'yes',
|
||||
'dbfilename' => nil,
|
||||
'slaveof' => nil,
|
||||
'masterauth' => nil,
|
||||
'slaveservestaledata' => 'yes',
|
||||
'slavereadonly' => 'yes',
|
||||
'repldisklesssync' => 'no', # Requires redis 2.8.18+
|
||||
'repldisklesssyncdelay' => '5', # Requires redis 2.8.18+
|
||||
'replpingslaveperiod' => '10',
|
||||
'repltimeout' => '60',
|
||||
'repldisabletcpnodelay => 'no',
|
||||
'slavepriority' => '100',
|
||||
'requirepass' => nil,
|
||||
'rename_commands' => nil, or a hash where each key is a redis command and the value is the command's new name.
|
||||
'maxclients' => 10000,
|
||||
'maxmemory' => nil,
|
||||
'maxmemorypolicy' => nil,
|
||||
'maxmemorysamples' => nil,
|
||||
'appendfilename' => nil,
|
||||
'appendfsync' => 'everysec',
|
||||
'noappendfsynconrewrite' => 'no',
|
||||
'aofrewritepercentage' => '100',
|
||||
'aofrewriteminsize' => '64mb',
|
||||
'luatimelimit' => '5000',
|
||||
'slowloglogslowerthan' => '10000',
|
||||
'slowlogmaxlen' => '1024',
|
||||
'notifykeyspaceevents' => '',
|
||||
'hashmaxziplistentries' => '512',
|
||||
'hashmaxziplistvalue' => '64',
|
||||
'listmaxziplistentries' => '512',
|
||||
'listmaxziplistvalue' => '64',
|
||||
'setmaxintsetentries' => '512',
|
||||
'zsetmaxziplistentries' => '128',
|
||||
'zsetmaxziplistvalue' => '64',
|
||||
'hllsparsemaxbytes' => '3000',
|
||||
'activerehasing' => 'yes',
|
||||
'clientoutputbufferlimit' => [
|
||||
%w(normal 0 0 0),
|
||||
%w(slave 256mb 64mb 60),
|
||||
%w(pubsub 32mb 8mb 60)
|
||||
],
|
||||
'hz' => '10',
|
||||
'aofrewriteincrementalfsync' => 'yes',
|
||||
'clusterenabled' => 'no',
|
||||
'clusterconfigfile' => nil, # Defaults to redis instance name inside of template if cluster is enabled.
|
||||
'clusternodetimeout' => 5000,
|
||||
'includes' => nil,
|
||||
'breadcrumb' => true # Defaults to create breadcrumb lock-file.
|
||||
```
|
||||
|
||||
* `redisio['servers']` - An array where each item is a set of key value pairs for redis instance specific settings. The only required option is 'port'. These settings will override the options in 'default_settings', if it is left `nil` it will default to `[{'port' => '6379'}]`. If set to `[]` (empty array), no instances will be created.
|
||||
|
||||
The redis_gem recipe will also allow you to install the redis ruby gem, these are attributes related to that, and are in the redis_gem attributes file.
|
||||
|
||||
* `redisio['gem']['name']` - the name of the gem to install, defaults to 'redis'
|
||||
* `redisio['gem']['version']` - the version of the gem to install. if it is nil, the latest available version will be installed.
|
||||
|
||||
The sentinel recipe's use their own attribute file.
|
||||
|
||||
* `redisio['sentinel_defaults']` - { 'sentinel-option' => 'option setting' }
|
||||
|
||||
```config
|
||||
'user' => 'redis',
|
||||
'configdir' => '/etc/redis',
|
||||
'sentinel_bind' => nil,
|
||||
'sentinel_port' => 26379,
|
||||
'monitor' => nil,
|
||||
'down-after-milliseconds' => 30000,
|
||||
'can-failover' => 'yes',
|
||||
'parallel-syncs' => 1,
|
||||
'failover-timeout' => 900000,
|
||||
'loglevel' => 'notice',
|
||||
'logfile' => nil,
|
||||
'syslogenabled' => 'yes',
|
||||
'syslogfacility' => 'local0',
|
||||
'quorum_count' => 2,
|
||||
'protected-mode' => nil,
|
||||
```
|
||||
|
||||
* `redisio['redisio']['sentinel']['manage_config']` - Should the cookbook manage the redis and redis sentinel config files. This is best set to false when using redis_sentinel as it will write state into both configuration files.
|
||||
|
||||
* `redisio['redisio']['sentinels']` - Array of sentinels to configure on the node. These settings will override the options in 'sentinel_defaults', if it is left `nil` it will default to `[{'port' => '26379', 'name' => 'mycluster', 'master_ip' => '127.0.0.1', 'master_port' => 6379}]`. If set to `[]` (empty array), no instances will be created.
|
||||
|
||||
You may also pass an array of masters to monitor like so:
|
||||
|
||||
```ruby
|
||||
[{
|
||||
'sentinel_port' => '26379',
|
||||
'name' => 'mycluster_sentinel',
|
||||
'masters' => [
|
||||
{ 'master_name' => 'master6379', 'master_ip' => '127.0.0.1', 'master_port' => 6379 },
|
||||
{ 'master_name' => 'master6380', 'master_ip' => '127.0.0.1', 'master_port' => 6380 }
|
||||
redisio_sentinel_instance 'cluster' do
|
||||
package_install true
|
||||
masters [
|
||||
{
|
||||
master_name: 'master6379',
|
||||
master_ip: '127.0.0.1',
|
||||
master_port: 6379,
|
||||
},
|
||||
]
|
||||
|
||||
}]
|
||||
```
|
||||
|
||||
## Resources/Providers
|
||||
|
||||
### `install`
|
||||
|
||||
Actions:
|
||||
|
||||
* `run` - perform the install (default)
|
||||
* `nothing` - do nothing
|
||||
|
||||
Attribute Parameters
|
||||
|
||||
* `version` - the version of redis to download / install
|
||||
* `download_url` - the URL plus filename of the redis package to install
|
||||
* `download_dir` - the directory to store the downloaded package
|
||||
* `artifact_type` - the file extension of the package
|
||||
* `base_name` - the name of the package minus the extension and version number
|
||||
* `safe_install` - a true or false value which determines if a version of redis will be installed if one already exists, defaults to true
|
||||
|
||||
This resource expects the following naming conventions:
|
||||
|
||||
package file should be in the format base_nameVersion_number.artifact_type
|
||||
|
||||
package file after extraction should be inside of the directory base_nameVersion_number
|
||||
|
||||
```ruby
|
||||
install "redis" do
|
||||
action [:run,:nothing]
|
||||
end
|
||||
```
|
||||
|
||||
### `configure`
|
||||
|
||||
Actions:
|
||||
|
||||
* `run` - perform the configure (default)
|
||||
* `nothing` - do nothing
|
||||
|
||||
Attribute Parameters
|
||||
|
||||
* `version` - the version of redis to download / install
|
||||
* `base_piddir` - directory where pid files will be created
|
||||
* `user` - the user to run redis as, and to own the redis files
|
||||
* `group` - the group to own the redis files
|
||||
* `default_settings` - a hash of the default redis server settings
|
||||
* `servers` - an array of hashes containing server configurations overrides (port is the only required)
|
||||
### Use the compatibility wrapper
|
||||
|
||||
```ruby
|
||||
configure "redis" do
|
||||
action [:run,:nothing]
|
||||
redisio_configure 'default' do
|
||||
package_install true
|
||||
servers [
|
||||
{ 'port' => 6379 },
|
||||
{ 'name' => 'savetest', 'port' => 16_379, 'permissions' => '0640' },
|
||||
]
|
||||
end
|
||||
```
|
||||
|
||||
## Contributors
|
||||
## Testing
|
||||
|
||||
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
|
||||
Run lint and unit tests with:
|
||||
|
||||
### Backers
|
||||
```bash
|
||||
cookstyle
|
||||
chef exec rspec --format documentation
|
||||
```
|
||||
|
||||
Thank you to all our backers!
|
||||
Run the default integration suite with:
|
||||
|
||||

|
||||
```bash
|
||||
KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen test default-ubuntu-2404 --destroy=always
|
||||
```
|
||||
|
||||
### Sponsors
|
||||
|
||||
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
Additional public API details live in `documentation/*.md`.
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
package_bin_path = '/usr/bin'
|
||||
config_dir = '/etc/redis'
|
||||
default_package_install = false
|
||||
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
shell = '/bin/false'
|
||||
homedir = '/var/lib/redis'
|
||||
package_name = 'redis-server'
|
||||
when 'rhel', 'fedora'
|
||||
shell = '/bin/sh'
|
||||
homedir = '/var/lib/redis'
|
||||
package_name = 'redis'
|
||||
when 'freebsd'
|
||||
shell = '/bin/sh'
|
||||
homedir = '/var/lib/redis'
|
||||
package_name = 'redis'
|
||||
package_bin_path = '/usr/local/bin'
|
||||
config_dir = '/usr/local/etc/redis'
|
||||
default_package_install = true
|
||||
else
|
||||
shell = '/bin/sh'
|
||||
homedir = '/redis'
|
||||
package_name = 'redis'
|
||||
end
|
||||
|
||||
# Overwite template used for the Redis Server config (not sentinel)
|
||||
default['redisio']['redis_config']['template_cookbook'] = 'redisio'
|
||||
default['redisio']['redis_config']['template_source'] = 'redis.conf.erb'
|
||||
|
||||
# Install related attributes
|
||||
default['redisio']['safe_install'] = true
|
||||
default['redisio']['package_install'] = default_package_install
|
||||
default['redisio']['package_name'] = package_name
|
||||
default['redisio']['bypass_setup'] = false
|
||||
|
||||
# Tarball and download related defaults
|
||||
default['redisio']['mirror'] = 'http://download.redis.io/releases/'
|
||||
default['redisio']['base_name'] = 'redis-'
|
||||
default['redisio']['artifact_type'] = 'tar.gz'
|
||||
default['redisio']['base_piddir'] = '/var/run/redis'
|
||||
|
||||
# Version
|
||||
default['redisio']['version'] = if node['redisio']['package_install']
|
||||
# latest version (only for package install)
|
||||
nil
|
||||
else
|
||||
# force version for tarball
|
||||
'3.2.11'
|
||||
end
|
||||
|
||||
# Custom installation directory
|
||||
default['redisio']['install_dir'] = nil
|
||||
|
||||
# Job control related options (initd, upstart, or systemd)
|
||||
default['redisio']['job_control'] = if systemd?
|
||||
'systemd'
|
||||
elsif platform_family?('freebsd')
|
||||
'rcinit'
|
||||
else
|
||||
'initd'
|
||||
end
|
||||
|
||||
# Init.d script related options
|
||||
default['redisio']['init.d']['required_start'] = []
|
||||
default['redisio']['init.d']['required_stop'] = []
|
||||
|
||||
# Default settings for all redis instances, these can be overridden on a per server basis in the 'servers' hash
|
||||
default['redisio']['default_settings'] = {
|
||||
'user' => 'redis',
|
||||
'group' => 'redis',
|
||||
'permissions' => '0644',
|
||||
'homedir' => homedir,
|
||||
'shell' => shell,
|
||||
'systemuser' => true,
|
||||
'uid' => nil,
|
||||
'ulimit' => 0,
|
||||
'configdir' => config_dir,
|
||||
'name' => nil,
|
||||
'tcpbacklog' => '511',
|
||||
'address' => nil,
|
||||
'databases' => '16',
|
||||
'backuptype' => 'rdb',
|
||||
'datadir' => '/var/lib/redis',
|
||||
'unixsocket' => nil,
|
||||
'unixsocketperm' => nil,
|
||||
'timeout' => '0',
|
||||
'keepalive' => '0',
|
||||
'loglevel' => 'notice',
|
||||
'logfile' => nil,
|
||||
'syslogenabled' => 'yes',
|
||||
'syslogfacility' => 'local0',
|
||||
'shutdown_save' => false,
|
||||
'save' => nil, # Defaults to ['900 1','300 10','60 10000'] inside of template. Needed due to lack of hash subtraction
|
||||
'stopwritesonbgsaveerror' => 'yes',
|
||||
'rdbcompression' => 'yes',
|
||||
'rdbchecksum' => 'yes',
|
||||
'dbfilename' => nil,
|
||||
'slaveof' => nil,
|
||||
'protected_mode' => nil, # unspecified by default but could be set explicitly to 'yes' or 'no'
|
||||
'masterauth' => nil,
|
||||
'slaveservestaledata' => 'yes',
|
||||
'slavereadonly' => 'yes',
|
||||
'repldisklesssync' => 'no',
|
||||
'repldisklesssyncdelay' => '5',
|
||||
'replpingslaveperiod' => '10',
|
||||
'repltimeout' => '60',
|
||||
'repldisabletcpnodelay' => 'no',
|
||||
'replbacklogsize' => '1mb',
|
||||
'replbacklogttl' => 3600,
|
||||
'slavepriority' => '100',
|
||||
'requirepass' => nil,
|
||||
'rename_commands' => nil,
|
||||
'maxclients' => 10000,
|
||||
'maxmemory' => nil,
|
||||
'maxmemorypolicy' => nil,
|
||||
'maxmemorysamples' => nil,
|
||||
'appendfilename' => nil,
|
||||
'appendfsync' => 'everysec',
|
||||
'noappendfsynconrewrite' => 'no',
|
||||
'aofrewritepercentage' => '100',
|
||||
'aofrewriteminsize' => '64mb',
|
||||
'aofloadtruncated' => 'yes',
|
||||
'luatimelimit' => '5000',
|
||||
'slowloglogslowerthan' => '10000',
|
||||
'slowlogmaxlen' => '1024',
|
||||
'notifykeyspaceevents' => '',
|
||||
'hashmaxziplistentries' => '512',
|
||||
'hashmaxziplistvalue' => '64',
|
||||
'listmaxziplistentries' => '512',
|
||||
'listmaxziplistvalue' => '64',
|
||||
'setmaxintsetentries' => '512',
|
||||
'zsetmaxziplistentries' => '128',
|
||||
'zsetmaxziplistvalue' => '64',
|
||||
'hllsparsemaxbytes' => '3000',
|
||||
'activerehasing' => 'yes',
|
||||
'clientoutputbufferlimit' => [
|
||||
%w(normal 0 0 0),
|
||||
%w(slave 256mb 64mb 60),
|
||||
%w(pubsub 32mb 8mb 60),
|
||||
],
|
||||
'hz' => '10',
|
||||
'aofrewriteincrementalfsync' => 'yes',
|
||||
'clusterenabled' => 'no',
|
||||
'clusterconfigfile' => nil, # Defaults to redis instance name inside of template if cluster is enabled.
|
||||
'clusternodetimeout' => 5000,
|
||||
'includes' => nil,
|
||||
'data_bag_name' => nil,
|
||||
'data_bag_item' => nil,
|
||||
'data_bag_key' => nil,
|
||||
'minslavestowrite' => nil,
|
||||
'minslavesmaxlag' => nil,
|
||||
'breadcrumb' => true,
|
||||
}
|
||||
|
||||
# The default for this is set inside of the "install" recipe. This is due to the way deep merge handles arrays
|
||||
default['redisio']['servers'] = nil
|
||||
|
||||
# Define binary path
|
||||
default['redisio']['bin_path'] = if node['redisio']['package_install']
|
||||
package_bin_path
|
||||
else
|
||||
'/usr/local/bin'
|
||||
end
|
||||
|
||||
# Ulimit
|
||||
default['ulimit']['pam_su_template_cookbook'] = nil
|
||||
default['ulimit']['users'] = Mash.new
|
||||
default['ulimit']['security_limits_directory'] = '/etc/security/limits.d'
|
||||
default['ulimit']['ulimit_overriding_sudo_file_name'] = 'sudo'
|
||||
default['ulimit']['ulimit_overriding_sudo_file_cookbook'] = nil
|
||||
@@ -1,3 +0,0 @@
|
||||
# Allow for a redis ruby gem to be installed
|
||||
default['redisio']['gem']['name'] = 'redis'
|
||||
default['redisio']['gem']['version'] = nil
|
||||
@@ -1,36 +0,0 @@
|
||||
config_dir = if platform_family?('freebsd')
|
||||
'/usr/local/etc/redis'
|
||||
else
|
||||
'/etc/redis'
|
||||
end
|
||||
|
||||
default['redisio']['sentinel_defaults'] = {
|
||||
'user' => 'redis',
|
||||
'configdir' => config_dir,
|
||||
'sentinel_bind' => nil,
|
||||
'sentinel_port' => 26379,
|
||||
'monitor' => nil,
|
||||
'down_after_milliseconds' => 30000,
|
||||
'can-failover' => 'yes',
|
||||
'parallel-syncs' => 1,
|
||||
'failover_timeout' => 900000,
|
||||
'loglevel' => 'notice',
|
||||
'logfile' => nil,
|
||||
'syslogenabled' => 'yes',
|
||||
'syslogfacility' => 'local0',
|
||||
'quorum_count' => 2,
|
||||
'data_bag_name' => nil,
|
||||
'data_bag_item' => nil,
|
||||
'data_bag_key' => nil,
|
||||
'announce-ip' => nil,
|
||||
'announce-port' => nil,
|
||||
'notification-script' => nil,
|
||||
'client-reconfig-script' => nil,
|
||||
'protected_mode' => nil,
|
||||
}
|
||||
|
||||
# Manage Sentinel Config File
|
||||
## Will write out the base config one time then no longer manage the config allowing sentinel to take over
|
||||
default['redisio']['sentinel']['manage_config'] = true # Deprecated
|
||||
|
||||
default['redisio']['sentinels'] = nil
|
||||
@@ -83,13 +83,6 @@ test/*
|
||||
*/.hg/*
|
||||
*/.svn/*
|
||||
|
||||
# Berkshelf #
|
||||
#############
|
||||
Berksfile
|
||||
Berksfile.lock
|
||||
cookbooks/*
|
||||
tmp
|
||||
|
||||
# Bundler #
|
||||
###########
|
||||
vendor/*
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#%PAM-1.0
|
||||
|
||||
auth required pam_env.so readenv=1 user_readenv=0
|
||||
auth required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
|
||||
session required pam_limits.so
|
||||
@include common-auth
|
||||
@include common-account
|
||||
@include common-session-noninteractive
|
||||
@@ -0,0 +1,145 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'shellwords'
|
||||
|
||||
module RedisioCookbook
|
||||
module Helpers
|
||||
def platform_package_name
|
||||
return 'redis6' if platform_family?('amazon')
|
||||
return 'redis-server' if platform_family?('debian')
|
||||
|
||||
'redis'
|
||||
end
|
||||
|
||||
def platform_default_home
|
||||
'/var/lib/redis'
|
||||
end
|
||||
|
||||
def platform_default_shell
|
||||
return '/bin/false' if platform_family?('debian')
|
||||
|
||||
'/bin/sh'
|
||||
end
|
||||
|
||||
def platform_default_group
|
||||
'redis'
|
||||
end
|
||||
|
||||
def platform_default_config_dir
|
||||
'/etc/redis'
|
||||
end
|
||||
|
||||
def platform_default_service_name
|
||||
return 'redis6' if platform_family?('amazon')
|
||||
return 'redis-server' if platform_family?('debian')
|
||||
|
||||
'redis'
|
||||
end
|
||||
|
||||
def platform_default_bin_path(package_install:, install_dir:)
|
||||
return ::File.join(install_dir, 'bin') if install_dir
|
||||
return '/usr/bin' if package_install
|
||||
|
||||
'/usr/local/bin'
|
||||
end
|
||||
|
||||
def source_build_packages
|
||||
return %w(tar gcc g++ make libc6-dev libssl-dev) if platform_family?('debian')
|
||||
|
||||
%w(tar gcc gcc-c++ make glibc-devel openssl-devel)
|
||||
end
|
||||
|
||||
def redis_service_name(instance_name)
|
||||
"redis@#{instance_name}"
|
||||
end
|
||||
|
||||
def sentinel_service_name(instance_name)
|
||||
"redis-sentinel@#{instance_name}"
|
||||
end
|
||||
|
||||
def sentinel_config_name(instance_name)
|
||||
"sentinel_#{instance_name}"
|
||||
end
|
||||
|
||||
def redis_version_to_hash(version_string)
|
||||
version_array = version_string.to_s.split('.')
|
||||
version_array[2] = version_array[2].to_s.split('-')
|
||||
version_array.flatten!
|
||||
|
||||
{
|
||||
major: version_array.first.to_s.include?(':') ? version_array.first.split(':')[1] : version_array.first,
|
||||
minor: version_array[1],
|
||||
tiny: version_array[2],
|
||||
rc: version_array[3],
|
||||
}
|
||||
end
|
||||
|
||||
def redis_server_binary_name(package_install:, package_name:)
|
||||
return 'redis6-server' if package_install && package_name == 'redis6'
|
||||
|
||||
'redis-server'
|
||||
end
|
||||
|
||||
def redis_cli_binary_name(package_install:, package_name:)
|
||||
return 'redis6-cli' if package_install && package_name == 'redis6'
|
||||
|
||||
'redis-cli'
|
||||
end
|
||||
|
||||
def redis_server_binary(bin_path, options = nil, package_install: nil, package_name: nil)
|
||||
if options.is_a?(Hash)
|
||||
package_install = options.fetch(:package_install, package_install)
|
||||
package_name = options.fetch(:package_name, package_name)
|
||||
end
|
||||
|
||||
::File.join(bin_path, redis_server_binary_name(package_install: package_install, package_name: package_name))
|
||||
end
|
||||
|
||||
def redis_cli_binary(bin_path, options = nil, package_install: nil, package_name: nil)
|
||||
if options.is_a?(Hash)
|
||||
package_install = options.fetch(:package_install, package_install)
|
||||
package_name = options.fetch(:package_name, package_name)
|
||||
end
|
||||
|
||||
::File.join(bin_path, redis_cli_binary_name(package_install: package_install, package_name: package_name))
|
||||
end
|
||||
|
||||
def installed_redis_version(bin_path, package_install:, package_name:)
|
||||
redis_server = redis_server_binary(bin_path, package_install: package_install, package_name: package_name)
|
||||
return unless ::File.exist?(redis_server)
|
||||
|
||||
command = shell_out!("#{Shellwords.escape(redis_server)} -v", timeout: 30)
|
||||
command.stdout[/version (\d+\.\d+\.\d+)/, 1] || command.stdout[/v=(\d+\.\d+\.\d+)/, 1]
|
||||
end
|
||||
|
||||
def normalize_hash(value)
|
||||
return {} if value.nil?
|
||||
return value.to_hash if value.respond_to?(:to_hash)
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
def normalize_array(value)
|
||||
return [] if value.nil?
|
||||
|
||||
Array(value)
|
||||
end
|
||||
|
||||
def deep_stringify_keys(value)
|
||||
case value
|
||||
when Hash
|
||||
value.each_with_object({}) do |(key, inner), result|
|
||||
result[key.to_s] = deep_stringify_keys(inner)
|
||||
end
|
||||
when Array
|
||||
value.map { |inner| deep_stringify_keys(inner) }
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def command_exists?(command)
|
||||
shell_out("command -v #{Shellwords.escape(command)}").exitstatus.zero?
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1 +0,0 @@
|
||||
# cookbook/libraries/matchers.rb
|
||||
@@ -1,32 +0,0 @@
|
||||
module RedisioHelper
|
||||
def recipe_eval
|
||||
sub_run_context = @run_context.dup
|
||||
sub_run_context.resource_collection = Chef::ResourceCollection.new
|
||||
begin
|
||||
original_run_context = @run_context
|
||||
@run_context = sub_run_context
|
||||
yield
|
||||
ensure
|
||||
@run_context = original_run_context
|
||||
end
|
||||
|
||||
begin
|
||||
Chef::Runner.new(sub_run_context).converge
|
||||
ensure
|
||||
new_resource.updated_by_last_action(true) if sub_run_context.resource_collection.any?(&:updated?)
|
||||
end
|
||||
end
|
||||
|
||||
def self.version_to_hash(version_string)
|
||||
version_array = version_string.split('.')
|
||||
version_array[2] = version_array[2].split('-')
|
||||
version_array.flatten!
|
||||
|
||||
{
|
||||
major: version_array[0].include?(':') ? version_array[0].split(':')[1] : version_array[0],
|
||||
minor: version_array[1],
|
||||
tiny: version_array[2],
|
||||
rc: version_array[3],
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,19 +1,15 @@
|
||||
{
|
||||
"name": "redisio",
|
||||
"description": "Installs and configures redis",
|
||||
"description": "Provides custom resources for installing and managing Redis instances and Sentinels",
|
||||
"long_description": "",
|
||||
"maintainer": "Sous Chefs",
|
||||
"maintainer_email": "help@sous-chefs.org",
|
||||
"license": "Apache-2.0",
|
||||
"platforms": {
|
||||
"centos": ">= 0.0.0",
|
||||
"debian": ">= 0.0.0",
|
||||
"fedora": ">= 0.0.0",
|
||||
"redhat": ">= 0.0.0",
|
||||
"rocky": ">= 0.0.0",
|
||||
"scientific": ">= 0.0.0",
|
||||
"suse": ">= 0.0.0",
|
||||
"ubuntu": ">= 0.0.0"
|
||||
"amazon": ">= 2023.0",
|
||||
"debian": ">= 12.0",
|
||||
"rocky": ">= 9.0",
|
||||
"ubuntu": ">= 22.04"
|
||||
},
|
||||
"dependencies": {
|
||||
"selinux": ">= 0.0.0"
|
||||
@@ -24,13 +20,13 @@
|
||||
"recipes": {
|
||||
|
||||
},
|
||||
"version": "6.4.1",
|
||||
"version": "8.0.0",
|
||||
"source_url": "https://github.com/sous-chefs/redisio",
|
||||
"issues_url": "https://github.com/sous-chefs/redisio/issues",
|
||||
"privacy": false,
|
||||
"chef_versions": [
|
||||
[
|
||||
">= 16"
|
||||
">= 16.0"
|
||||
]
|
||||
],
|
||||
"ohai_versions": [
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
name 'redisio'
|
||||
maintainer 'Sous Chefs'
|
||||
maintainer_email 'help@sous-chefs.org'
|
||||
license 'Apache-2.0'
|
||||
description 'Installs and configures redis'
|
||||
version '6.4.1'
|
||||
description 'Provides custom resources for installing and managing Redis instances and Sentinels'
|
||||
version '8.0.0'
|
||||
source_url 'https://github.com/sous-chefs/redisio'
|
||||
issues_url 'https://github.com/sous-chefs/redisio/issues'
|
||||
chef_version '>= 16'
|
||||
chef_version '>= 16.0'
|
||||
|
||||
suports 'amazon'
|
||||
supports 'centos'
|
||||
supports 'debian'
|
||||
supports 'fedora'
|
||||
supports 'redhat'
|
||||
supports 'rocky'
|
||||
supports 'scientific'
|
||||
supports 'suse'
|
||||
supports 'ubuntu'
|
||||
supports 'amazon', '>= 2023.0'
|
||||
supports 'debian', '>= 12.0'
|
||||
supports 'rocky', '>= 9.0'
|
||||
supports 'ubuntu', '>= 22.04'
|
||||
|
||||
depends 'selinux'
|
||||
|
||||
@@ -1,377 +0,0 @@
|
||||
action :run do
|
||||
base_piddir = new_resource.base_piddir
|
||||
|
||||
if !new_resource.version
|
||||
redis_output = Mixlib::ShellOut.new("#{node['redisio']['bin_path']}/redis-server -v")
|
||||
redis_output.run_command
|
||||
redis_output.error!
|
||||
current_version = redis_output.stdout.gsub(/.*v=((\d+\.){2}\d+).*/, '\1').chomp
|
||||
else
|
||||
current_version = new_resource.version
|
||||
end
|
||||
version_hash = RedisioHelper.version_to_hash(current_version)
|
||||
|
||||
# Setup a configuration file and init script for each configuration provided
|
||||
new_resource.servers.each do |current_instance|
|
||||
# Retrieve the default settings hash and the current server setups settings hash.
|
||||
current_instance_hash = current_instance.to_hash
|
||||
current_defaults_hash = new_resource.default_settings.to_hash
|
||||
|
||||
# Merge the configuration defaults with the provided array of configurations provided
|
||||
current = current_defaults_hash.merge(current_instance_hash)
|
||||
|
||||
# Merge in the default maxmemory
|
||||
node_memory_kb = node['memory']['total']
|
||||
# On BSD platforms Ohai reports total memory as a Fixnum
|
||||
|
||||
node_memory_kb = node_memory_kb.sub('kB', '').to_i if node_memory_kb.is_a?(String)
|
||||
|
||||
# Here we determine what the logfile is. It has these possible states
|
||||
#
|
||||
# Redis 2.6 and lower can be
|
||||
# stdout
|
||||
# A path
|
||||
# nil
|
||||
# Redis 2.8 and higher can be
|
||||
# empty string, which means stdout)
|
||||
# A path
|
||||
# nil
|
||||
|
||||
if current['logfile'].nil?
|
||||
log_file = nil
|
||||
log_directory = nil
|
||||
elsif current['logfile'] == 'stdout' || current['logfile'].empty?
|
||||
log_directory = nil
|
||||
log_file = current['logfile']
|
||||
else
|
||||
log_directory = ::File.dirname(current['logfile'])
|
||||
log_file = ::File.basename(current['logfile'])
|
||||
if current['syslogenabled'] == 'yes'
|
||||
Chef::Log.warn("log file is set to #{current['logfile']} but syslogenabled is also set to 'yes'")
|
||||
end
|
||||
end
|
||||
|
||||
maxmemory = current['maxmemory'].to_s
|
||||
if !maxmemory.empty? && maxmemory.include?('%')
|
||||
# Just assume this is sensible like "95%" or "95 %"
|
||||
percent_factor = current['maxmemory'].to_f / 100.0
|
||||
# Ohai reports memory in KB as it looks in /proc/meminfo
|
||||
maxmemory = (node_memory_kb * 1024 * percent_factor / new_resource.servers.length).round.to_s
|
||||
end
|
||||
|
||||
descriptors = if current['ulimit'] == 0
|
||||
current['maxclients'] + 32
|
||||
elsif current['ulimit'] > current['maxclients']
|
||||
current['ulimit']
|
||||
else
|
||||
current['maxclients']
|
||||
end
|
||||
|
||||
server_name = current['name'] || current['port']
|
||||
piddir = "#{base_piddir}/#{server_name}"
|
||||
aof_file = current['appendfilename'] || "#{current['datadir']}/appendonly-#{server_name}.aof"
|
||||
rdb_file = current['dbfilename'] || "#{current['datadir']}/dump-#{server_name}.rdb"
|
||||
|
||||
# Create the owner of the redis data directory
|
||||
user current['user'] do
|
||||
comment 'Redis service account'
|
||||
manage_home true
|
||||
home current['homedir']
|
||||
shell current['shell']
|
||||
system current['systemuser']
|
||||
uid current['uid'] unless current['uid'].nil?
|
||||
end
|
||||
|
||||
# Create the redis configuration directory
|
||||
directory current['configdir'] do
|
||||
owner 'root'
|
||||
group platform_family?('freebsd') ? 'wheel' : 'redis'
|
||||
mode '0775'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
# Create the instance data directory
|
||||
directory current['datadir'] do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0775'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
# Create the pid file directory
|
||||
directory piddir do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
# Create the log directory if syslog is not being used
|
||||
if log_directory
|
||||
directory log_directory do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
end
|
||||
# Configure SELinux if it is enabled
|
||||
extend Chef::Util::Selinux
|
||||
|
||||
if selinux_enabled?
|
||||
selinux_install 'install'
|
||||
|
||||
selinux_fcontext "#{current['configdir']}(/.*)?" do
|
||||
secontext 'redis_conf_t'
|
||||
end
|
||||
selinux_fcontext "#{current['datadir']}(/.*)?" do
|
||||
secontext 'redis_var_lib_t'
|
||||
end
|
||||
selinux_fcontext "#{piddir}(/.*)?" do
|
||||
secontext 'redis_var_run_t'
|
||||
end
|
||||
if log_directory
|
||||
selinux_fcontext "#{log_directory}(/.*)?" do
|
||||
secontext 'redis_log_t'
|
||||
end
|
||||
end
|
||||
end
|
||||
# Create the log file if syslog is not being used
|
||||
if log_file
|
||||
file current['logfile'] do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
backup false
|
||||
action :create
|
||||
# in version 2.8 or higher the empty string is used instead of stdout
|
||||
only_if { !log_file.empty? && log_file != 'stdout' }
|
||||
end
|
||||
end
|
||||
# Set proper permissions on the AOF or RDB files
|
||||
file aof_file do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
only_if { current['backuptype'] == 'aof' || current['backuptype'] == 'both' }
|
||||
only_if { ::File.exist?(aof_file) }
|
||||
end
|
||||
file rdb_file do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
only_if { current['backuptype'] == 'rdb' || current['backuptype'] == 'both' }
|
||||
only_if { ::File.exist?(rdb_file) }
|
||||
end
|
||||
|
||||
# Setup the redis users descriptor limits
|
||||
# Pending response on https://github.com/brianbianco/redisio/commit/4ee9aad3b53029cc3b6c6cf741f5126755e712cd#diff-8ae42a59a6f4e8dc5b4e6dd2d6a34eab
|
||||
# TODO: ulimit cookbook v0.1.2 doesn't work with freeBSD
|
||||
if current['ulimit'] && !platform_family?('freebsd')
|
||||
user_ulimit current['user'] do
|
||||
filehandle_limit descriptors
|
||||
end
|
||||
end
|
||||
|
||||
computed_save = current['save']
|
||||
if current['save'] && current['save'].respond_to?(:each_line)
|
||||
computed_save = current['save'].each_line
|
||||
Chef::Log.warn("#{server_name}: given a save argument as a string, instead of an array.")
|
||||
Chef::Log.warn("#{server_name}: This will be deprecated in future versions of the redisio cookbook.")
|
||||
end
|
||||
|
||||
# Load password for use with requirepass from data bag if needed
|
||||
if current['data_bag_name'] && current['data_bag_item'] && current['data_bag_key']
|
||||
bag = data_bag_item(current['data_bag_name'], current['data_bag_item'])
|
||||
current['requirepass'] = bag[current['data_bag_key']]
|
||||
current['masterauth'] = bag[current['data_bag_key']]
|
||||
end
|
||||
|
||||
# Lay down the configuration files for the current instance
|
||||
template "#{current['configdir']}/#{server_name}.conf" do
|
||||
source node['redisio']['redis_config']['template_source']
|
||||
cookbook node['redisio']['redis_config']['template_cookbook']
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode current['permissions']
|
||||
action :create
|
||||
variables(
|
||||
version: version_hash,
|
||||
piddir: piddir,
|
||||
name: server_name,
|
||||
job_control: node['redisio']['job_control'],
|
||||
port: current['port'],
|
||||
tcpbacklog: current['tcpbacklog'],
|
||||
address: current['address'],
|
||||
databases: current['databases'],
|
||||
backuptype: current['backuptype'],
|
||||
datadir: current['datadir'],
|
||||
unixsocket: current['unixsocket'],
|
||||
unixsocketperm: current['unixsocketperm'],
|
||||
timeout: current['timeout'],
|
||||
keepalive: current['keepalive'],
|
||||
loglevel: current['loglevel'],
|
||||
logfile: current['logfile'],
|
||||
syslogenabled: current['syslogenabled'],
|
||||
syslogfacility: current['syslogfacility'],
|
||||
save: computed_save,
|
||||
stopwritesonbgsaveerror: current['stopwritesonbgsaveerror'],
|
||||
rdbcompression: current['rdbcompression'],
|
||||
rdbchecksum: current['rdbchecksum'],
|
||||
dbfilename: current['dbfilename'],
|
||||
slaveof: current['slaveof'],
|
||||
protected_mode: current['protected_mode'],
|
||||
masterauth: current['masterauth'],
|
||||
slaveservestaledata: current['slaveservestaledata'],
|
||||
slavereadonly: current['slavereadonly'],
|
||||
replpingslaveperiod: current['replpingslaveperiod'],
|
||||
repltimeout: current['repltimeout'],
|
||||
repldisabletcpnodelay: current['repldisabletcpnodelay'],
|
||||
replbacklogsize: current['replbacklogsize'],
|
||||
replbacklogttl: current['replbacklogttl'],
|
||||
slavepriority: current['slavepriority'],
|
||||
requirepass: current['requirepass'],
|
||||
rename_commands: current['rename_commands'],
|
||||
maxclients: current['maxclients'],
|
||||
maxmemory: maxmemory,
|
||||
maxmemorypolicy: current['maxmemorypolicy'],
|
||||
maxmemorysamples: current['maxmemorysamples'],
|
||||
appendfilename: current['appendfilename'],
|
||||
appendfsync: current['appendfsync'],
|
||||
noappendfsynconrewrite: current['noappendfsynconrewrite'],
|
||||
aofrewritepercentage: current['aofrewritepercentage'],
|
||||
aofrewriteminsize: current['aofrewriteminsize'],
|
||||
aofloadtruncated: current['aofloadtruncated'],
|
||||
luatimelimit: current['luatimelimit'],
|
||||
slowloglogslowerthan: current['slowloglogslowerthan'],
|
||||
slowlogmaxlen: current['slowlogmaxlen'],
|
||||
notifykeyspaceevents: current['notifykeyspaceevents'],
|
||||
hashmaxziplistentries: current['hashmaxziplistentries'],
|
||||
hashmaxziplistvalue: current['hashmaxziplistvalue'],
|
||||
listmaxziplistentries: current['listmaxziplistentries'],
|
||||
listmaxziplistvalue: current['listmaxziplistvalue'],
|
||||
setmaxintsetentries: current['setmaxintsetentries'],
|
||||
zsetmaxziplistentries: current['zsetmaxziplistentries'],
|
||||
zsetmaxziplistvalue: current['zsetmaxziplistvalue'],
|
||||
hllsparsemaxbytes: current['hllsparsemaxbytes'],
|
||||
activerehasing: current['activerehasing'],
|
||||
clientoutputbufferlimit: current['clientoutputbufferlimit'],
|
||||
hz: current['hz'],
|
||||
aofrewriteincrementalfsync: current['aofrewriteincrementalfsync'],
|
||||
clusterenabled: current['clusterenabled'],
|
||||
clusterconfigfile: current['clusterconfigfile'],
|
||||
clusternodetimeout: current['clusternodetimeout'],
|
||||
includes: current['includes'],
|
||||
minslavestowrite: current['minslavestowrite'],
|
||||
minslavesmaxlag: current['minslavesmaxlag'],
|
||||
repldisklesssync: current['repldisklesssync'],
|
||||
repldisklesssyncdelay: current['repldisklesssyncdelay']
|
||||
)
|
||||
not_if { ::File.exist?("#{current['configdir']}/#{server_name}.conf.breadcrumb") }
|
||||
end
|
||||
|
||||
file "#{current['configdir']}/#{server_name}.conf.breadcrumb" do
|
||||
content 'This file prevents the chef cookbook from overwritting the redis config more than once'
|
||||
action :create_if_missing
|
||||
only_if { current['breadcrumb'] == true }
|
||||
end
|
||||
|
||||
# Setup init.d file
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
|
||||
case node['redisio']['job_control']
|
||||
when 'initd'
|
||||
template "/etc/init.d/redis#{server_name}" do
|
||||
source 'redis.init.erb'
|
||||
cookbook 'redisio'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
variables(
|
||||
name: server_name,
|
||||
bin_path: bin_path,
|
||||
port: current['port'],
|
||||
address: current['address'],
|
||||
user: current['user'],
|
||||
configdir: current['configdir'],
|
||||
piddir: piddir,
|
||||
requirepass: current['requirepass'],
|
||||
shutdown_save: current['shutdown_save'],
|
||||
platform: node['platform'],
|
||||
unixsocket: current['unixsocket'],
|
||||
ulimit: descriptors,
|
||||
required_start: node['redisio']['init.d']['required_start'].join(' '),
|
||||
required_stop: node['redisio']['init.d']['required_stop'].join(' ')
|
||||
)
|
||||
end
|
||||
when 'upstart'
|
||||
template "/etc/init/redis#{server_name}.conf" do
|
||||
source 'redis.upstart.conf.erb'
|
||||
cookbook 'redisio'
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
variables(
|
||||
name: server_name,
|
||||
bin_path: bin_path,
|
||||
port: current['port'],
|
||||
user: current['user'],
|
||||
group: current['group'],
|
||||
configdir: current['configdir'],
|
||||
piddir: piddir
|
||||
)
|
||||
end
|
||||
when 'rcinit'
|
||||
template "/usr/local/etc/rc.d/redis#{server_name}" do
|
||||
source 'redis.rcinit.erb'
|
||||
cookbook 'redisio'
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0755'
|
||||
variables(
|
||||
name: server_name,
|
||||
bin_path: bin_path,
|
||||
user: current['user'],
|
||||
configdir: current['configdir'],
|
||||
piddir: piddir
|
||||
)
|
||||
end
|
||||
when 'systemd'
|
||||
service_name = "redis@#{server_name}"
|
||||
reload_name = "#{service_name} systemd reload"
|
||||
|
||||
file "/etc/tmpfiles.d/#{service_name}.conf" do
|
||||
content "d #{piddir} 0755 #{current['user']} #{current['group']}\n"
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
end
|
||||
|
||||
execute reload_name do
|
||||
command 'systemctl daemon-reload'
|
||||
action :nothing
|
||||
end
|
||||
|
||||
template "/lib/systemd/system/#{service_name}.service" do
|
||||
source 'redis@.service.erb'
|
||||
cookbook 'redisio'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
bin_path: bin_path,
|
||||
user: current['user'],
|
||||
group: current['group'],
|
||||
limit_nofile: descriptors
|
||||
)
|
||||
notifies :run, "execute[#{reload_name}]", :immediately
|
||||
end
|
||||
end
|
||||
end
|
||||
# servers each loop
|
||||
end
|
||||
@@ -1,93 +0,0 @@
|
||||
action :run do
|
||||
# Package install
|
||||
if node['redisio']['package_install']
|
||||
package_resource = package 'redisio_package_name' do
|
||||
package_name node['redisio']['package_name']
|
||||
version node['redisio']['version']
|
||||
action :nothing
|
||||
end
|
||||
|
||||
package_resource.run_action(:install)
|
||||
new_resource.updated_by_last_action(true) if package_resource.updated_by_last_action?
|
||||
|
||||
# freeBSD does not support from source since ports does not support versioning (without a lot of hassle)
|
||||
elsif platform_family?('freebsd')
|
||||
raise 'Source install not supported for freebsd'
|
||||
# Tarball install
|
||||
else
|
||||
@tarball = "#{new_resource.base_name}#{new_resource.version}.#{new_resource.artifact_type}"
|
||||
|
||||
unless current_resource.version == new_resource.version || (redis_exists? && new_resource.safe_install)
|
||||
Chef::Log.info("Installing Redis #{new_resource.version} from source")
|
||||
download
|
||||
unpack
|
||||
build
|
||||
install
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def download
|
||||
Chef::Log.info("Downloading redis tarball from #{new_resource.download_url}")
|
||||
remote_file "#{new_resource.download_dir}/#{@tarball}" do
|
||||
source new_resource.download_url
|
||||
end
|
||||
end
|
||||
|
||||
def unpack
|
||||
install_dir = "#{new_resource.base_name}#{new_resource.version}"
|
||||
case new_resource.artifact_type
|
||||
when 'tar.gz', '.tgz'
|
||||
execute %(cd #{new_resource.download_dir} ; mkdir -p '#{install_dir}' ; tar zxf '#{@tarball}' --strip-components=1 -C '#{install_dir}' --no-same-owner)
|
||||
else
|
||||
raise Chef::Exceptions::UnsupportedAction, "Current package type #{new_resource.artifact_type} is unsupported"
|
||||
end
|
||||
end
|
||||
|
||||
def build
|
||||
execute "cd #{new_resource.download_dir}/#{new_resource.base_name}#{new_resource.version} && make clean && make"
|
||||
end
|
||||
|
||||
def install
|
||||
install_prefix = if new_resource.install_dir
|
||||
"PREFIX=#{new_resource.install_dir}"
|
||||
else
|
||||
''
|
||||
end
|
||||
execute "cd #{new_resource.download_dir}/#{new_resource.base_name}#{new_resource.version} && make #{install_prefix} install"
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
|
||||
def redis_exists?
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
redis_server = ::File.join(bin_path, 'redis-server')
|
||||
::File.exist?(redis_server)
|
||||
end
|
||||
|
||||
def version
|
||||
if redis_exists?
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
redis_server = ::File.join(bin_path, 'redis-server')
|
||||
redis_version = Mixlib::ShellOut.new("#{redis_server} -v")
|
||||
redis_version.run_command
|
||||
version = redis_version.stdout[/version (\d*.\d*.\d*)/, 1] || redis_version.stdout[/v=(\d*.\d*.\d*)/, 1]
|
||||
Chef::Log.info("The Redis server version is: #{version}")
|
||||
return version.delete("\n")
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource.resource_for_node(:redisio_install, node).new(new_resource.name)
|
||||
@current_resource.version(version)
|
||||
@current_resource
|
||||
end
|
||||
@@ -1,243 +0,0 @@
|
||||
action :run do
|
||||
base_piddir = new_resource.base_piddir
|
||||
|
||||
current_version = if new_resource.version.nil?
|
||||
version
|
||||
else
|
||||
new_resource.version
|
||||
end
|
||||
|
||||
version_hash = RedisioHelper.version_to_hash(current_version)
|
||||
|
||||
# Setup a configuration file and init script for each configuration provided
|
||||
new_resource.sentinels.each do |current_instance|
|
||||
# Retrieve the default settings hash and the current server setups settings hash.
|
||||
current_instance_hash = current_instance.to_hash
|
||||
current_defaults_hash = new_resource.sentinel_defaults.to_hash
|
||||
|
||||
# Merge the configuration defaults with the provided array of configurations provided
|
||||
current = current_defaults_hash.merge(current_instance_hash)
|
||||
|
||||
sentinel_name = current['name'] || current['port']
|
||||
sentinel_name = "sentinel_#{sentinel_name}"
|
||||
piddir = "#{base_piddir}/#{sentinel_name}"
|
||||
|
||||
# Create the owner of the redis data directory
|
||||
user current['user'] do
|
||||
comment 'Redis service account'
|
||||
manage_home true
|
||||
home current['homedir']
|
||||
shell current['shell']
|
||||
system current['systemuser']
|
||||
uid current['uid'] unless current['uid'].nil?
|
||||
end
|
||||
|
||||
# Create the redis configuration directory
|
||||
directory current['configdir'] do
|
||||
owner 'root'
|
||||
group platform_family?('freebsd') ? 'wheel' : 'redis'
|
||||
mode '0775'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
# Create the pid file directory
|
||||
directory piddir do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
unless current['logfile'].nil?
|
||||
# Create the log directory if syslog is not being used
|
||||
directory ::File.dirname(current['logfile']) do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
only_if { current['syslogenabled'] != 'yes' && current['logfile'] && current['logfile'] != 'stdout' }
|
||||
end
|
||||
|
||||
# Create the log file is syslog is not being used
|
||||
file current['logfile'] do
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
backup false
|
||||
action :touch
|
||||
only_if { current['logfile'] && current['logfile'] != 'stdout' }
|
||||
end
|
||||
end
|
||||
|
||||
# <%=@name%> <%=@masterip%> <%=@masterport%> <%= @quorum_count %>
|
||||
# <%= "sentinel auth-pass #{@name} #{@authpass}" unless @authpass.nil? %>
|
||||
# sentinel down-after-milliseconds <%=@name%> <%=@downaftermil%>
|
||||
# sentinel parallel-syncs <%=@name%> <%=@parallelsyncs%>
|
||||
# sentinel failover-timeout <%=@name%> <%=@failovertimeout%>
|
||||
|
||||
# convert from old format (preserve compat)
|
||||
if !current['masters'] && current['master_ip']
|
||||
Chef::Log.warn('You are using a deprecated sentinel format. This will be removed in future versions.')
|
||||
|
||||
# use old key names if newer key names aren't present (e.g. 'foo' || :foo)
|
||||
masters = [
|
||||
{
|
||||
master_name: current['master_name'] || current[:mastername],
|
||||
master_ip: current['master_ip'] || current[:masterip],
|
||||
master_port: current['master_port'] || current[:masterport],
|
||||
quorum_count: current['quorum_count'] || current[:quorum_count],
|
||||
auth_pass: current['auth-pass'] || current[:authpass],
|
||||
down_after_milliseconds: current['down-after-milliseconds'] || current[:downaftermil],
|
||||
parallel_syncs: current['parallel-syncs'] || current[:parallelsyncs],
|
||||
failover_timeout: current['failover-timeout'] || current[:failovertimeout],
|
||||
},
|
||||
]
|
||||
else
|
||||
masters = [current['masters']].flatten
|
||||
end
|
||||
|
||||
# Load password for use with requirepass from data bag if needed
|
||||
if current['data_bag_name'] && current['data_bag_item'] && current['data_bag_key']
|
||||
bag = data_bag_item(current['data_bag_name'], current['data_bag_item'])
|
||||
masters.each do |master|
|
||||
master['auth_pass'] = bag[current['data_bag_key']]
|
||||
end
|
||||
end
|
||||
|
||||
# merge in default values to each sentinel hash
|
||||
masters_with_defaults = []
|
||||
masters.each do |current_sentinel_master|
|
||||
default_sentinel_master = new_resource.sentinel_defaults.to_hash
|
||||
sentinel_master = default_sentinel_master.merge(current_sentinel_master || {})
|
||||
masters_with_defaults << sentinel_master
|
||||
end
|
||||
|
||||
# Don't render a template if we're missing these from any sentinel,
|
||||
# as these are the minimal settings required to be passed in
|
||||
masters_with_defaults.each do |sentinel_instance|
|
||||
%w(master_ip master_port quorum_count).each do |param|
|
||||
raise "Missing required sentinel parameter #{param} for #{sentinel_instance}" unless sentinel_instance[param]
|
||||
end
|
||||
end
|
||||
|
||||
# Lay down the configuration files for the current instance
|
||||
template "#{current['configdir']}/#{sentinel_name}.conf" do
|
||||
source 'sentinel.conf.erb'
|
||||
cookbook 'redisio'
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
action :create
|
||||
variables(
|
||||
name: current['name'],
|
||||
piddir: piddir,
|
||||
version: version_hash,
|
||||
job_control: node['redisio']['job_control'],
|
||||
sentinel_bind: current['sentinel_bind'],
|
||||
sentinel_port: current['sentinel_port'],
|
||||
loglevel: current['loglevel'],
|
||||
logfile: current['logfile'],
|
||||
syslogenabled: current['syslogenabled'],
|
||||
syslogfacility: current['syslogfacility'],
|
||||
masters: masters_with_defaults,
|
||||
announce_ip: current['announce-ip'],
|
||||
announce_port: current['announce-port'],
|
||||
notification_script: current['notification-script'],
|
||||
client_reconfig_script: current['client-reconfig-script'],
|
||||
protected_mode: current['protected_mode']
|
||||
)
|
||||
not_if { ::File.exist?("#{current['configdir']}/#{sentinel_name}.conf.breadcrumb") }
|
||||
end
|
||||
|
||||
file "#{current['configdir']}/#{sentinel_name}.conf.breadcrumb" do
|
||||
content 'This file prevents the chef cookbook from overwritting the sentinel config more than once'
|
||||
action :create_if_missing
|
||||
end
|
||||
|
||||
# Setup init.d file
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
template "/etc/init.d/redis_#{sentinel_name}" do
|
||||
source 'sentinel.init.erb'
|
||||
cookbook 'redisio'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
variables(
|
||||
name: sentinel_name,
|
||||
bin_path: bin_path,
|
||||
user: current['user'],
|
||||
configdir: current['configdir'],
|
||||
piddir: piddir,
|
||||
platform: node['platform']
|
||||
)
|
||||
only_if { node['redisio']['job_control'] == 'initd' }
|
||||
end
|
||||
|
||||
template "/etc/init/redis_#{sentinel_name}.conf" do
|
||||
source 'sentinel.upstart.conf.erb'
|
||||
cookbook 'redisio'
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0644'
|
||||
variables(
|
||||
name: sentinel_name,
|
||||
bin_path: bin_path,
|
||||
user: current['user'],
|
||||
group: current['group'],
|
||||
configdir: current['configdir'],
|
||||
piddir: piddir
|
||||
)
|
||||
only_if { node['redisio']['job_control'] == 'upstart' }
|
||||
end
|
||||
# TODO: fix for freebsd
|
||||
template "/usr/local/etc/rc.d/redis_#{sentinel_name}" do
|
||||
source 'sentinel.rcinit.erb'
|
||||
cookbook 'redisio'
|
||||
owner current['user']
|
||||
group current['group']
|
||||
mode '0755'
|
||||
variables(
|
||||
name: sentinel_name,
|
||||
bin_path: bin_path,
|
||||
user: current['user'],
|
||||
configdir: current['configdir'],
|
||||
piddir: piddir
|
||||
)
|
||||
only_if { node['redisio']['job_control'] == 'rcinit' }
|
||||
end
|
||||
end
|
||||
# servers each loop
|
||||
end
|
||||
|
||||
def redis_exists?
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
redis_server = ::File.join(bin_path, 'redis-server')
|
||||
::File.exist?(redis_server)
|
||||
end
|
||||
|
||||
def version
|
||||
if redis_exists?
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
redis_server = ::File.join(bin_path, 'redis-server')
|
||||
redis_version = Mixlib::ShellOut.new("#{redis_server} -v")
|
||||
redis_version.run_command
|
||||
version = redis_version.stdout[/version (\d*.\d*.\d*)/, 1] || redis_version.stdout[/v=(\d*.\d*.\d*)/, 1]
|
||||
Chef::Log.info("The Redis server version is: #{version}")
|
||||
return version.delete("\n")
|
||||
end
|
||||
nil
|
||||
end
|
||||
@@ -1,18 +0,0 @@
|
||||
packages_to_install = case node['platform_family']
|
||||
when 'debian'
|
||||
%w(
|
||||
tar
|
||||
)
|
||||
when 'rhel', 'fedora'
|
||||
%w(
|
||||
tar
|
||||
)
|
||||
else
|
||||
%w()
|
||||
end
|
||||
|
||||
packages_to_install.each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
@@ -1,56 +0,0 @@
|
||||
include_recipe 'redisio::default'
|
||||
include_recipe 'redisio::ulimit'
|
||||
|
||||
redis = node['redisio']
|
||||
|
||||
redis_instances = redis['servers']
|
||||
if redis_instances.nil?
|
||||
redis_instances = [
|
||||
{
|
||||
'port' => '6379',
|
||||
},
|
||||
]
|
||||
end
|
||||
|
||||
redisio_configure 'redis-servers' do
|
||||
version redis['version'] if redis['version']
|
||||
default_settings redis['default_settings']
|
||||
servers redis_instances
|
||||
base_piddir redis['base_piddir']
|
||||
end
|
||||
|
||||
# Create a service resource for each redis instance, named for the port it runs on.
|
||||
redis_instances.each do |current_server|
|
||||
server_name = current_server['name'] || current_server['port']
|
||||
|
||||
case node['redisio']['job_control']
|
||||
when 'initd'
|
||||
service "redis#{server_name}" do
|
||||
# don't supply start/stop/restart commands, Chef::Provider::Service::*
|
||||
# do a fine job on it's own, and support systemd correctly
|
||||
supports start: true, stop: true, restart: false, status: true
|
||||
end
|
||||
when 'upstart'
|
||||
service "redis#{server_name}" do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
start_command "start redis#{server_name}"
|
||||
stop_command "stop redis#{server_name}"
|
||||
restart_command "restart redis#{server_name}"
|
||||
supports start: true, stop: true, restart: true, status: false
|
||||
end
|
||||
when 'systemd'
|
||||
service "redis@#{server_name}" do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports start: true, stop: true, restart: true, status: true
|
||||
end
|
||||
when 'rcinit'
|
||||
service "redis#{server_name}" do
|
||||
provider Chef::Provider::Service::Freebsd
|
||||
supports start: true, stop: true, restart: true, status: true
|
||||
end
|
||||
else
|
||||
Chef::Log.error('Unknown job control type, no service resource created!')
|
||||
end
|
||||
end
|
||||
|
||||
node.override['redisio']['servers'] = redis_instances
|
||||
@@ -1,12 +0,0 @@
|
||||
apt_update
|
||||
|
||||
unless node['redisio']['package_install']
|
||||
include_recipe 'redisio::_install_prereqs'
|
||||
build_essential 'install build deps'
|
||||
end
|
||||
|
||||
unless node['redisio']['bypass_setup']
|
||||
include_recipe 'redisio::install'
|
||||
include_recipe 'redisio::disable_os_default'
|
||||
include_recipe 'redisio::configure'
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
redis = node['redisio']
|
||||
|
||||
redis['servers'].each do |current_server|
|
||||
server_name = current_server['name'] || current_server['port']
|
||||
resource_name = if node['redisio']['job_control'] == 'systemd'
|
||||
"service[redis@#{server_name}]"
|
||||
else
|
||||
"service[redis#{server_name}]"
|
||||
end
|
||||
resource = resources(resource_name)
|
||||
resource.action Array(resource.action)
|
||||
resource.action << :stop
|
||||
resource.action << :disable
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
# disable the default OS redis init script
|
||||
service_name = case node['platform_family']
|
||||
when 'debian'
|
||||
'redis-server'
|
||||
when 'rhel', 'fedora'
|
||||
'redis'
|
||||
end
|
||||
|
||||
service service_name do
|
||||
action [:stop, :disable]
|
||||
only_if { service_name }
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
redis = node['redisio']
|
||||
|
||||
redis['servers'].each do |current_server|
|
||||
server_name = current_server['name'] || current_server['port']
|
||||
resource_name = if node['redisio']['job_control'] == 'systemd'
|
||||
"service[redis@#{server_name}]"
|
||||
else
|
||||
"service[redis#{server_name}]"
|
||||
end
|
||||
resource = resources(resource_name)
|
||||
resource.action Array(resource.action)
|
||||
resource.action.concat [:start, :enable]
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
if node['redisio']['package_install']
|
||||
package 'redisio_package_name' do
|
||||
package_name node['redisio']['package_name']
|
||||
version node['redisio']['version'] if node['redisio']['version']
|
||||
action :install
|
||||
end
|
||||
else
|
||||
include_recipe 'redisio::_install_prereqs'
|
||||
build_essential 'install build deps'
|
||||
|
||||
redis = node['redisio']
|
||||
location = "#{redis['mirror']}/#{redis['base_name']}#{redis['version']}.#{redis['artifact_type']}"
|
||||
|
||||
redisio_install 'redis-installation' do
|
||||
version redis['version'] if redis['version']
|
||||
download_url location
|
||||
safe_install redis['safe_install']
|
||||
install_dir redis['install_dir'] if redis['install_dir']
|
||||
end
|
||||
end
|
||||
|
||||
include_recipe 'redisio::ulimit'
|
||||
@@ -1,4 +0,0 @@
|
||||
gem_package node['redisio']['gem']['name'] do
|
||||
version node['redisio']['gem']['version'] unless node['redisio']['gem']['version'].nil?
|
||||
action :install
|
||||
end
|
||||
@@ -1,78 +0,0 @@
|
||||
include_recipe 'redisio::_install_prereqs'
|
||||
include_recipe 'redisio::install'
|
||||
include_recipe 'redisio::ulimit'
|
||||
|
||||
redis = node['redisio']
|
||||
|
||||
sentinel_instances = redis['sentinels']
|
||||
if sentinel_instances.nil?
|
||||
sentinel_instances = [
|
||||
{
|
||||
'sentinel_port' => '26379',
|
||||
'name' => 'mycluster',
|
||||
'masters' => [
|
||||
{
|
||||
'master_name' => 'mycluster_master',
|
||||
'master_ip' => '127.0.0.1',
|
||||
'master_port' => '6379',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
end
|
||||
|
||||
redisio_sentinel 'redis-sentinels' do
|
||||
version redis['version'] if redis['version']
|
||||
sentinel_defaults redis['sentinel_defaults']
|
||||
sentinels sentinel_instances
|
||||
base_piddir redis['base_piddir']
|
||||
end
|
||||
|
||||
bin_path = if node['redisio']['install_dir']
|
||||
::File.join(node['redisio']['install_dir'], 'bin')
|
||||
else
|
||||
node['redisio']['bin_path']
|
||||
end
|
||||
|
||||
template '/lib/systemd/system/redis-sentinel@.service' do
|
||||
source 'redis-sentinel@.service'
|
||||
variables(
|
||||
bin_path: bin_path,
|
||||
limit_nofile: redis['default_settings']['maxclients'] + 32
|
||||
)
|
||||
only_if { node['redisio']['job_control'] == 'systemd' }
|
||||
end
|
||||
|
||||
# Create a service resource for each sentinel instance, named for the port it runs on.
|
||||
sentinel_instances.each do |current_sentinel|
|
||||
sentinel_name = current_sentinel['name']
|
||||
|
||||
case node['redisio']['job_control']
|
||||
when 'initd'
|
||||
service "redis_sentinel_#{sentinel_name}" do
|
||||
# don't supply start/stop/restart commands, Chef::Provider::Service::*
|
||||
# do a fine job on it's own, and support systemd correctly
|
||||
supports start: true, stop: true, restart: true, status: false
|
||||
end
|
||||
when 'upstart'
|
||||
service "redis_sentinel_#{sentinel_name}" do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
start_command "start redis_sentinel_#{sentinel_name}"
|
||||
stop_command "stop redis_sentinel_#{sentinel_name}"
|
||||
restart_command "restart redis_sentinel_#{sentinel_name}"
|
||||
supports start: true, stop: true, restart: true, status: false
|
||||
end
|
||||
when 'systemd'
|
||||
service "redis-sentinel@#{sentinel_name}" do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports start: true, stop: true, restart: true, status: true
|
||||
end
|
||||
when 'rcinit'
|
||||
service "redis_sentinel_#{sentinel_name}" do
|
||||
provider Chef::Provider::Service::Freebsd
|
||||
supports start: true, stop: true, restart: true, status: true
|
||||
end
|
||||
else
|
||||
Chef::Log.error('Unknown job control type, no service resource created!')
|
||||
end
|
||||
end
|
||||
@@ -1,38 +0,0 @@
|
||||
sentinel_instances = node['redisio']['sentinels']
|
||||
|
||||
if sentinel_instances.nil?
|
||||
sentinel_instances = [
|
||||
{
|
||||
'sentinel_port' => '26379',
|
||||
'name' => 'mycluster',
|
||||
'master_ip' => '127.0.0.1',
|
||||
'master_port' => '6379',
|
||||
},
|
||||
]
|
||||
end
|
||||
|
||||
execute 'reload-systemd-sentinel' do
|
||||
command 'systemctl daemon-reload'
|
||||
only_if { node['redisio']['job_control'] == 'systemd' }
|
||||
action :nothing
|
||||
end
|
||||
|
||||
sentinel_instances.each do |current_sentinel|
|
||||
sentinel_name = current_sentinel['name']
|
||||
resource_name = if node['redisio']['job_control'] == 'systemd'
|
||||
"service[redis-sentinel@#{sentinel_name}]"
|
||||
else
|
||||
"service[redis_sentinel_#{sentinel_name}]"
|
||||
end
|
||||
resource = resources(resource_name)
|
||||
resource.action Array(resource.action)
|
||||
resource.action << :start
|
||||
if node['redisio']['job_control'] != 'systemd'
|
||||
resource.action << :enable
|
||||
else
|
||||
link "/etc/systemd/system/multi-user.target.wants/redis-sentinel@#{sentinel_name}.service" do
|
||||
to '/usr/lib/systemd/system/redis-sentinel@.service'
|
||||
notifies :run, 'execute[reload-systemd-sentinel]', :immediately
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
# Pulled from the now replaced ulimit cookbook
|
||||
# TODO: find a more tidy way to do this
|
||||
ulimit = node['ulimit']
|
||||
|
||||
if platform_family?('debian')
|
||||
template '/etc/pam.d/su' do
|
||||
cookbook ulimit['pam_su_template_cookbook']
|
||||
end
|
||||
|
||||
cookbook_file '/etc/pam.d/sudo' do
|
||||
cookbook node['ulimit']['ulimit_overriding_sudo_file_cookbook']
|
||||
source node['ulimit']['ulimit_overriding_sudo_file_name']
|
||||
mode '0644'
|
||||
end
|
||||
end
|
||||
|
||||
if ulimit.key?('users')
|
||||
ulimit['users'].each do |user, attributes|
|
||||
user_ulimit user do
|
||||
attributes.each do |a, v|
|
||||
send(a.to_sym, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"last-release-sha": "b68590fe972f64e7a5bc715d9e3d03230e701d6c",
|
||||
"packages": {
|
||||
".": {
|
||||
"package-name": "redisio",
|
||||
"changelog-path": "CHANGELOG.md",
|
||||
"release-type": "ruby",
|
||||
"release-as": "8.0.0",
|
||||
"include-component-in-tag": false,
|
||||
"version-file": "metadata.rb"
|
||||
}
|
||||
},
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:base"],
|
||||
"packageRules": [{
|
||||
"packageRules": [
|
||||
{
|
||||
"groupName": "Actions",
|
||||
"matchUpdateTypes": ["patch", "pin", "digest"],
|
||||
"matchUpdateTypes": ["minor", "patch", "pin"],
|
||||
"automerge": true,
|
||||
"addLabels": ["Release: Patch", "Skip: Announcements"]
|
||||
},
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
property :version
|
||||
property :base_piddir, String, default: '/var/run/redis'
|
||||
property :user, String, default: 'redis'
|
||||
property :group, String, default: 'redis'
|
||||
property :uid
|
||||
property :systemuser, [true, false], default: true
|
||||
property :homedir
|
||||
property :shell
|
||||
property :configdir
|
||||
property :loglevel, String, default: 'notice'
|
||||
property :logfile, default: nil
|
||||
property :syslogenabled, String, default: 'yes'
|
||||
property :syslogfacility, String, default: 'local0'
|
||||
property :protected_mode, default: nil
|
||||
property :maxclients, Integer, default: 10_000
|
||||
property :aclfile, default: nil
|
||||
property :includes, default: nil
|
||||
property :data_bag_name, default: nil
|
||||
property :data_bag_item, default: nil
|
||||
property :data_bag_key, default: nil
|
||||
property :tlsport, default: nil
|
||||
property :tlscertfile, default: nil
|
||||
property :tlskeyfile, default: nil
|
||||
property :tlskeyfilepass, default: nil
|
||||
property :tlsclientcertfile, default: nil
|
||||
property :tlsclientkeyfile, default: nil
|
||||
property :tlsclientkeyfilepass, default: nil
|
||||
property :tlsdhparamsfile, default: nil
|
||||
property :tlscacertfile, default: nil
|
||||
property :tlscacertdir, default: nil
|
||||
property :tlsauthclients, default: nil
|
||||
property :tlsreplication, default: nil
|
||||
property :tlscluster, default: nil
|
||||
property :tlsprotocols, default: nil
|
||||
property :tlsciphers, default: nil
|
||||
property :tlsciphersuites, default: nil
|
||||
property :tlspreferserverciphers, default: nil
|
||||
property :tlssessioncaching, default: nil
|
||||
property :tlssessioncachesize, default: nil
|
||||
property :tlssessioncachetimeout, default: nil
|
||||
property :package_install, [true, false], default: false, desired_state: false
|
||||
property :package_name
|
||||
property :install_dir, default: nil
|
||||
property :bin_path
|
||||
@@ -0,0 +1,70 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
property :port, [String, Integer], default: 6379
|
||||
property :permissions, String, default: '0644'
|
||||
property :name_override, default: nil
|
||||
property :tcpbacklog, String, default: '511'
|
||||
property :address, default: nil
|
||||
property :databases, String, default: '16'
|
||||
property :backuptype, String, default: 'rdb'
|
||||
property :datadir, String, default: '/var/lib/redis'
|
||||
property :unixsocket, default: nil
|
||||
property :unixsocketperm, default: nil
|
||||
property :timeout, String, default: '0'
|
||||
property :keepalive, String, default: '0'
|
||||
property :save, default: nil
|
||||
property :stopwritesonbgsaveerror, String, default: 'yes'
|
||||
property :rdbcompression, String, default: 'yes'
|
||||
property :rdbchecksum, String, default: 'yes'
|
||||
property :dbfilename, default: nil
|
||||
property :replicaof, default: nil
|
||||
property :masterauth, default: nil
|
||||
property :replicaservestaledata, String, default: 'yes'
|
||||
property :replicareadonly, String, default: 'yes'
|
||||
property :repldisklesssync, String, default: 'no'
|
||||
property :repldisklesssyncdelay, String, default: '5'
|
||||
property :replpingreplicaperiod, String, default: '10'
|
||||
property :repltimeout, String, default: '60'
|
||||
property :repldisabletcpnodelay, String, default: 'no'
|
||||
property :replbacklogsize, String, default: '1mb'
|
||||
property :replbacklogttl, default: 3600
|
||||
property :replicapriority, String, default: '100'
|
||||
property :requirepass, default: nil
|
||||
property :rename_commands, default: nil
|
||||
property :maxmemory, default: nil
|
||||
property :maxmemorypolicy, default: nil
|
||||
property :maxmemorysamples, default: nil
|
||||
property :appendfilename, default: nil
|
||||
property :appendfsync, String, default: 'everysec'
|
||||
property :noappendfsynconrewrite, String, default: 'no'
|
||||
property :aofrewritepercentage, String, default: '100'
|
||||
property :aofrewriteminsize, String, default: '64mb'
|
||||
property :aofloadtruncated, String, default: 'yes'
|
||||
property :luatimelimit, String, default: '5000'
|
||||
property :slowloglogslowerthan, String, default: '10000'
|
||||
property :slowlogmaxlen, String, default: '1024'
|
||||
property :notifykeyspaceevents, String, default: ''
|
||||
property :hashmaxziplistentries, String, default: '512'
|
||||
property :hashmaxziplistvalue, String, default: '64'
|
||||
property :setmaxintsetentries, String, default: '512'
|
||||
property :zsetmaxziplistentries, String, default: '128'
|
||||
property :zsetmaxziplistvalue, String, default: '64'
|
||||
property :hllsparsemaxbytes, String, default: '3000'
|
||||
property :activerehasing, String, default: 'yes'
|
||||
property :clientoutputbufferlimit, default: [
|
||||
%w(normal 0 0 0),
|
||||
%w(replica 256mb 64mb 60),
|
||||
%w(pubsub 32mb 8mb 60),
|
||||
]
|
||||
property :hz, String, default: '10'
|
||||
property :aofrewriteincrementalfsync, String, default: 'yes'
|
||||
property :clusterenabled, String, default: 'no'
|
||||
property :clusterconfigfile, default: nil
|
||||
property :clusternodetimeout, default: 5000
|
||||
property :clusterport, default: nil
|
||||
property :minreplicastowrite, default: nil
|
||||
property :minreplicasmaxlag, default: nil
|
||||
property :ulimit, Integer, default: 0
|
||||
property :breadcrumb, [true, false], default: true
|
||||
property :template_cookbook, String, default: 'redisio'
|
||||
property :template_source, String, default: 'redis.conf.erb'
|
||||
@@ -1,12 +1,155 @@
|
||||
actions :run
|
||||
# frozen_string_literal: true
|
||||
|
||||
provides :redisio_configure
|
||||
unified_mode true
|
||||
default_action :run
|
||||
|
||||
# Configuration attributes
|
||||
attribute :version, kind_of: String
|
||||
attribute :base_piddir, kind_of: String, default: '/var/run/redis'
|
||||
attribute :user, kind_of: String, default: 'redis'
|
||||
attribute :group, kind_of: String, default: 'redis'
|
||||
property :version, [String, NilClass]
|
||||
property :base_piddir, String, default: '/var/run/redis'
|
||||
property :user, String, default: 'redis'
|
||||
property :group, String, default: 'redis'
|
||||
property :default_settings, Hash, default: {}
|
||||
property :servers, [Array, NilClass], default: nil
|
||||
property :package_install, [true, false], default: false
|
||||
property :package_name, [String, NilClass]
|
||||
property :install_dir, [String, NilClass]
|
||||
property :bin_path, [String, NilClass]
|
||||
|
||||
attribute :default_settings, kind_of: Hash
|
||||
attribute :servers, kind_of: Array
|
||||
action_class do
|
||||
include RedisioCookbook::Helpers
|
||||
|
||||
def normalized_servers
|
||||
return [{ 'port' => 6379 }] if new_resource.servers.nil?
|
||||
|
||||
normalize_array(new_resource.servers).map { |server| deep_stringify_keys(normalize_hash(server)) }
|
||||
end
|
||||
|
||||
def merged_defaults(server)
|
||||
deep_stringify_keys(normalize_hash(new_resource.default_settings)).merge(server)
|
||||
end
|
||||
end
|
||||
|
||||
action :create do
|
||||
normalized_servers.each do |server|
|
||||
merged = merged_defaults(server)
|
||||
instance_name = (merged['name'] || merged['port']).to_s
|
||||
|
||||
redisio_server instance_name do
|
||||
version new_resource.version || merged['version']
|
||||
base_piddir new_resource.base_piddir
|
||||
user merged.fetch('user', new_resource.user)
|
||||
group merged.fetch('group', new_resource.group)
|
||||
uid merged['uid']
|
||||
systemuser merged.fetch('systemuser', true)
|
||||
homedir merged['homedir']
|
||||
shell merged['shell']
|
||||
configdir merged['configdir']
|
||||
loglevel merged.fetch('loglevel', 'notice')
|
||||
logfile merged['logfile']
|
||||
syslogenabled merged.fetch('syslogenabled', 'yes')
|
||||
syslogfacility merged.fetch('syslogfacility', 'local0')
|
||||
protected_mode merged['protected_mode']
|
||||
maxclients merged.fetch('maxclients', 10_000)
|
||||
aclfile merged['aclfile']
|
||||
includes merged['includes']
|
||||
data_bag_name merged['data_bag_name']
|
||||
data_bag_item merged['data_bag_item']
|
||||
data_bag_key merged['data_bag_key']
|
||||
tlsport merged['tlsport']
|
||||
tlscertfile merged['tlscertfile']
|
||||
tlskeyfile merged['tlskeyfile']
|
||||
tlskeyfilepass merged['tlskeyfilepass']
|
||||
tlsclientcertfile merged['tlsclientcertfile']
|
||||
tlsclientkeyfile merged['tlsclientkeyfile']
|
||||
tlsclientkeyfilepass merged['tlsclientkeyfilepass']
|
||||
tlsdhparamsfile merged['tlsdhparamsfile']
|
||||
tlscacertfile merged['tlscacertfile']
|
||||
tlscacertdir merged['tlscacertdir']
|
||||
tlsauthclients merged['tlsauthclients']
|
||||
tlsreplication merged['tlsreplication']
|
||||
tlscluster merged['tlscluster']
|
||||
tlsprotocols merged['tlsprotocols']
|
||||
tlsciphers merged['tlsciphers']
|
||||
tlsciphersuites merged['tlsciphersuites']
|
||||
tlspreferserverciphers merged['tlspreferserverciphers']
|
||||
tlssessioncaching merged['tlssessioncaching']
|
||||
tlssessioncachesize merged['tlssessioncachesize']
|
||||
tlssessioncachetimeout merged['tlssessioncachetimeout']
|
||||
package_install new_resource.package_install
|
||||
package_name new_resource.package_name
|
||||
install_dir new_resource.install_dir
|
||||
bin_path new_resource.bin_path
|
||||
port merged.fetch('port', 6379)
|
||||
permissions merged.fetch('permissions', '0644')
|
||||
name_override merged['name']
|
||||
tcpbacklog merged.fetch('tcpbacklog', '511')
|
||||
address merged['address']
|
||||
databases merged.fetch('databases', '16')
|
||||
backuptype merged.fetch('backuptype', 'rdb')
|
||||
datadir merged.fetch('datadir', '/var/lib/redis')
|
||||
unixsocket merged['unixsocket']
|
||||
unixsocketperm merged['unixsocketperm']
|
||||
timeout merged.fetch('timeout', '0')
|
||||
keepalive merged.fetch('keepalive', '0')
|
||||
save merged['save']
|
||||
stopwritesonbgsaveerror merged.fetch('stopwritesonbgsaveerror', 'yes')
|
||||
rdbcompression merged.fetch('rdbcompression', 'yes')
|
||||
rdbchecksum merged.fetch('rdbchecksum', 'yes')
|
||||
dbfilename merged['dbfilename']
|
||||
replicaof merged['replicaof']
|
||||
masterauth merged['masterauth']
|
||||
replicaservestaledata merged.fetch('replicaservestaledata', 'yes')
|
||||
replicareadonly merged.fetch('replicareadonly', 'yes')
|
||||
repldisklesssync merged.fetch('repldisklesssync', 'no')
|
||||
repldisklesssyncdelay merged.fetch('repldisklesssyncdelay', '5')
|
||||
replpingreplicaperiod merged.fetch('replpingreplicaperiod', '10')
|
||||
repltimeout merged.fetch('repltimeout', '60')
|
||||
repldisabletcpnodelay merged.fetch('repldisabletcpnodelay', 'no')
|
||||
replbacklogsize merged.fetch('replbacklogsize', '1mb')
|
||||
replbacklogttl merged.fetch('replbacklogttl', 3600)
|
||||
replicapriority merged.fetch('replicapriority', '100')
|
||||
requirepass merged['requirepass']
|
||||
rename_commands merged['rename_commands']
|
||||
maxmemory merged['maxmemory']
|
||||
maxmemorypolicy merged['maxmemorypolicy']
|
||||
maxmemorysamples merged['maxmemorysamples']
|
||||
appendfilename merged['appendfilename']
|
||||
appendfsync merged.fetch('appendfsync', 'everysec')
|
||||
noappendfsynconrewrite merged.fetch('noappendfsynconrewrite', 'no')
|
||||
aofrewritepercentage merged.fetch('aofrewritepercentage', '100')
|
||||
aofrewriteminsize merged.fetch('aofrewriteminsize', '64mb')
|
||||
aofloadtruncated merged.fetch('aofloadtruncated', 'yes')
|
||||
luatimelimit merged.fetch('luatimelimit', '5000')
|
||||
slowloglogslowerthan merged.fetch('slowloglogslowerthan', '10000')
|
||||
slowlogmaxlen merged.fetch('slowlogmaxlen', '1024')
|
||||
notifykeyspaceevents merged.fetch('notifykeyspaceevents', '')
|
||||
hashmaxziplistentries merged.fetch('hashmaxziplistentries', '512')
|
||||
hashmaxziplistvalue merged.fetch('hashmaxziplistvalue', '64')
|
||||
setmaxintsetentries merged.fetch('setmaxintsetentries', '512')
|
||||
zsetmaxziplistentries merged.fetch('zsetmaxziplistentries', '128')
|
||||
zsetmaxziplistvalue merged.fetch('zsetmaxziplistvalue', '64')
|
||||
hllsparsemaxbytes merged.fetch('hllsparsemaxbytes', '3000')
|
||||
activerehasing merged.fetch('activerehasing', 'yes')
|
||||
clientoutputbufferlimit merged.fetch(
|
||||
'clientoutputbufferlimit',
|
||||
[
|
||||
%w(normal 0 0 0),
|
||||
%w(replica 256mb 64mb 60),
|
||||
%w(pubsub 32mb 8mb 60),
|
||||
]
|
||||
)
|
||||
hz merged.fetch('hz', '10')
|
||||
aofrewriteincrementalfsync merged.fetch('aofrewriteincrementalfsync', 'yes')
|
||||
clusterenabled merged.fetch('clusterenabled', 'no')
|
||||
clusterconfigfile merged['clusterconfigfile']
|
||||
clusternodetimeout merged.fetch('clusternodetimeout', 5000)
|
||||
clusterport merged['clusterport']
|
||||
minreplicastowrite merged['minreplicastowrite']
|
||||
minreplicasmaxlag merged['minreplicasmaxlag']
|
||||
ulimit merged.fetch('ulimit', 0)
|
||||
breadcrumb merged.fetch('breadcrumb', true)
|
||||
template_cookbook merged.fetch('template_cookbook', 'redisio')
|
||||
template_source merged.fetch('template_source', 'redis.conf.erb')
|
||||
action new_resource.action
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,135 @@
|
||||
actions :run
|
||||
# frozen_string_literal: true
|
||||
|
||||
provides :redisio_install
|
||||
unified_mode true
|
||||
default_action :run
|
||||
|
||||
# Installation attributes
|
||||
attribute :version, kind_of: String
|
||||
attribute :download_url, kind_of: String
|
||||
attribute :download_dir, kind_of: String, default: Chef::Config[:file_cache_path]
|
||||
attribute :artifact_type, kind_of: String, default: 'tar.gz'
|
||||
attribute :base_name, kind_of: String, default: 'redis-'
|
||||
attribute :safe_install, kind_of: [TrueClass, FalseClass], default: true
|
||||
property :package_install, [true, false], default: false
|
||||
property :package_name, [String, NilClass]
|
||||
property :version, [String, NilClass]
|
||||
property :download_url, [String, NilClass]
|
||||
property :download_dir, String, default: lazy { Chef::Config[:file_cache_path] }
|
||||
property :artifact_type, String, default: 'tar.gz'
|
||||
property :base_name, String, default: 'redis-'
|
||||
property :safe_install, [true, false], default: true
|
||||
property :install_dir, [String, NilClass]
|
||||
|
||||
attribute :install_dir, kind_of: String, default: nil
|
||||
action_class do
|
||||
include RedisioCookbook::Helpers
|
||||
|
||||
def resolved_package_name
|
||||
new_resource.package_name || platform_package_name
|
||||
end
|
||||
|
||||
def resolved_version
|
||||
return new_resource.version if new_resource.version
|
||||
return if new_resource.package_install
|
||||
|
||||
'3.2.11'
|
||||
end
|
||||
|
||||
def resolved_download_url
|
||||
return new_resource.download_url if new_resource.download_url
|
||||
|
||||
version = resolved_version || 'redis-stable'
|
||||
base_url = version == 'redis-stable' ? 'https://download.redis.io' : 'https://download.redis.io/releases'
|
||||
file_name = version == 'redis-stable' ? version : "#{new_resource.base_name}#{version}"
|
||||
"#{base_url}/#{file_name}.#{new_resource.artifact_type}"
|
||||
end
|
||||
|
||||
def resolved_bin_path
|
||||
platform_default_bin_path(package_install: new_resource.package_install, install_dir: new_resource.install_dir)
|
||||
end
|
||||
|
||||
def resolved_server_binary
|
||||
redis_server_binary(resolved_bin_path, package_install: new_resource.package_install, package_name: resolved_package_name)
|
||||
end
|
||||
|
||||
def tarball_name
|
||||
return 'redis-stable.tar.gz' if resolved_download_url.end_with?('redis-stable.tar.gz')
|
||||
|
||||
"#{new_resource.base_name}#{resolved_version}.#{new_resource.artifact_type}"
|
||||
end
|
||||
|
||||
def source_directory
|
||||
return 'redis-stable' if tarball_name.start_with?('redis-stable')
|
||||
|
||||
"#{new_resource.base_name}#{new_resource.version}"
|
||||
end
|
||||
|
||||
def package_service_name
|
||||
platform_default_service_name
|
||||
end
|
||||
end
|
||||
|
||||
action :create do
|
||||
if new_resource.package_install
|
||||
if platform_family?('debian')
|
||||
apt_update 'redisio-package-cache'
|
||||
end
|
||||
|
||||
package resolved_package_name do
|
||||
version resolved_version unless resolved_version.nil?
|
||||
end
|
||||
|
||||
service package_service_name do
|
||||
action %i(stop disable)
|
||||
end
|
||||
else
|
||||
source_build_packages.each do |build_package|
|
||||
package build_package
|
||||
end
|
||||
|
||||
current_version = installed_redis_version(resolved_bin_path, package_install: new_resource.package_install, package_name: resolved_package_name)
|
||||
converge_if_changed :version do
|
||||
if current_version == resolved_version || (current_version && new_resource.safe_install)
|
||||
Chef::Log.info("Skipping Redis source install because #{current_version} is already present")
|
||||
else
|
||||
remote_file "#{new_resource.download_dir}/#{tarball_name}" do
|
||||
source resolved_download_url
|
||||
end
|
||||
|
||||
directory "#{new_resource.download_dir}/#{source_directory}" do
|
||||
recursive true
|
||||
end
|
||||
|
||||
execute "extract-#{source_directory}" do
|
||||
cwd new_resource.download_dir
|
||||
command "tar zxf #{Shellwords.escape(tarball_name)} --strip-components=1 -C #{Shellwords.escape(source_directory)} --no-same-owner"
|
||||
creates "#{new_resource.download_dir}/#{source_directory}/src/redis-server"
|
||||
end
|
||||
|
||||
execute "build-#{source_directory}" do
|
||||
cwd "#{new_resource.download_dir}/#{source_directory}"
|
||||
command 'make clean && make'
|
||||
end
|
||||
|
||||
execute "install-#{source_directory}" do
|
||||
cwd "#{new_resource.download_dir}/#{source_directory}"
|
||||
command new_resource.install_dir ? "make PREFIX=#{Shellwords.escape(new_resource.install_dir)} install" : 'make install'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if new_resource.package_install
|
||||
service package_service_name do
|
||||
action %i(stop disable)
|
||||
end
|
||||
|
||||
package resolved_package_name do
|
||||
action :remove
|
||||
end
|
||||
else
|
||||
binaries = %w(redis-benchmark redis-check-aof redis-check-rdb redis-sentinel)
|
||||
binaries.unshift(redis_server_binary_name(package_install: new_resource.package_install, package_name: resolved_package_name))
|
||||
binaries.unshift(redis_cli_binary_name(package_install: new_resource.package_install, package_name: resolved_package_name))
|
||||
|
||||
binaries.each do |binary|
|
||||
file ::File.join(resolved_bin_path, binary) do
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,153 @@
|
||||
actions :run
|
||||
# frozen_string_literal: true
|
||||
|
||||
provides :redisio_sentinel
|
||||
unified_mode true
|
||||
default_action :run
|
||||
|
||||
# Configuration attributes
|
||||
attribute :version, kind_of: String
|
||||
attribute :base_piddir, kind_of: String, default: '/var/run/redis'
|
||||
attribute :user, kind_of: String, default: 'redis'
|
||||
property :version, [String, NilClass]
|
||||
property :base_piddir, String, default: '/var/run/redis'
|
||||
property :user, String, default: 'redis'
|
||||
property :group, String, default: 'redis'
|
||||
property :sentinel_defaults, Hash, default: {}
|
||||
property :sentinels, [Array, NilClass], default: nil
|
||||
property :package_install, [true, false], default: false
|
||||
property :package_name, [String, NilClass]
|
||||
property :install_dir, [String, NilClass]
|
||||
property :bin_path, [String, NilClass]
|
||||
|
||||
attribute :sentinel_defaults, kind_of: Hash
|
||||
attribute :sentinels, kind_of: Array
|
||||
action_class do
|
||||
include RedisioCookbook::Helpers
|
||||
|
||||
SENTINEL_KEY_MAP = {
|
||||
'announce-ip' => 'announce_ip',
|
||||
'announce-port' => 'announce_port',
|
||||
'notification-script' => 'notification_script',
|
||||
'client-reconfig-script' => 'client_reconfig_script',
|
||||
}.freeze
|
||||
|
||||
MASTER_KEY_MAP = {
|
||||
'auth-pass' => 'auth_pass',
|
||||
'down-after-milliseconds' => 'down_after_milliseconds',
|
||||
'parallel-syncs' => 'parallel_syncs',
|
||||
'failover-timeout' => 'failover_timeout',
|
||||
}.freeze
|
||||
|
||||
def normalized_sentinels
|
||||
return [
|
||||
{
|
||||
'sentinel_port' => 26_379,
|
||||
'name' => 'mycluster',
|
||||
'masters' => [
|
||||
{
|
||||
'master_name' => 'mycluster_master',
|
||||
'master_ip' => '127.0.0.1',
|
||||
'master_port' => 6379,
|
||||
},
|
||||
],
|
||||
},
|
||||
] if new_resource.sentinels.nil?
|
||||
|
||||
normalize_array(new_resource.sentinels).map { |sentinel| deep_stringify_keys(normalize_hash(sentinel)) }
|
||||
end
|
||||
|
||||
def normalize_sentinel_keys(hash)
|
||||
hash.each_with_object({}) do |(key, value), result|
|
||||
mapped_key = SENTINEL_KEY_MAP.fetch(key, key)
|
||||
result[mapped_key] = value
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_master_keys(hash)
|
||||
hash.each_with_object({}) do |(key, value), result|
|
||||
mapped_key = MASTER_KEY_MAP.fetch(key, key)
|
||||
result[mapped_key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :create do
|
||||
defaults = normalize_sentinel_keys(deep_stringify_keys(normalize_hash(new_resource.sentinel_defaults)))
|
||||
|
||||
normalized_sentinels.each do |sentinel|
|
||||
merged = defaults.merge(normalize_sentinel_keys(sentinel))
|
||||
instance_name = (merged['name'] || merged['sentinel_port']).to_s
|
||||
masters = normalize_array(merged['masters']).map { |master| normalize_master_keys(deep_stringify_keys(normalize_hash(master))) }
|
||||
if masters.empty? && merged['master_ip']
|
||||
masters = [
|
||||
{
|
||||
'master_name' => merged['master_name'] || merged['mastername'],
|
||||
'master_ip' => merged['master_ip'],
|
||||
'master_port' => merged['master_port'],
|
||||
'quorum_count' => merged['quorum_count'],
|
||||
'auth_pass' => merged['auth_pass'] || merged['authpass'],
|
||||
'down_after_milliseconds' => merged['down_after_milliseconds'] || merged['downaftermil'],
|
||||
'parallel_syncs' => merged['parallel_syncs'] || merged['parallelsyncs'],
|
||||
'failover_timeout' => merged['failover_timeout'] || merged['failovertimeout'],
|
||||
},
|
||||
]
|
||||
end
|
||||
|
||||
redisio_sentinel_instance instance_name do
|
||||
version new_resource.version || merged['version']
|
||||
base_piddir new_resource.base_piddir
|
||||
user merged.fetch('user', new_resource.user)
|
||||
group merged.fetch('group', new_resource.group)
|
||||
uid merged['uid']
|
||||
systemuser merged.fetch('systemuser', true)
|
||||
homedir merged['homedir']
|
||||
shell merged['shell']
|
||||
configdir merged['configdir']
|
||||
loglevel merged.fetch('loglevel', 'notice')
|
||||
logfile merged['logfile']
|
||||
syslogenabled merged.fetch('syslogenabled', 'yes')
|
||||
syslogfacility merged.fetch('syslogfacility', 'local0')
|
||||
protected_mode merged['protected_mode']
|
||||
maxclients merged.fetch('maxclients', 10_000)
|
||||
aclfile merged['aclfile']
|
||||
includes merged['includes']
|
||||
data_bag_name merged['data_bag_name']
|
||||
data_bag_item merged['data_bag_item']
|
||||
data_bag_key merged['data_bag_key']
|
||||
tlsport merged['tlsport']
|
||||
tlscertfile merged['tlscertfile']
|
||||
tlskeyfile merged['tlskeyfile']
|
||||
tlskeyfilepass merged['tlskeyfilepass']
|
||||
tlsclientcertfile merged['tlsclientcertfile']
|
||||
tlsclientkeyfile merged['tlsclientkeyfile']
|
||||
tlsclientkeyfilepass merged['tlsclientkeyfilepass']
|
||||
tlsdhparamsfile merged['tlsdhparamsfile']
|
||||
tlscacertfile merged['tlscacertfile']
|
||||
tlscacertdir merged['tlscacertdir']
|
||||
tlsauthclients merged['tlsauthclients']
|
||||
tlsreplication merged['tlsreplication']
|
||||
tlscluster merged['tlscluster']
|
||||
tlsprotocols merged['tlsprotocols']
|
||||
tlsciphers merged['tlsciphers']
|
||||
tlsciphersuites merged['tlsciphersuites']
|
||||
tlspreferserverciphers merged['tlspreferserverciphers']
|
||||
tlssessioncaching merged['tlssessioncaching']
|
||||
tlssessioncachesize merged['tlssessioncachesize']
|
||||
tlssessioncachetimeout merged['tlssessioncachetimeout']
|
||||
package_install new_resource.package_install
|
||||
package_name new_resource.package_name
|
||||
install_dir new_resource.install_dir
|
||||
bin_path new_resource.bin_path
|
||||
name_override merged['name']
|
||||
sentinel_bind merged['sentinel_bind']
|
||||
sentinel_port merged.fetch('sentinel_port', 26_379)
|
||||
masters masters
|
||||
master_name merged['master_name']
|
||||
master_ip merged['master_ip']
|
||||
master_port merged['master_port']
|
||||
quorum_count merged.fetch('quorum_count', 2)
|
||||
auth_pass merged['auth_pass']
|
||||
down_after_milliseconds merged.fetch('down_after_milliseconds', 30_000)
|
||||
parallel_syncs merged.fetch('parallel_syncs', 1)
|
||||
failover_timeout merged.fetch('failover_timeout', 900_000)
|
||||
announce_ip merged['announce_ip']
|
||||
announce_port merged['announce_port']
|
||||
notification_script merged['notification_script']
|
||||
client_reconfig_script merged['client_reconfig_script']
|
||||
action new_resource.action
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
provides :redisio_sentinel_instance
|
||||
unified_mode true
|
||||
|
||||
use '_partial/_base'
|
||||
|
||||
property :instance_name, String, name_property: true
|
||||
property :name_override, String
|
||||
property :sentinel_bind, [String, Array, nil], default: nil
|
||||
property :sentinel_port, [String, Integer], default: 26_379
|
||||
property :masters, Array, default: []
|
||||
property :master_name, String
|
||||
property :master_ip, String
|
||||
property :master_port, [String, Integer, nil], default: nil
|
||||
property :quorum_count, [String, Integer], default: 2
|
||||
property :auth_pass, String
|
||||
property :down_after_milliseconds, [String, Integer], default: 30_000
|
||||
property :parallel_syncs, [String, Integer], default: 1
|
||||
property :failover_timeout, [String, Integer], default: 900_000
|
||||
property :announce_ip, String
|
||||
property :announce_port, [String, Integer, nil], default: nil
|
||||
property :notification_script, String
|
||||
property :client_reconfig_script, String
|
||||
|
||||
action_class do
|
||||
include RedisioCookbook::Helpers
|
||||
|
||||
def resolved_instance_name
|
||||
(new_resource.name_override || new_resource.instance_name).to_s
|
||||
end
|
||||
|
||||
def resolved_group
|
||||
new_resource.group || platform_default_group
|
||||
end
|
||||
|
||||
def resolved_homedir
|
||||
new_resource.homedir || platform_default_home
|
||||
end
|
||||
|
||||
def resolved_shell
|
||||
new_resource.shell || platform_default_shell
|
||||
end
|
||||
|
||||
def resolved_configdir
|
||||
new_resource.configdir || platform_default_config_dir
|
||||
end
|
||||
|
||||
def resolved_bin_path
|
||||
new_resource.bin_path || platform_default_bin_path(package_install: new_resource.package_install, install_dir: new_resource.install_dir)
|
||||
end
|
||||
|
||||
def resolved_package_name
|
||||
new_resource.package_name || platform_package_name
|
||||
end
|
||||
|
||||
def resolved_version_hash
|
||||
version = if new_resource.version
|
||||
new_resource.version
|
||||
elsif new_resource.package_install
|
||||
'7.0.0'
|
||||
else
|
||||
installed_redis_version(resolved_bin_path, package_install: new_resource.package_install, package_name: resolved_package_name)
|
||||
end
|
||||
|
||||
redis_version_to_hash(version || '0.0.0')
|
||||
end
|
||||
|
||||
def resolved_config_name
|
||||
sentinel_config_name(resolved_instance_name)
|
||||
end
|
||||
|
||||
def resolved_piddir
|
||||
::File.join(new_resource.base_piddir, resolved_config_name)
|
||||
end
|
||||
|
||||
def resolved_log_directory
|
||||
return if new_resource.logfile.nil?
|
||||
return if new_resource.logfile.empty? || new_resource.logfile == 'stdout'
|
||||
|
||||
::File.dirname(new_resource.logfile)
|
||||
end
|
||||
|
||||
def resolved_log_file
|
||||
return if new_resource.logfile.nil?
|
||||
return if new_resource.logfile.empty? || new_resource.logfile == 'stdout'
|
||||
|
||||
new_resource.logfile
|
||||
end
|
||||
|
||||
def base_master
|
||||
{
|
||||
'master_name' => new_resource.master_name,
|
||||
'master_ip' => new_resource.master_ip,
|
||||
'master_port' => new_resource.master_port,
|
||||
'quorum_count' => new_resource.quorum_count,
|
||||
'auth_pass' => new_resource.auth_pass,
|
||||
'down_after_milliseconds' => new_resource.down_after_milliseconds,
|
||||
'parallel_syncs' => new_resource.parallel_syncs,
|
||||
'failover_timeout' => new_resource.failover_timeout,
|
||||
}
|
||||
end
|
||||
|
||||
def resolved_masters
|
||||
masters = normalize_array(new_resource.masters).map { |master| deep_stringify_keys(normalize_hash(master)) }
|
||||
masters = [base_master] if masters.empty? && new_resource.master_ip
|
||||
raise 'At least one sentinel master must be defined' if masters.empty?
|
||||
|
||||
bag_secret = if new_resource.data_bag_name && new_resource.data_bag_item && new_resource.data_bag_key
|
||||
data_bag_item(new_resource.data_bag_name, new_resource.data_bag_item)[new_resource.data_bag_key]
|
||||
end
|
||||
|
||||
masters.map do |master|
|
||||
{
|
||||
'master_name' => master['master_name'] || master['name'],
|
||||
'master_ip' => master['master_ip'],
|
||||
'master_port' => master['master_port'],
|
||||
'quorum_count' => master['quorum_count'].nil? ? new_resource.quorum_count : master['quorum_count'],
|
||||
'auth_pass' => bag_secret || master['auth_pass'],
|
||||
'down_after_milliseconds' => master['down_after_milliseconds'].nil? ? new_resource.down_after_milliseconds : master['down_after_milliseconds'],
|
||||
'parallel_syncs' => master['parallel_syncs'].nil? ? new_resource.parallel_syncs : master['parallel_syncs'],
|
||||
'failover_timeout' => master['failover_timeout'].nil? ? new_resource.failover_timeout : master['failover_timeout'],
|
||||
}.tap do |resolved|
|
||||
%w(master_name master_ip master_port quorum_count).each do |key|
|
||||
raise "Missing required sentinel parameter #{key}" if resolved[key].nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def config_path
|
||||
::File.join(resolved_configdir, "#{resolved_config_name}.conf")
|
||||
end
|
||||
|
||||
def breadcrumb_path
|
||||
"#{config_path}.breadcrumb"
|
||||
end
|
||||
|
||||
def service_name
|
||||
sentinel_service_name(resolved_instance_name)
|
||||
end
|
||||
end
|
||||
|
||||
action :create do
|
||||
user new_resource.user do
|
||||
comment 'Redis service account'
|
||||
manage_home true
|
||||
home resolved_homedir
|
||||
shell resolved_shell
|
||||
system new_resource.systemuser
|
||||
uid new_resource.uid unless new_resource.uid.nil?
|
||||
end
|
||||
|
||||
directory resolved_configdir do
|
||||
owner 'root'
|
||||
group resolved_group
|
||||
mode '0775'
|
||||
recursive true
|
||||
end
|
||||
|
||||
directory resolved_piddir do
|
||||
owner new_resource.user
|
||||
group resolved_group
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
|
||||
unless resolved_log_directory.nil?
|
||||
directory resolved_log_directory do
|
||||
owner new_resource.user
|
||||
group resolved_group
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
end
|
||||
|
||||
unless resolved_log_file.nil?
|
||||
file resolved_log_file do
|
||||
owner new_resource.user
|
||||
group resolved_group
|
||||
mode '0644'
|
||||
backup false
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
template config_path do
|
||||
source 'sentinel.conf.erb'
|
||||
cookbook 'redisio'
|
||||
owner new_resource.user
|
||||
group resolved_group
|
||||
mode '0644'
|
||||
variables(
|
||||
name: resolved_instance_name,
|
||||
piddir: resolved_piddir,
|
||||
version: resolved_version_hash,
|
||||
job_control: 'systemd',
|
||||
sentinel_bind: new_resource.sentinel_bind,
|
||||
sentinel_port: new_resource.sentinel_port,
|
||||
loglevel: new_resource.loglevel,
|
||||
logfile: new_resource.logfile,
|
||||
syslogenabled: new_resource.syslogenabled,
|
||||
syslogfacility: new_resource.syslogfacility,
|
||||
masters: resolved_masters,
|
||||
announce_ip: new_resource.announce_ip,
|
||||
announce_port: new_resource.announce_port,
|
||||
notification_script: new_resource.notification_script,
|
||||
client_reconfig_script: new_resource.client_reconfig_script,
|
||||
protected_mode: new_resource.protected_mode,
|
||||
maxclients: new_resource.maxclients,
|
||||
aclfile: new_resource.aclfile,
|
||||
includes: new_resource.includes,
|
||||
tlsport: new_resource.tlsport,
|
||||
tlscertfile: new_resource.tlscertfile,
|
||||
tlskeyfile: new_resource.tlskeyfile,
|
||||
tlskeyfilepass: new_resource.tlskeyfilepass,
|
||||
tlsclientcertfile: new_resource.tlsclientcertfile,
|
||||
tlsclientkeyfile: new_resource.tlsclientkeyfile,
|
||||
tlsclientkeyfilepass: new_resource.tlsclientkeyfilepass,
|
||||
tlsdhparamsfile: new_resource.tlsdhparamsfile,
|
||||
tlscacertfile: new_resource.tlscacertfile,
|
||||
tlscacertdir: new_resource.tlscacertdir,
|
||||
tlsauthclients: new_resource.tlsauthclients,
|
||||
tlsreplication: new_resource.tlsreplication,
|
||||
tlscluster: new_resource.tlscluster,
|
||||
tlsprotocols: new_resource.tlsprotocols,
|
||||
tlsciphers: new_resource.tlsciphers,
|
||||
tlsciphersuites: new_resource.tlsciphersuites,
|
||||
tlspreferserverciphers: new_resource.tlspreferserverciphers,
|
||||
tlssessioncaching: new_resource.tlssessioncaching,
|
||||
tlssessioncachesize: new_resource.tlssessioncachesize,
|
||||
tlssessioncachetimeout: new_resource.tlssessioncachetimeout
|
||||
)
|
||||
not_if { ::File.exist?(breadcrumb_path) }
|
||||
notifies :restart, "service[#{service_name}]", :delayed
|
||||
end
|
||||
|
||||
file breadcrumb_path do
|
||||
content 'This file prevents the Chef cookbook from overwriting the sentinel config more than once'
|
||||
action :create_if_missing
|
||||
end
|
||||
|
||||
systemd_unit "#{service_name}.service" do
|
||||
content(
|
||||
Unit: {
|
||||
Description: "Redis Sentinel (#{resolved_instance_name})",
|
||||
After: 'network.target',
|
||||
},
|
||||
Service: {
|
||||
Type: 'notify',
|
||||
ExecStart: "#{redis_server_binary(resolved_bin_path, package_install: new_resource.package_install, package_name: resolved_package_name)} #{config_path} --sentinel --daemonize no",
|
||||
User: new_resource.user,
|
||||
Group: resolved_group,
|
||||
LimitNOFILE: new_resource.maxclients + 32,
|
||||
},
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target',
|
||||
}
|
||||
)
|
||||
action %i(create enable)
|
||||
end
|
||||
|
||||
service service_name do
|
||||
action %i(enable start)
|
||||
supports status: true, restart: true
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
service service_name do
|
||||
action %i(stop disable)
|
||||
supports status: true, restart: true
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
systemd_unit "#{service_name}.service" do
|
||||
action %i(disable delete)
|
||||
end
|
||||
|
||||
file breadcrumb_path do
|
||||
action :delete
|
||||
end
|
||||
|
||||
file config_path do
|
||||
action :delete
|
||||
end
|
||||
|
||||
unless resolved_log_file.nil?
|
||||
file resolved_log_file do
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
|
||||
directory resolved_piddir do
|
||||
recursive true
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,403 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
provides :redisio_server
|
||||
unified_mode true
|
||||
|
||||
use '_partial/_base'
|
||||
use '_partial/_server'
|
||||
|
||||
property :instance_name, String, name_property: true
|
||||
|
||||
action_class do
|
||||
include RedisioCookbook::Helpers
|
||||
include Chef::Util::Selinux
|
||||
|
||||
def resolved_instance_name
|
||||
(new_resource.name_override || new_resource.instance_name).to_s
|
||||
end
|
||||
|
||||
def resolved_user
|
||||
new_resource.user
|
||||
end
|
||||
|
||||
def resolved_group
|
||||
new_resource.group || platform_default_group
|
||||
end
|
||||
|
||||
def resolved_homedir
|
||||
new_resource.homedir || platform_default_home
|
||||
end
|
||||
|
||||
def resolved_shell
|
||||
new_resource.shell || platform_default_shell
|
||||
end
|
||||
|
||||
def resolved_configdir
|
||||
new_resource.configdir || platform_default_config_dir
|
||||
end
|
||||
|
||||
def resolved_bin_path
|
||||
new_resource.bin_path || platform_default_bin_path(package_install: new_resource.package_install, install_dir: new_resource.install_dir)
|
||||
end
|
||||
|
||||
def resolved_package_name
|
||||
new_resource.package_name || platform_package_name
|
||||
end
|
||||
|
||||
def resolved_version
|
||||
return new_resource.version if new_resource.version
|
||||
return '7.0.0' if new_resource.package_install
|
||||
|
||||
installed_redis_version(resolved_bin_path, package_install: new_resource.package_install, package_name: resolved_package_name)
|
||||
end
|
||||
|
||||
def resolved_version_hash
|
||||
redis_version_to_hash(resolved_version || '0.0.0')
|
||||
end
|
||||
|
||||
def resolved_piddir
|
||||
::File.join(new_resource.base_piddir, resolved_instance_name)
|
||||
end
|
||||
|
||||
def resolved_log_directory
|
||||
return if new_resource.logfile.nil?
|
||||
return if new_resource.logfile.empty? || new_resource.logfile == 'stdout'
|
||||
|
||||
::File.dirname(new_resource.logfile)
|
||||
end
|
||||
|
||||
def resolved_log_file
|
||||
return if new_resource.logfile.nil?
|
||||
return if new_resource.logfile.empty? || new_resource.logfile == 'stdout'
|
||||
|
||||
new_resource.logfile
|
||||
end
|
||||
|
||||
def resolved_descriptors
|
||||
if new_resource.ulimit.zero?
|
||||
new_resource.maxclients + 32
|
||||
else
|
||||
[new_resource.ulimit, new_resource.maxclients].max
|
||||
end
|
||||
end
|
||||
|
||||
def resolved_maxmemory(server_count = 1)
|
||||
maxmemory = new_resource.maxmemory.to_s
|
||||
return new_resource.maxmemory if maxmemory.empty? || !maxmemory.include?('%')
|
||||
|
||||
node_memory_kb = node['memory']['total']
|
||||
node_memory_kb = node_memory_kb.delete_suffix('kB').to_i if node_memory_kb.is_a?(String)
|
||||
((node_memory_kb * 1024 * (new_resource.maxmemory.to_f / 100.0)) / server_count).round.to_s
|
||||
end
|
||||
|
||||
def resolved_save
|
||||
return new_resource.save.each_line.to_a if new_resource.save.respond_to?(:each_line) && !new_resource.save.is_a?(Array)
|
||||
|
||||
new_resource.save
|
||||
end
|
||||
|
||||
def resolved_data_bag_secret
|
||||
return {} unless new_resource.data_bag_name && new_resource.data_bag_item && new_resource.data_bag_key
|
||||
|
||||
bag = data_bag_item(new_resource.data_bag_name, new_resource.data_bag_item)
|
||||
{
|
||||
requirepass: bag[new_resource.data_bag_key],
|
||||
masterauth: bag[new_resource.data_bag_key],
|
||||
}
|
||||
end
|
||||
|
||||
def resolved_append_file
|
||||
::File.join(new_resource.datadir, new_resource.appendfilename || "appendonly-#{resolved_instance_name}.aof")
|
||||
end
|
||||
|
||||
def resolved_rdb_file
|
||||
::File.join(new_resource.datadir, new_resource.dbfilename || "dump-#{resolved_instance_name}.rdb")
|
||||
end
|
||||
|
||||
def limits_file
|
||||
"/etc/security/limits.d/redis-#{resolved_instance_name}.conf"
|
||||
end
|
||||
|
||||
def config_path
|
||||
::File.join(resolved_configdir, "#{resolved_instance_name}.conf")
|
||||
end
|
||||
|
||||
def breadcrumb_path
|
||||
"#{config_path}.breadcrumb"
|
||||
end
|
||||
|
||||
def service_name
|
||||
redis_service_name(resolved_instance_name)
|
||||
end
|
||||
end
|
||||
|
||||
action :create do
|
||||
secrets = resolved_data_bag_secret
|
||||
|
||||
user resolved_user do
|
||||
comment 'Redis service account'
|
||||
manage_home true
|
||||
home resolved_homedir
|
||||
shell resolved_shell
|
||||
system new_resource.systemuser
|
||||
uid new_resource.uid unless new_resource.uid.nil?
|
||||
end
|
||||
|
||||
directory resolved_configdir do
|
||||
owner 'root'
|
||||
group resolved_group
|
||||
mode '0775'
|
||||
recursive true
|
||||
end
|
||||
|
||||
directory new_resource.datadir do
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode '0775'
|
||||
recursive true
|
||||
end
|
||||
|
||||
directory resolved_piddir do
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
|
||||
unless resolved_log_directory.nil?
|
||||
directory resolved_log_directory do
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
end
|
||||
|
||||
if selinux_enabled?
|
||||
selinux_install 'install'
|
||||
|
||||
selinux_fcontext "#{resolved_configdir}(/.*)?" do
|
||||
secontext 'redis_conf_t'
|
||||
end
|
||||
|
||||
selinux_fcontext "#{new_resource.datadir}(/.*)?" do
|
||||
secontext 'redis_var_lib_t'
|
||||
end
|
||||
|
||||
selinux_fcontext "#{resolved_piddir}(/.*)?" do
|
||||
secontext 'redis_var_run_t'
|
||||
end
|
||||
|
||||
unless resolved_log_directory.nil?
|
||||
selinux_fcontext "#{resolved_log_directory}(/.*)?" do
|
||||
secontext 'redis_log_t'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless resolved_log_file.nil?
|
||||
file resolved_log_file do
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode '0644'
|
||||
backup false
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
file resolved_append_file do
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode '0644'
|
||||
only_if { %w(aof both).include?(new_resource.backuptype) && ::File.exist?(resolved_append_file) }
|
||||
end
|
||||
|
||||
file resolved_rdb_file do
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode '0644'
|
||||
only_if { %w(rdb both).include?(new_resource.backuptype) && ::File.exist?(resolved_rdb_file) }
|
||||
end
|
||||
|
||||
file limits_file do
|
||||
content <<~LIMITS
|
||||
#{resolved_user} soft nofile #{resolved_descriptors}
|
||||
#{resolved_user} hard nofile #{resolved_descriptors}
|
||||
LIMITS
|
||||
mode '0644'
|
||||
end
|
||||
|
||||
template config_path do
|
||||
cookbook new_resource.template_cookbook
|
||||
source new_resource.template_source
|
||||
owner resolved_user
|
||||
group resolved_group
|
||||
mode new_resource.permissions
|
||||
variables(
|
||||
version: resolved_version_hash,
|
||||
piddir: resolved_piddir,
|
||||
name: resolved_instance_name,
|
||||
job_control: 'systemd',
|
||||
port: new_resource.port,
|
||||
tcpbacklog: new_resource.tcpbacklog,
|
||||
address: new_resource.address,
|
||||
databases: new_resource.databases,
|
||||
backuptype: new_resource.backuptype,
|
||||
datadir: new_resource.datadir,
|
||||
unixsocket: new_resource.unixsocket,
|
||||
unixsocketperm: new_resource.unixsocketperm,
|
||||
timeout: new_resource.timeout,
|
||||
keepalive: new_resource.keepalive,
|
||||
loglevel: new_resource.loglevel,
|
||||
logfile: new_resource.logfile,
|
||||
syslogenabled: new_resource.syslogenabled,
|
||||
syslogfacility: new_resource.syslogfacility,
|
||||
save: resolved_save,
|
||||
stopwritesonbgsaveerror: new_resource.stopwritesonbgsaveerror,
|
||||
rdbcompression: new_resource.rdbcompression,
|
||||
rdbchecksum: new_resource.rdbchecksum,
|
||||
dbfilename: new_resource.dbfilename,
|
||||
replicaof: new_resource.replicaof,
|
||||
protected_mode: new_resource.protected_mode,
|
||||
masterauth: secrets.fetch(:masterauth, new_resource.masterauth),
|
||||
replicaservestaledata: new_resource.replicaservestaledata,
|
||||
replicareadonly: new_resource.replicareadonly,
|
||||
repldisklesssync: new_resource.repldisklesssync,
|
||||
repldisklesssyncdelay: new_resource.repldisklesssyncdelay,
|
||||
replpingreplicaperiod: new_resource.replpingreplicaperiod,
|
||||
repltimeout: new_resource.repltimeout,
|
||||
repldisabletcpnodelay: new_resource.repldisabletcpnodelay,
|
||||
replbacklogsize: new_resource.replbacklogsize,
|
||||
replbacklogttl: new_resource.replbacklogttl,
|
||||
replicapriority: new_resource.replicapriority,
|
||||
requirepass: secrets.fetch(:requirepass, new_resource.requirepass),
|
||||
rename_commands: new_resource.rename_commands,
|
||||
maxclients: new_resource.maxclients,
|
||||
maxmemory: resolved_maxmemory,
|
||||
maxmemorypolicy: new_resource.maxmemorypolicy,
|
||||
maxmemorysamples: new_resource.maxmemorysamples,
|
||||
appendfilename: new_resource.appendfilename,
|
||||
appendfsync: new_resource.appendfsync,
|
||||
noappendfsynconrewrite: new_resource.noappendfsynconrewrite,
|
||||
aofrewritepercentage: new_resource.aofrewritepercentage,
|
||||
aofrewriteminsize: new_resource.aofrewriteminsize,
|
||||
aofloadtruncated: new_resource.aofloadtruncated,
|
||||
luatimelimit: new_resource.luatimelimit,
|
||||
slowloglogslowerthan: new_resource.slowloglogslowerthan,
|
||||
slowlogmaxlen: new_resource.slowlogmaxlen,
|
||||
notifykeyspaceevents: new_resource.notifykeyspaceevents,
|
||||
hashmaxziplistentries: new_resource.hashmaxziplistentries,
|
||||
hashmaxziplistvalue: new_resource.hashmaxziplistvalue,
|
||||
setmaxintsetentries: new_resource.setmaxintsetentries,
|
||||
zsetmaxziplistentries: new_resource.zsetmaxziplistentries,
|
||||
zsetmaxziplistvalue: new_resource.zsetmaxziplistvalue,
|
||||
hllsparsemaxbytes: new_resource.hllsparsemaxbytes,
|
||||
activerehasing: new_resource.activerehasing,
|
||||
clientoutputbufferlimit: new_resource.clientoutputbufferlimit,
|
||||
hz: new_resource.hz,
|
||||
aofrewriteincrementalfsync: new_resource.aofrewriteincrementalfsync,
|
||||
clusterenabled: new_resource.clusterenabled,
|
||||
clusterconfigfile: new_resource.clusterconfigfile,
|
||||
clusternodetimeout: new_resource.clusternodetimeout,
|
||||
clusterport: new_resource.clusterport,
|
||||
includes: new_resource.includes,
|
||||
aclfile: new_resource.aclfile,
|
||||
minreplicastowrite: new_resource.minreplicastowrite,
|
||||
minreplicasmaxlag: new_resource.minreplicasmaxlag,
|
||||
tlsport: new_resource.tlsport,
|
||||
tlscertfile: new_resource.tlscertfile,
|
||||
tlskeyfile: new_resource.tlskeyfile,
|
||||
tlskeyfilepass: new_resource.tlskeyfilepass,
|
||||
tlsclientcertfile: new_resource.tlsclientcertfile,
|
||||
tlsclientkeyfile: new_resource.tlsclientkeyfile,
|
||||
tlsclientkeyfilepass: new_resource.tlsclientkeyfilepass,
|
||||
tlsdhparamsfile: new_resource.tlsdhparamsfile,
|
||||
tlscacertfile: new_resource.tlscacertfile,
|
||||
tlscacertdir: new_resource.tlscacertdir,
|
||||
tlsauthclients: new_resource.tlsauthclients,
|
||||
tlsreplication: new_resource.tlsreplication,
|
||||
tlscluster: new_resource.tlscluster,
|
||||
tlsprotocols: new_resource.tlsprotocols,
|
||||
tlsciphers: new_resource.tlsciphers,
|
||||
tlsciphersuites: new_resource.tlsciphersuites,
|
||||
tlspreferserverciphers: new_resource.tlspreferserverciphers,
|
||||
tlssessioncaching: new_resource.tlssessioncaching,
|
||||
tlssessioncachesize: new_resource.tlssessioncachesize,
|
||||
tlssessioncachetimeout: new_resource.tlssessioncachetimeout
|
||||
)
|
||||
not_if { new_resource.breadcrumb && ::File.exist?(breadcrumb_path) }
|
||||
notifies :restart, "service[#{service_name}]", :delayed
|
||||
end
|
||||
|
||||
file breadcrumb_path do
|
||||
content 'This file prevents the Chef cookbook from overwriting the redis config more than once'
|
||||
action :create_if_missing
|
||||
only_if { new_resource.breadcrumb }
|
||||
end
|
||||
|
||||
systemd_unit "#{service_name}.service" do
|
||||
content(
|
||||
Unit: {
|
||||
Description: "Redis (#{resolved_instance_name}) persistent key-value database",
|
||||
Wants: 'network-online.target',
|
||||
After: 'network-online.target',
|
||||
},
|
||||
Service: {
|
||||
Type: 'notify',
|
||||
ExecStart: "#{redis_server_binary(resolved_bin_path, package_install: new_resource.package_install, package_name: resolved_package_name)} #{config_path} --daemonize no",
|
||||
User: resolved_user,
|
||||
Group: resolved_group,
|
||||
LimitNOFILE: resolved_descriptors,
|
||||
},
|
||||
Install: {
|
||||
WantedBy: 'multi-user.target',
|
||||
}
|
||||
)
|
||||
action %i(create enable)
|
||||
end
|
||||
|
||||
service service_name do
|
||||
action %i(enable start)
|
||||
supports status: true, restart: true
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
service service_name do
|
||||
action %i(stop disable)
|
||||
supports status: true, restart: true
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
systemd_unit "#{service_name}.service" do
|
||||
action %i(disable delete)
|
||||
end
|
||||
|
||||
file breadcrumb_path do
|
||||
action :delete
|
||||
end
|
||||
|
||||
file config_path do
|
||||
action :delete
|
||||
end
|
||||
|
||||
file limits_file do
|
||||
action :delete
|
||||
end
|
||||
|
||||
unless resolved_log_file.nil?
|
||||
file resolved_log_file do
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
|
||||
directory resolved_piddir do
|
||||
recursive true
|
||||
action :delete
|
||||
end
|
||||
|
||||
directory new_resource.datadir do
|
||||
recursive true
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
<%
|
||||
node.run_state[:ulimit][@domain].each do |item, entries|
|
||||
entries.each do |type, value|
|
||||
-%>
|
||||
<%= @domain %> <%= type %> <%= item %> <%= value %>
|
||||
<%
|
||||
end
|
||||
end
|
||||
-%>
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Redis persistent key-value database
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=<%= @bin_path %>/redis-server /etc/redis/sentinel_%i.conf --sentinel --daemonize no
|
||||
User=redis
|
||||
Group=redis
|
||||
LimitNOFILE=<%= @limit_nofile %>
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -17,6 +17,9 @@
|
||||
<% if @job_control == 'initd' || @job_control == 'rcinit' %>
|
||||
daemonize yes
|
||||
<% end %>
|
||||
<% if @job_control == 'systemd' %>
|
||||
supervised systemd
|
||||
<% end %>
|
||||
|
||||
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
|
||||
# default. You can specify a custom pid file location here.
|
||||
@@ -26,7 +29,6 @@ pidfile <%= @piddir %>/redis_<%=@name%>.pid
|
||||
# If port 0 is specified Redis will not listen on a TCP socket.
|
||||
port <%=@port%>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 8 && @version[:patch].to_i >= 5 || @version[:major].to_i >= 3 %>
|
||||
# TCP listen() backlog.
|
||||
#
|
||||
# In high requests-per-second environments you need an high backlog in order
|
||||
@@ -35,7 +37,6 @@ port <%=@port%>
|
||||
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
|
||||
# in order to get the desired effect.
|
||||
tcp-backlog <%= @tcpbacklog %>
|
||||
<% end %>
|
||||
|
||||
# By default Redis listens for connections from all the network interfaces
|
||||
# available on the server. It is possible to listen to just one or multiple
|
||||
@@ -83,7 +84,6 @@ protected-mode <%= @protected_mode %>
|
||||
# Close the connection after a client is idle for N seconds (0 to disable)
|
||||
<%= "timeout #{@timeout}" %>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i >= 8) || @version[:major].to_i >= 3 %>
|
||||
# TCP keepalive.
|
||||
#
|
||||
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
|
||||
@@ -99,7 +99,6 @@ protected-mode <%= @protected_mode %>
|
||||
#
|
||||
# A reasonable value for this option is 60 seconds.
|
||||
tcp-keepalive <%=@keepalive%>
|
||||
<% end %>
|
||||
|
||||
# Set server verbosity to 'debug'
|
||||
# it can be one of:
|
||||
@@ -134,6 +133,142 @@ syslog-facility <%= @syslogfacility %>
|
||||
# dbid is a number between 0 and 'databases'-1
|
||||
databases <%=@databases%>
|
||||
|
||||
################################# TLS/SSL #####################################
|
||||
|
||||
# By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
|
||||
# directive can be used to define TLS-listening ports. To enable TLS on the
|
||||
# default port, use:
|
||||
#
|
||||
# port 0
|
||||
# tls-port 6379
|
||||
<%= "tls-port #{@tlsport}" unless @tlsport.nil? %>
|
||||
|
||||
# Configure a X.509 certificate and private key to use for authenticating the
|
||||
# server to connected clients, masters or cluster peers. These files should be
|
||||
# PEM formatted.
|
||||
#
|
||||
# tls-cert-file redis.crt
|
||||
# tls-key-file redis.key
|
||||
<%= "tls-cert-file #{@tlscertfile}" unless @tlscertfile.nil? %>
|
||||
<%= "tls-key-file #{@tlskeyfile}" unless @tlskeyfile.nil? %>
|
||||
#
|
||||
# If the key file is encrypted using a passphrase, it can be included here
|
||||
# as well.
|
||||
#
|
||||
# tls-key-file-pass secret
|
||||
<%= "tls-key-file-pass #{@tlskeyfilepass}" unless @tlskeyfilepass.nil? %>
|
||||
|
||||
# Normally Redis uses the same certificate for both server functions (accepting
|
||||
# connections) and client functions (replicating from a master, establishing
|
||||
# cluster bus connections, etc.).
|
||||
#
|
||||
# Sometimes certificates are issued with attributes that designate them as
|
||||
# client-only or server-only certificates. In that case it may be desired to use
|
||||
# different certificates for incoming (server) and outgoing (client)
|
||||
# connections. To do that, use the following directives:
|
||||
#
|
||||
# tls-client-cert-file client.crt
|
||||
# tls-client-key-file client.key
|
||||
<%= "tls-client-cert-file #{@tlsclientcertfile}" unless @tlsclientcertfile.nil? %>
|
||||
<%= "tls-client-key-file #{@tlsclientkeyfile}" unless @tlsclientkeyfile.nil? %>
|
||||
#
|
||||
# If the key file is encrypted using a passphrase, it can be included here
|
||||
# as well.
|
||||
#
|
||||
# tls-client-key-file-pass secret
|
||||
<%= "tls-client-key-file-pass #{@tlsclientkeyfilepass}" unless @tlsclientkeyfilepass.nil? %>
|
||||
|
||||
# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange,
|
||||
# required by older versions of OpenSSL (<3.0). Newer versions do not require
|
||||
# this configuration and recommend against it.
|
||||
#
|
||||
# tls-dh-params-file redis.dh
|
||||
<%= "tls-dh-params-file #{@tlsdhparamsfile}" unless @tlsdhparamsfile.nil? %>
|
||||
|
||||
# Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
|
||||
# clients and peers. Redis requires an explicit configuration of at least one
|
||||
# of these, and will not implicitly use the system wide configuration.
|
||||
#
|
||||
# tls-ca-cert-file ca.crt
|
||||
# tls-ca-cert-dir /etc/ssl/certs
|
||||
<%= "tls-ca-cert-file #{@tlscacertfile}" unless @tlscacertfile.nil? %>
|
||||
<%= "tls-ca-cert-dir #{@tlscacertdir}" unless @tlscacertdir.nil? %>
|
||||
|
||||
# By default, clients (including replica servers) on a TLS port are required
|
||||
# to authenticate using valid client side certificates.
|
||||
#
|
||||
# If "no" is specified, client certificates are not required and not accepted.
|
||||
# If "optional" is specified, client certificates are accepted and must be
|
||||
# valid if provided, but are not required.
|
||||
#
|
||||
# tls-auth-clients no
|
||||
# tls-auth-clients optional
|
||||
<%= "tls-auth-clients #{@tlsauthclients}" unless @tlsauthclients.nil? %>
|
||||
|
||||
# By default, a Redis replica does not attempt to establish a TLS connection
|
||||
# with its master.
|
||||
#
|
||||
# Use the following directive to enable TLS on replication links.
|
||||
#
|
||||
# tls-replication yes
|
||||
<%= "tls-replication #{@tlsreplication}" unless @tlsreplication.nil? %>
|
||||
|
||||
# By default, the Redis Cluster bus uses a plain TCP connection. To enable
|
||||
# TLS for the bus protocol, use the following directive:
|
||||
#
|
||||
# tls-cluster yes
|
||||
<%= "tls-cluster #{@tlscluster}" unless @tlscluster.nil? %>
|
||||
|
||||
# By default, only TLSv1.2 and TLSv1.3 are enabled and it is highly recommended
|
||||
# that older formally deprecated versions are kept disabled to reduce the attack surface.
|
||||
# You can explicitly specify TLS versions to support.
|
||||
# Allowed values are case insensitive and include "TLSv1", "TLSv1.1", "TLSv1.2",
|
||||
# "TLSv1.3" (OpenSSL >= 1.1.1) or any combination.
|
||||
# To enable only TLSv1.2 and TLSv1.3, use:
|
||||
#
|
||||
# tls-protocols "TLSv1.2 TLSv1.3"
|
||||
<%= "tls-protocols #{@tlsprotocols}" unless @tlsprotocols.nil? %>
|
||||
|
||||
# Configure allowed ciphers. See the ciphers(1ssl) manpage for more information
|
||||
# about the syntax of this string.
|
||||
#
|
||||
# Note: this configuration applies only to <= TLSv1.2.
|
||||
#
|
||||
# tls-ciphers DEFAULT:!MEDIUM
|
||||
<%= "tls-ciphers #{@tlsciphers}" unless @tlsciphers.nil? %>
|
||||
|
||||
# Configure allowed TLSv1.3 ciphersuites. See the ciphers(1ssl) manpage for more
|
||||
# information about the syntax of this string, and specifically for TLSv1.3
|
||||
# ciphersuites.
|
||||
#
|
||||
# tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256
|
||||
<%= "tls-ciphersuites #{@tlsciphersuites}" unless @tlsciphersuites.nil? %>
|
||||
|
||||
# When choosing a cipher, use the server's preference instead of the client
|
||||
# preference. By default, the server follows the client's preference.
|
||||
#
|
||||
# tls-prefer-server-ciphers yes
|
||||
<%= "tls-prefer-server-ciphers #{@tlspreferserverciphers}" unless @tlspreferserverciphers.nil? %>
|
||||
|
||||
# By default, TLS session caching is enabled to allow faster and less expensive
|
||||
# reconnections by clients that support it. Use the following directive to disable
|
||||
# caching.
|
||||
#
|
||||
# tls-session-caching no
|
||||
<%= "tls-session-caching #{@tlssessioncaching}" unless @tlssessioncaching.nil? %>
|
||||
|
||||
# Change the default number of TLS sessions cached. A zero value sets the cache
|
||||
# to unlimited size. The default size is 20480.
|
||||
#
|
||||
# tls-session-cache-size 5000
|
||||
<%= "tls-session-cache-size #{@tlssessioncachesize}" unless @tlssessioncachesize.nil? %>
|
||||
|
||||
# Change the default timeout of cached TLS sessions. The default timeout is 300
|
||||
# seconds.
|
||||
#
|
||||
# tls-session-cache-timeout 60
|
||||
<%= "tls-session-cache-timeout #{@tlssessioncachetimeout}" unless @tlssessioncachetimeout.nil? %>
|
||||
|
||||
################################ SNAPSHOTTING #################################
|
||||
#
|
||||
# Save the DB on disk:
|
||||
@@ -185,7 +320,6 @@ stop-writes-on-bgsave-error <%= @stopwritesonbgsaveerror %>
|
||||
# the dataset will likely be bigger if you have compressible values or keys.
|
||||
rdbcompression <%= @rdbcompression %>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i >= 3 %>
|
||||
# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
|
||||
# This makes the format more resistant to corruption but there is a performance
|
||||
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
|
||||
@@ -194,7 +328,6 @@ rdbcompression <%= @rdbcompression %>
|
||||
# RDB files created with checksum disabled have a checksum of zero that will
|
||||
# tell the loading code to skip the check.
|
||||
rdbchecksum <%= @rdbchecksum %>
|
||||
<% end %>
|
||||
|
||||
# The filename where to dump the DB
|
||||
<% if @dbfilename %>
|
||||
@@ -217,91 +350,92 @@ dir <%=@datadir%>
|
||||
|
||||
################################# REPLICATION #################################
|
||||
|
||||
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
||||
# Master-Replica replication. Use replicaof to make a Redis instance a copy of
|
||||
# another Redis server. A few things to understand ASAP about Redis replication.
|
||||
#
|
||||
# +------------------+ +---------------+
|
||||
# | Master | ---> | Replica |
|
||||
# | (receive writes) | | (exact copy) |
|
||||
# +------------------+ +---------------+
|
||||
#
|
||||
# 1) Redis replication is asynchronous, but you can configure a master to
|
||||
# stop accepting writes if it appears to be not connected with at least
|
||||
# a given number of slaves.
|
||||
# 2) Redis slaves are able to perform a partial resynchronization with the
|
||||
# a given number of replicas.
|
||||
# 2) Redis replicas are able to perform a partial resynchronization with the
|
||||
# master if the replication link is lost for a relatively small amount of
|
||||
# time. You may want to configure the replication backlog size (see the next
|
||||
# sections of this file) with a sensible value depending on your needs.
|
||||
# 3) Replication is automatic and does not need user intervention. After a
|
||||
# network partition slaves automatically try to reconnect to masters
|
||||
# network partition replicas automatically try to reconnect to masters
|
||||
# and resynchronize with them.
|
||||
#
|
||||
# slaveof <ip> <port>
|
||||
<%= "slaveof #{@slaveof['address']} #{@slaveof['port']}" unless @slaveof.nil? %>
|
||||
# replicaof <ip> <port>
|
||||
<%= "replicaof #{@replicaof['address']} #{@replicaof['port']}" unless @replicaof.nil? %>
|
||||
|
||||
# If the master is password protected (using the "requirepass" configuration
|
||||
# directive below) it is possible to tell the slave to authenticate before
|
||||
# directive below) it is possible to tell the replica to authenticate before
|
||||
# starting the replication synchronization process, otherwise the master will
|
||||
# refuse the slave request.
|
||||
# refuse the replica request.
|
||||
#
|
||||
# masterauth <master-password>
|
||||
<%= "masterauth #{@masterauth}" unless @masterauth.nil? %>
|
||||
|
||||
# When a slave lost the connection with the master, or when the replication
|
||||
# is still in progress, the slave can act in two different ways:
|
||||
# When a replica loses its connection with the master, or when the replication
|
||||
# is still in progress, the replica can act in two different ways:
|
||||
#
|
||||
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
|
||||
# 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will
|
||||
# still reply to client requests, possibly with out of date data, or the
|
||||
# data set may just be empty if this is the first synchronization.
|
||||
#
|
||||
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
|
||||
# an error "SYNC with master in progress" to all the kind of commands
|
||||
# but to INFO and SLAVEOF.
|
||||
# 2) If replica-serve-stale-data is set to 'no' the replica will reply with error
|
||||
# "MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'"
|
||||
# to all data access commands, excluding commands such as:
|
||||
# INFO, REPLICAOF, AUTH, SHUTDOWN, REPLCONF, ROLE, CONFIG, SUBSCRIBE,
|
||||
# UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, COMMAND, POST,
|
||||
# HOST and LATENCY.
|
||||
#
|
||||
slave-serve-stale-data <%=@slaveservestaledata%>
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i >= 3 -%>
|
||||
<% ######## Redis 2.6 and higher ######## -%>
|
||||
replica-serve-stale-data <%=@replicaservestaledata%>
|
||||
|
||||
# You can configure a slave instance to accept writes or not. Writing against
|
||||
# a slave instance may be useful to store some ephemeral data (because data
|
||||
# written on a slave will be easily deleted after resync with the master) but
|
||||
# You can configure a replica instance to accept writes or not. Writing against
|
||||
# a replica instance may be useful to store some ephemeral data (because data
|
||||
# written on a replica will be easily deleted after resync with the master) but
|
||||
# may also cause problems if clients are writing to it because of a
|
||||
# misconfiguration.
|
||||
#
|
||||
# Since Redis 2.6 by default slaves are read-only.
|
||||
# Since Redis 2.6 by default replicas are read-only.
|
||||
#
|
||||
# Note: read only slaves are not designed to be exposed to untrusted clients
|
||||
# Note: read only replicas are not designed to be exposed to untrusted clients
|
||||
# on the internet. It's just a protection layer against misuse of the instance.
|
||||
# Still a read only slave exports by default all the administrative commands
|
||||
# Still a read only replica exports by default all the administrative commands
|
||||
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
|
||||
# security of read only slaves using 'rename-command' to shadow all the
|
||||
# security of read only replicas using 'rename-command' to shadow all the
|
||||
# administrative / dangerous commands.
|
||||
slave-read-only <%=@slavereadonly%>
|
||||
<% end %>
|
||||
replica-read-only <%=@replicareadonly%>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i == 8 && @version[:tiny].to_i >= 18) or (@version[:major].to_i == 2 && @version[:minor].to_i >= 9) or @version[:major].to_i >= 3 -%>
|
||||
<% ######## Redis 2.8.18 and higher ######## -%>
|
||||
# Replication SYNC strategy: disk or socket.
|
||||
#
|
||||
# -------------------------------------------------------
|
||||
# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY
|
||||
# -------------------------------------------------------
|
||||
# New replicas and reconnecting replicas that are not able to continue the
|
||||
# replication process just receiving differences, need to do what is called a
|
||||
# "full synchronization". An RDB file is transmitted from the master to the
|
||||
# replicas.
|
||||
#
|
||||
# New slaves and reconnecting slaves that are not able to continue the replication
|
||||
# process just receiving differences, need to do what is called a "full
|
||||
# synchronization". An RDB file is transmitted from the master to the slaves.
|
||||
# The transmission can happen in two different ways:
|
||||
#
|
||||
# 1) Disk-backed: The Redis master creates a new process that writes the RDB
|
||||
# file on disk. Later the file is transferred by the parent
|
||||
# process to the slaves incrementally.
|
||||
# process to the replicas incrementally.
|
||||
# 2) Diskless: The Redis master creates a new process that directly writes the
|
||||
# RDB file to slave sockets, without touching the disk at all.
|
||||
# RDB file to replica sockets, without touching the disk at all.
|
||||
#
|
||||
# With disk-backed replication, while the RDB file is generated, more slaves
|
||||
# can be queued and served with the RDB file as soon as the current child producing
|
||||
# the RDB file finishes its work. With diskless replication instead once
|
||||
# the transfer starts, new slaves arriving will be queued and a new transfer
|
||||
# will start when the current one terminates.
|
||||
# With disk-backed replication, while the RDB file is generated, more replicas
|
||||
# can be queued and served with the RDB file as soon as the current child
|
||||
# producing the RDB file finishes its work. With diskless replication instead
|
||||
# once the transfer starts, new replicas arriving will be queued and a new
|
||||
# transfer will start when the current one terminates.
|
||||
#
|
||||
# When diskless replication is used, the master waits a configurable amount of
|
||||
# time (in seconds) before starting the transfer in the hope that multiple slaves
|
||||
# will arrive and the transfer can be parallelized.
|
||||
# time (in seconds) before starting the transfer in the hope that multiple
|
||||
# replicas will arrive and the transfer can be parallelized.
|
||||
#
|
||||
# With slow disks and fast (large bandwidth) networks, diskless replication
|
||||
# works better.
|
||||
@@ -309,164 +443,143 @@ repl-diskless-sync <%=@repldisklesssync%>
|
||||
|
||||
# When diskless replication is enabled, it is possible to configure the delay
|
||||
# the server waits in order to spawn the child that transfers the RDB via socket
|
||||
# to the slaves.
|
||||
# to the replicas.
|
||||
#
|
||||
# This is important since once the transfer starts, it is not possible to serve
|
||||
# new slaves arriving, that will be queued for the next RDB transfer, so the server
|
||||
# waits a delay in order to let more slaves arrive.
|
||||
# new replicas arriving, that will be queued for the next RDB transfer, so the
|
||||
# server waits a delay in order to let more replicas arrive.
|
||||
#
|
||||
# The delay is specified in seconds, and by default is 5 seconds. To disable
|
||||
# it entirely just set it to 0 seconds and the transfer will start ASAP.
|
||||
repl-diskless-sync-delay <%=@repldisklesssyncdelay%>
|
||||
<% end %>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i >= 3 %>
|
||||
# You can configure a slave instance to accept writes or not. Writing against
|
||||
# a slave instance may be useful to store some ephemeral data (because data
|
||||
# written on a slave will be easily deleted after resync with the master) but
|
||||
# may also cause problems if clients are writing to it because of a
|
||||
# misconfiguration.
|
||||
# Master send PINGs to its replicas in a predefined interval. It's possible to
|
||||
# change this interval with the repl_ping_replica_period option. The default
|
||||
# value is 10 seconds.
|
||||
#
|
||||
# Since Redis 2.6 by default slaves are read-only.
|
||||
#
|
||||
# Note: read only slaves are not designed to be exposed to untrusted clients
|
||||
# on the internet. It's just a protection layer against misuse of the instance.
|
||||
# Still a read only slave exports by default all the administrative commands
|
||||
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
|
||||
# security of read only slaves using 'rename-command' to shadow all the
|
||||
# administrative / dangerous commands.
|
||||
slave-read-only <%= @slavereadonly %>
|
||||
<% end %>
|
||||
repl-ping-replica-period <%=@replpingreplicaperiod%>
|
||||
|
||||
# Slaves send PINGs to server in a predefined interval. It's possible to change
|
||||
# this interval with the repl_ping_slave_period option. The default value is 10
|
||||
# seconds.
|
||||
# The following option sets the replication timeout for:
|
||||
#
|
||||
repl-ping-slave-period <%=@replpingslaveperiod%>
|
||||
|
||||
# The following option sets a timeout for both Bulk transfer I/O timeout and
|
||||
# master data or ping response timeout. The default value is 60 seconds.
|
||||
# 1) Bulk transfer I/O during SYNC, from the point of view of replica.
|
||||
# 2) Master timeout from the point of view of replicas (data, pings).
|
||||
# 3) Replica timeout from the point of view of masters (REPLCONF ACK pings).
|
||||
#
|
||||
# It is important to make sure that this value is greater than the value
|
||||
# specified for repl-ping-slave-period otherwise a timeout will be detected
|
||||
# every time there is low traffic between the master and the slave.
|
||||
# specified for repl-ping-replica-period otherwise a timeout will be detected
|
||||
# every time there is low traffic between the master and the replica. The default
|
||||
# value is 60 seconds.
|
||||
#
|
||||
repl-timeout <%=@repltimeout%>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i >= 3 %>
|
||||
# Disable TCP_NODELAY on the slave socket after SYNC?
|
||||
# Disable TCP_NODELAY on the replica socket after SYNC?
|
||||
#
|
||||
# If you select "yes" Redis will use a smaller number of TCP packets and
|
||||
# less bandwidth to send data to slaves. But this can add a delay for
|
||||
# the data to appear on the slave side, up to 40 milliseconds with
|
||||
# less bandwidth to send data to replicas. But this can add a delay for
|
||||
# the data to appear on the replica side, up to 40 milliseconds with
|
||||
# Linux kernels using a default configuration.
|
||||
#
|
||||
# If you select "no" the delay for data to appear on the slave side will
|
||||
# If you select "no" the delay for data to appear on the replica side will
|
||||
# be reduced but more bandwidth will be used for replication.
|
||||
#
|
||||
# By default we optimize for low latency, but in very high traffic conditions
|
||||
# or when the master and slaves are many hops away, turning this to "yes" may
|
||||
# or when the master and replicas are many hops away, turning this to "yes" may
|
||||
# be a good idea.
|
||||
repl-disable-tcp-nodelay <%= @repldisabletcpnodelay %>
|
||||
<% end %>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i >= 8) || @version[:major].to_i >= 3 %>
|
||||
# Set the replication backlog size. The backlog is a buffer that accumulates
|
||||
# slave data when slaves are disconnected for some time, so that when a slave
|
||||
# wants to reconnect again, often a full resync is not needed, but a partial
|
||||
# resync is enough, just passing the portion of data the slave missed while
|
||||
# disconnected.
|
||||
# replica data when replicas are disconnected for some time, so that when a
|
||||
# replica wants to reconnect again, often a full resync is not needed, but a
|
||||
# partial resync is enough, just passing the portion of data the replica
|
||||
# missed while disconnected.
|
||||
#
|
||||
# The bigger the replication backlog, the longer the time the slave can be
|
||||
# disconnected and later be able to perform a partial resynchronization.
|
||||
# The bigger the replication backlog, the longer the replica can endure the
|
||||
# disconnect and later be able to perform a partial resynchronization.
|
||||
#
|
||||
# The backlog is only allocated once there is at least a slave connected.
|
||||
# The backlog is only allocated if there is at least one replica connected.
|
||||
#
|
||||
repl-backlog-size <%= @replbacklogsize %>
|
||||
|
||||
# After a master has no longer connected slaves for some time, the backlog
|
||||
# will be freed. The following option configures the amount of seconds that
|
||||
# need to elapse, starting from the time the last slave disconnected, for
|
||||
# the backlog buffer to be freed.
|
||||
# After a master has no connected replicas for some time, the backlog will be
|
||||
# freed. The following option configures the amount of seconds that need to
|
||||
# elapse, starting from the time the last replica disconnected, for the backlog
|
||||
# buffer to be freed.
|
||||
#
|
||||
# Note that replicas never free the backlog for timeout, since they may be
|
||||
# promoted to masters later, and should be able to correctly "partially
|
||||
# resynchronize" with other replicas: hence they should always accumulate backlog.
|
||||
#
|
||||
# A value of 0 means to never release the backlog.
|
||||
#
|
||||
repl-backlog-ttl <%= @replbacklogttl %>
|
||||
<% end %>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i >= 6) || @version[:major].to_i >= 3 %>
|
||||
# The slave priority is an integer number published by Redis in the INFO output.
|
||||
# It is used by Redis Sentinel in order to select a slave to promote into a
|
||||
# master if the master is no longer working correctly.
|
||||
# The replica priority is an integer number published by Redis in the INFO
|
||||
# output. It is used by Redis Sentinel in order to select a replica to promote
|
||||
# into a master if the master is no longer working correctly.
|
||||
#
|
||||
# A slave with a low priority number is considered better for promotion, so
|
||||
# for instance if there are three slaves with priority 10, 100, 25 Sentinel will
|
||||
# pick the one with priority 10, that is the lowest.
|
||||
# A replica with a low priority number is considered better for promotion, so
|
||||
# for instance if there are three replicas with priority 10, 100, 25 Sentinel
|
||||
# will pick the one with priority 10, that is the lowest.
|
||||
#
|
||||
# However a special priority of 0 marks the slave as not able to perform the
|
||||
# role of master, so a slave with priority of 0 will never be selected by
|
||||
# However a special priority of 0 marks the replica as not able to perform the
|
||||
# role of master, so a replica with priority of 0 will never be selected by
|
||||
# Redis Sentinel for promotion.
|
||||
#
|
||||
# By default the priority is 100.
|
||||
slave-priority <%= @slavepriority %>
|
||||
<% end %>
|
||||
replica-priority <%= @replicapriority %>
|
||||
|
||||
<% if @version[:major].to_i >= 3 %>
|
||||
# It is possible for a master to stop accepting writes if there are less than
|
||||
# N slaves connected, having a lag less or equal than M seconds.
|
||||
# N replicas connected, having a lag less or equal than M seconds.
|
||||
#
|
||||
# The N slaves need to be in "online" state.
|
||||
# The N replicas need to be in "online" state.
|
||||
#
|
||||
# The lag in seconds, that must be <= the specified value, is calculated from
|
||||
# the last ping received from the slave, that is usually sent every second.
|
||||
# the last ping received from the replica, that is usually sent every second.
|
||||
#
|
||||
# This option does not GUARANTEE that N replicas will accept the write, but
|
||||
# will limit the window of exposure for lost writes in case not enough slaves
|
||||
# will limit the window of exposure for lost writes in case not enough replicas
|
||||
# are available, to the specified number of seconds.
|
||||
#
|
||||
# For example to require at least 3 slaves with a lag <= 10 seconds use:
|
||||
# For example to require at least 3 replicas with a lag <= 10 seconds use:
|
||||
#
|
||||
# min-slaves-to-write 3
|
||||
# min-slaves-max-lag 10
|
||||
# min-replicas-to-write 3
|
||||
# min-replicas-max-lag 10
|
||||
#
|
||||
# Setting one or the other to 0 disables the feature.
|
||||
#
|
||||
# By default min-slaves-to-write is set to 0 (feature disabled) and
|
||||
# min-slaves-max-lag is set to 10.
|
||||
<%= "min-slaves-to-write #{@minslavestowrite}" unless @minslavestowrite.nil? %>
|
||||
<%= "min-slaves-max-lag #{@minslavesmaxlag}" unless @minslavesmaxlag.nil? %>
|
||||
<% end %>
|
||||
# By default min-replicas-to-write is set to 0 (feature disabled) and
|
||||
# min-replicas-max-lag is set to 10.
|
||||
<%= "min-replicas-to-write #{@minreplicastowrite}" unless @minreplicastowrite.nil? %>
|
||||
<%= "min-replicas-max-lag #{@minreplicasmaxlag}" unless @minreplicasmaxlag.nil? %>
|
||||
|
||||
<% if @version[:major].to_i >= 4 %>
|
||||
# A Redis master is able to list the address and port of the attached
|
||||
# slaves in different ways. For example the "INFO replication" section
|
||||
# replicas in different ways. For example the "INFO replication" section
|
||||
# offers this information, which is used, among other tools, by
|
||||
# Redis Sentinel in order to discover slave instances.
|
||||
# Redis Sentinel in order to discover replica instances.
|
||||
# Another place where this info is available is in the output of the
|
||||
# "ROLE" command of a masteer.
|
||||
# "ROLE" command of a master.
|
||||
#
|
||||
# The listed IP and address normally reported by a slave is obtained
|
||||
# in the following way:
|
||||
# The listed IP address and port normally reported by a replica is
|
||||
# obtained in the following way:
|
||||
#
|
||||
# IP: The address is auto detected by checking the peer address
|
||||
# of the socket used by the slave to connect with the master.
|
||||
# of the socket used by the replica to connect with the master.
|
||||
#
|
||||
# Port: The port is communicated by the slave during the replication
|
||||
# handshake, and is normally the port that the slave is using to
|
||||
# list for connections.
|
||||
# Port: The port is communicated by the replica during the replication
|
||||
# handshake, and is normally the port that the replica is using to
|
||||
# listen for connections.
|
||||
#
|
||||
# However when port forwarding or Network Address Translation (NAT) is
|
||||
# used, the slave may be actually reachable via different IP and port
|
||||
# pairs. The following two options can be used by a slave in order to
|
||||
# used, the replica may actually be reachable via different IP and port
|
||||
# pairs. The following two options can be used by a replica in order to
|
||||
# report to its master a specific set of IP and port, so that both INFO
|
||||
# and ROLE will report those values.
|
||||
#
|
||||
# There is no need to use both the options if you need to override just
|
||||
# the port or the IP address.
|
||||
#
|
||||
# slave-announce-ip 5.5.5.5
|
||||
# slave-announce-port 1234
|
||||
<% end %>
|
||||
# replica-announce-ip 5.5.5.5
|
||||
# replica-announce-port 1234
|
||||
|
||||
################################## SECURITY ###################################
|
||||
|
||||
@@ -528,19 +641,19 @@ slave-priority <%= @slavepriority %>
|
||||
# This option is usually useful when using Redis as an LRU cache, or to set
|
||||
# a hard memory limit for an instance (using the 'noeviction' policy).
|
||||
#
|
||||
# WARNING: If you have slaves attached to an instance with maxmemory on,
|
||||
# the size of the output buffers needed to feed the slaves are subtracted
|
||||
# WARNING: If you have replicas attached to an instance with maxmemory on,
|
||||
# the size of the output buffers needed to feed the replicas are subtracted
|
||||
# from the used memory count, so that network problems / resyncs will
|
||||
# not trigger a loop where keys are evicted, and in turn the output
|
||||
# buffer of slaves is full with DELs of keys evicted triggering the deletion
|
||||
# buffer of replicas is full with DELs of keys evicted triggering the deletion
|
||||
# of more keys, and so forth until the database is completely emptied.
|
||||
#
|
||||
# In short... if you have slaves attached it is suggested that you set a lower
|
||||
# limit for maxmemory so that there is some free RAM on the system for slave
|
||||
# In short... if you have replicas attached it is suggested that you set a lower
|
||||
# limit for maxmemory so that there is some free RAM on the system for replica
|
||||
# output buffers (but this is not needed if the policy is 'noeviction').
|
||||
#
|
||||
#maxmemory <bytes>
|
||||
<%= "maxmemory #{@maxmemory}" unless @maxmemory.empty? %>
|
||||
<%= "maxmemory #{@maxmemory}" unless @maxmemory.to_s.empty? %>
|
||||
|
||||
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
|
||||
# is reached. You can select among five behaviors:
|
||||
@@ -676,7 +789,6 @@ no-appendfsync-on-rewrite <%=@noappendfsynconrewrite%>
|
||||
auto-aof-rewrite-percentage <%=@aofrewritepercentage%>
|
||||
auto-aof-rewrite-min-size <%=@aofrewriteminsize%>
|
||||
|
||||
<% if @version[:major].to_i >= 3 %>
|
||||
# An AOF file may be found to be truncated at the end during the Redis
|
||||
# startup process, when the AOF data gets loaded back into memory.
|
||||
# This may happen when the system where Redis is running
|
||||
@@ -700,9 +812,7 @@ auto-aof-rewrite-min-size <%=@aofrewriteminsize%>
|
||||
# Redis will try to read more data from the AOF file but not enough bytes
|
||||
# will be found.
|
||||
aof-load-truncated <%= @aofloadtruncated %>
|
||||
<% end %>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i >= 6) || @version[:major].to_i >= 3 %>
|
||||
################################ LUA SCRIPTING ###############################
|
||||
|
||||
# Max execution time of a Lua script in milliseconds.
|
||||
@@ -720,7 +830,6 @@ aof-load-truncated <%= @aofloadtruncated %>
|
||||
#
|
||||
# Set it to 0 or a negative value for unlimited execution without warnings.
|
||||
lua-time-limit <%= @luatimelimit %>
|
||||
<% end %>
|
||||
|
||||
################################## SLOW LOG ###################################
|
||||
|
||||
@@ -746,89 +855,10 @@ slowlog-log-slower-than <%= @slowloglogslowerthan %>
|
||||
# You can reclaim memory used by the slow log with SLOWLOG RESET.
|
||||
slowlog-max-len <%= @slowlogmaxlen %>
|
||||
|
||||
<% if @version[:major].to_i <= 2 && @version[:minor].to_i <= 4 %>
|
||||
################################ VIRTUAL MEMORY ###############################
|
||||
|
||||
### WARNING! Virtual Memory is deprecated in Redis 2.4
|
||||
### The use of Virtual Memory is strongly discouraged.
|
||||
|
||||
# Virtual Memory allows Redis to work with datasets bigger than the actual
|
||||
# amount of RAM needed to hold the whole dataset in memory.
|
||||
# In order to do so very used keys are taken in memory while the other keys
|
||||
# are swapped into a swap file, similarly to what operating systems do
|
||||
# with memory pages.
|
||||
#
|
||||
# To enable VM just set 'vm-enabled' to yes, and set the following three
|
||||
# VM parameters accordingly to your needs.
|
||||
|
||||
vm-enabled no
|
||||
# vm-enabled yes
|
||||
|
||||
# This is the path of the Redis swap file. As you can guess, swap files
|
||||
# can't be shared by different Redis instances, so make sure to use a swap
|
||||
# file for every redis process you are running. Redis will complain if the
|
||||
# swap file is already in use.
|
||||
#
|
||||
# The best kind of storage for the Redis swap file (that's accessed at random)
|
||||
# is a Solid State Disk (SSD).
|
||||
#
|
||||
# *** WARNING *** if you are using a shared hosting the default of putting
|
||||
# the swap file under /tmp is not secure. Create a dir with access granted
|
||||
# only to Redis user and configure Redis to create the swap file there.
|
||||
vm-swap-file <%= "/tmp/redis-#{@name}.swap" %>
|
||||
|
||||
# vm-max-memory configures the VM to use at max the specified amount of
|
||||
# RAM. Everything that deos not fit will be swapped on disk *if* possible, that
|
||||
# is, if there is still enough contiguous space in the swap file.
|
||||
#
|
||||
# With vm-max-memory 0 the system will swap everything it can. Not a good
|
||||
# default, just specify the max amount of RAM you can in bytes, but it's
|
||||
# better to leave some margin. For instance specify an amount of RAM
|
||||
# that's more or less between 60 and 80% of your free RAM.
|
||||
vm-max-memory 0
|
||||
|
||||
# Redis swap files is split into pages. An object can be saved using multiple
|
||||
# contiguous pages, but pages can't be shared between different objects.
|
||||
# So if your page is too big, small objects swapped out on disk will waste
|
||||
# a lot of space. If you page is too small, there is less space in the swap
|
||||
# file (assuming you configured the same number of total swap file pages).
|
||||
#
|
||||
# If you use a lot of small objects, use a page size of 64 or 32 bytes.
|
||||
# If you use a lot of big objects, use a bigger page size.
|
||||
# If unsure, use the default :)
|
||||
vm-page-size 32
|
||||
|
||||
# Number of total memory pages in the swap file.
|
||||
# Given that the page table (a bitmap of free/used pages) is taken in memory,
|
||||
# every 8 pages on disk will consume 1 byte of RAM.
|
||||
#
|
||||
# The total swap size is vm-page-size * vm-pages
|
||||
#
|
||||
# With the default of 32-bytes memory pages and 134217728 pages Redis will
|
||||
# use a 4 GB swap file, that will use 16 MB of RAM for the page table.
|
||||
#
|
||||
# It's better to use the smallest acceptable value for your application,
|
||||
# but the default is large in order to work in most conditions.
|
||||
vm-pages 134217728
|
||||
|
||||
# Max number of VM I/O threads running at the same time.
|
||||
# This threads are used to read/write data from/to swap file, since they
|
||||
# also encode and decode objects from disk to memory or the reverse, a bigger
|
||||
# number of threads can help with big objects even if they can't help with
|
||||
# I/O itself as the physical device may not be able to couple with many
|
||||
# reads/writes operations at the same time.
|
||||
#
|
||||
# The special value of 0 turn off threaded I/O and enables the blocking
|
||||
# Virtual Memory implementation.
|
||||
vm-max-threads 4
|
||||
<% end %>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 8 || @version[:major].to_i >= 3 %>
|
||||
<% ######## Redis 2.8 and higher ######## %>
|
||||
############################# Event notification ##############################
|
||||
############################# EVENT NOTIFICATION ##############################
|
||||
|
||||
# Redis can notify Pub/Sub clients about events happening in the key space.
|
||||
# This feature is documented at http://redis.io/topics/keyspace-events
|
||||
# This feature is documented at http://redis.io/topics/notifications
|
||||
#
|
||||
# For instance if keyspace events notification is enabled, and a client
|
||||
# performs a DEL operation on key "foo" stored in the Database 0, two
|
||||
@@ -850,7 +880,11 @@ vm-max-threads 4
|
||||
# z Sorted set commands
|
||||
# x Expired events (events generated every time a key expires)
|
||||
# e Evicted events (events generated when a key is evicted for maxmemory)
|
||||
# A Alias for g$lshzxe, so that the "AKE" string means all the events.
|
||||
# t Stream commands
|
||||
# m Key-miss events (Note: It is not included in the 'A' class)
|
||||
# A Alias for g$lshzxet, so that the "AKE" string means all the events
|
||||
# (Except key-miss events which are excluded from 'A' due to their
|
||||
# unique nature).
|
||||
#
|
||||
# The "notify-keyspace-events" takes as argument a string that is composed
|
||||
# of zero or multiple characters. The empty string means that notifications
|
||||
@@ -870,29 +904,15 @@ vm-max-threads 4
|
||||
# this feature and the feature has some overhead. Note that if you don't
|
||||
# specify at least one of K or E, no events will be delivered.
|
||||
notify-keyspace-events "<%= @notifykeyspaceevents %>"
|
||||
<% end %>
|
||||
|
||||
############################### ADVANCED CONFIG ###############################
|
||||
|
||||
# Hashes are encoded using a memory efficient data structure when they have a
|
||||
# small number of entries, and the biggest entry does not exceed a given
|
||||
# threshold. These thresholds can be configured using the following directives.
|
||||
|
||||
# Similarly to hashes, small lists are also encoded in a special way in order
|
||||
# to save a lot of space. The special representation is only used when
|
||||
# you are under the following limits:
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i >= 3 %>
|
||||
<% ######## Redis 2.6 and higher ######## %>
|
||||
hash-max-ziplist-entries <%= @hashmaxziplistentries %>
|
||||
hash-max-ziplist-value <%= @hashmaxziplistvalue %>
|
||||
|
||||
# Similarly to hashes, small lists are also encoded in a special way in order
|
||||
# # to save a lot of space. The special representation is only used when
|
||||
# # you are under the following limits:
|
||||
list-max-ziplist-entries <%= @listmaxziplistentries %>
|
||||
list-max-ziplist-value <%= @listmaxziplistvalue %>
|
||||
|
||||
# Sets have a special encoding in just one case: when a set is composed
|
||||
# of just strings that happen to be integers in radix 10 in the range
|
||||
# of 64 bit signed integers.
|
||||
@@ -906,7 +926,6 @@ set-max-intset-entries <%= @setmaxintsetentries %>
|
||||
zset-max-ziplist-entries <%= @zsetmaxziplistentries %>
|
||||
zset-max-ziplist-value <%= @zsetmaxziplistvalue %>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 8 && @version[:patch].to_i >= 9 || @version[:major].to_i >= 3 %>
|
||||
# HyperLogLog sparse representation bytes limit. The limit includes the
|
||||
# 16 bytes header. When an HyperLogLog using the sparse representation crosses
|
||||
# this limit, it is converted into the dense representation.
|
||||
@@ -920,7 +939,6 @@ zset-max-ziplist-value <%= @zsetmaxziplistvalue %>
|
||||
# ~ 10000 when CPU is not a concern, but space is, and the data set is
|
||||
# composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
|
||||
hll-sparse-max-bytes <%= @hllsparsemaxbytes %>
|
||||
<% end %>
|
||||
|
||||
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
|
||||
# order to help rehashing the main Redis hash table (the one mapping top-level
|
||||
@@ -942,13 +960,6 @@ hll-sparse-max-bytes <%= @hllsparsemaxbytes %>
|
||||
# want to free memory asap when possible.
|
||||
activerehashing <%= @activerehasing %>
|
||||
|
||||
<% elsif @version[:major].to_i == 2 && @version[:minor].to_i == 4 %>
|
||||
<% ######## Redis 2.4 ######## %>
|
||||
hash-max-zipmap-entries 512
|
||||
hash-max-zipmap-value 64
|
||||
<% end %>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i >= 6) || @version[:major].to_i >= 3 %>
|
||||
# The client output buffer limits can be used to force disconnection of clients
|
||||
# that are not reading data from the server fast enough for some reason (a
|
||||
# common reason is that a Pub/Sub client can't consume messages as fast as the
|
||||
@@ -956,8 +967,8 @@ activerehashing <%= @activerehasing %>
|
||||
#
|
||||
# The limit can be set differently for the three different classes of clients:
|
||||
#
|
||||
# normal -> normal clients
|
||||
# slave -> slave clients and MONITOR clients
|
||||
# normal -> normal clients including MONITOR clients
|
||||
# replica -> replica clients
|
||||
# pubsub -> clients subscribed to at least one pubsub channel or pattern
|
||||
#
|
||||
# The syntax of every client-output-buffer-limit directive is the following:
|
||||
@@ -978,21 +989,26 @@ activerehashing <%= @activerehasing %>
|
||||
# asynchronous clients may create a scenario where data is requested faster
|
||||
# than it can read.
|
||||
#
|
||||
# Instead there is a default limit for pubsub and slave clients, since
|
||||
# subscribers and slaves receive data in a push fashion.
|
||||
# Instead there is a default limit for pubsub and replica clients, since
|
||||
# subscribers and replicas receive data in a push fashion.
|
||||
#
|
||||
# Note that it doesn't make sense to set the replica clients output buffer
|
||||
# limit lower than the repl-backlog-size config (partial sync will succeed
|
||||
# and then replica will get disconnected).
|
||||
# Such a configuration is ignored (the size of repl-backlog-size will be used).
|
||||
# This doesn't have memory consumption implications since the replica client
|
||||
# will share the backlog buffers memory.
|
||||
#
|
||||
# Both the hard or the soft limit can be disabled by setting them to zero.
|
||||
|
||||
#client-output-buffer-limit normal 0 0 0
|
||||
#client-output-buffer-limit slave 256mb 64mb 60
|
||||
#client-output-buffer-limit replica 256mb 64mb 60
|
||||
#client-output-buffer-limit pubsub 32mb 8mb 60
|
||||
|
||||
<% @clientoutputbufferlimit.each do |c| %>
|
||||
<%= "client-output-buffer-limit #{c.flatten.join(' ')}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if (@version[:major].to_i == 2 && @version[:minor].to_i >= 8) || @version[:major].to_i >= 3 %>
|
||||
# Redis calls an internal function to perform many background tasks, like
|
||||
# closing connections of clients in timeout, purging expired keys that are
|
||||
# never requested, and so forth.
|
||||
@@ -1015,14 +1031,30 @@ hz <%= @hz %>
|
||||
# in order to commit the file to the disk more incrementally and avoid
|
||||
# big latency spikes.
|
||||
aof-rewrite-incremental-fsync <%= @aofrewriteincrementalfsync %>
|
||||
<% end %>
|
||||
|
||||
<%if @clusterenabled == 'yes' %>
|
||||
cluster-enabled yes
|
||||
cluster-config-file <%= @clusterconfigfile || "nodes-#{@name}.conf" %>
|
||||
cluster-node-timeout <%= @clusternodetimeout %>
|
||||
<%= "cluster-port #{@clusterport}" unless @clusterport.nil? %>
|
||||
<%end%>
|
||||
|
||||
<% if @version[:major].to_i >= 6 %>
|
||||
# Using an external ACL file
|
||||
#
|
||||
# Instead of configuring users here in this file, it is possible to use
|
||||
# a stand-alone file just listing users. The two methods cannot be mixed:
|
||||
# if you configure users here and at the same time you activate the external
|
||||
# ACL file, the server will refuse to start.
|
||||
#
|
||||
# The format of the external ACL user file is exactly the same as the
|
||||
# format that is used inside redis.conf to describe users.
|
||||
#
|
||||
<% unless @aclfile.nil? %>
|
||||
aclfile <%= @aclfile %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
################################## INCLUDES ###################################
|
||||
|
||||
# Include one or more other config files here. This is useful if you
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Simple Redis init.d script conceived to work on Linux systems
|
||||
# as it does use of the /proc filesystem.
|
||||
#
|
||||
# description: Redis is an in memory key-value store database
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: redis<%= @port %>
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Required-Start: <%= @required_start %>
|
||||
# Required-Stop: <%= @required_stop %>
|
||||
# Description: redis<%= @port %> init script
|
||||
### END INIT INFO
|
||||
|
||||
REDISNAME=<%= @name %>
|
||||
REDISPORT=<%= @port %>
|
||||
<% case @platform %>
|
||||
<% when 'ubuntu','debian','fedora' %>
|
||||
EXEC="su -s /bin/sh -c '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${REDISNAME}.conf' <%= @user %>"
|
||||
<% else %>
|
||||
EXEC="runuser <%= @user %> -c \"<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${REDISNAME}.conf\""
|
||||
<% end %>
|
||||
CLIEXEC=<%= File.join(@bin_path, 'redis-cli') %>
|
||||
|
||||
<% connection_string = String.new %>
|
||||
<% if @unixsocket.nil? %>
|
||||
<% connection_string << " -p #{@port}" %>
|
||||
<% connection_string << " -h #{@address.respond_to?(:first) ? @address.first : @address }" if @address %>
|
||||
<% else %>
|
||||
<% connection_string << " -s #{@unixsocket}" %>
|
||||
<% end %>
|
||||
<% connection_string << " -a '#{@requirepass}'" unless @requirepass.nil? %>
|
||||
|
||||
PIDFILE=<%= @piddir %>/redis_${REDISNAME}.pid
|
||||
|
||||
if [ ! -d <%= @piddir %> ]; then
|
||||
mkdir -p <%= @piddir %>
|
||||
chown <%= @user %> <%= @piddir %>
|
||||
fi
|
||||
|
||||
ulimit -n <%= @ulimit %>
|
||||
|
||||
case "$1" in
|
||||
status)
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
echo "redis$REDISNAME $PIDFILE exists, pid is $(cat $PIDFILE), should be running"
|
||||
ps -p $(cat $PIDFILE) >/dev/null 2>&1
|
||||
exit $?
|
||||
else
|
||||
echo "redis$REDISNAME $PIDFILE doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
start)
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE exists, process is already running or crashed"
|
||||
PIDNUM=`cat $PIDFILE`
|
||||
PROCESS_RUNNING=`ps --no-headers -q $PIDNUM | wc -l`
|
||||
if [ ! $PROCESS_RUNNING -eq 1 ]
|
||||
then
|
||||
echo "The PID doesn't exists, restarting it."
|
||||
rm $PIDFILE
|
||||
eval $EXEC
|
||||
fi
|
||||
else
|
||||
echo "Starting Redis server..."
|
||||
eval $EXEC
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
if [ ! -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE does not exist, process is not running"
|
||||
else
|
||||
PID=$(cat $PIDFILE)
|
||||
echo "Stopping ..."
|
||||
|
||||
<%= "$CLIEXEC #{connection_string} save" if @shutdown_save %>
|
||||
$CLIEXEC <%= connection_string %> shutdown
|
||||
|
||||
while [ -x /proc/${PID} ]
|
||||
do
|
||||
echo "Waiting for Redis to shutdown ..."
|
||||
sleep 1
|
||||
done
|
||||
echo "Redis stopped"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Please use start or stop as first argument"
|
||||
;;
|
||||
esac
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
|
||||
# PROVIDE: redis<%= @name %>
|
||||
# REQUIRE: LOGIN
|
||||
# BEFORE: securelevel
|
||||
# KEYWORD: shutdown
|
||||
|
||||
# Add the following line to /etc/rc.conf to enable `redis':
|
||||
#
|
||||
#redis<%= @name %>_enable="YES"
|
||||
#
|
||||
# Define profiles here to run separate redis instances:
|
||||
#
|
||||
#redis_profiles="foo bar" # Script uses /usr/local/etc/redis-NAME.conf respectively.
|
||||
# For correct script working please update pidfile entries in
|
||||
# redis-NAME.conf files.
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="redis<%= @name %>"
|
||||
rcvar="${name}_enable"
|
||||
|
||||
extra_commands="reload"
|
||||
|
||||
command="<%= File.join(@bin_path, 'redis-server') %>"
|
||||
pidfile="<%= @piddir %>/redis_<%=@name%>.pid"
|
||||
|
||||
# read configuration and set defaults
|
||||
load_rc_config "$name"
|
||||
: ${redis<%= @name %>_enable="NO"}
|
||||
: ${redis_user="<%= @user %>"}
|
||||
: ${redis_config="<%= @configdir %>/<%= @name %>.conf"}
|
||||
|
||||
command_args="${redis_config}"
|
||||
required_files="${redis_config}"
|
||||
|
||||
_profile_exists() {
|
||||
for _p in ${redis_profiles}; do
|
||||
[ "${_p}" = "$1" ] && return 1;
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ $# -eq 2 ]; then
|
||||
_profile=$2
|
||||
_profile_exists $_profile
|
||||
_exists=$?
|
||||
[ ${_exists} -ne 1 ] && {
|
||||
echo "`basename /usr/local/etc/rc.d/redis`: no '$2' in 'redis_profiles'"
|
||||
exit 1
|
||||
};
|
||||
echo "-- Profile: ${name} --"
|
||||
config_file="/usr/local/etc/redis/${name}.conf"
|
||||
command_args="${config_file}"
|
||||
pidfile="<%= @piddir %>/${name}.pid"
|
||||
required_files="${config_file}"
|
||||
elif [ -n "${redis_profiles}" ]; then
|
||||
_swap=$*; shift; _profiles=$*
|
||||
_profiles=${_profiles:-${redis_profiles}}
|
||||
set -- ${_swap}
|
||||
for _profile in ${_profiles}; do
|
||||
/usr/local/etc/rc.d/redis $1 ${_profile}
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
run_rc_command "$1"
|
||||
@@ -1,19 +0,0 @@
|
||||
description "Start the redis instance on port <%= @port %>"
|
||||
author "Installed by chef redisio cookbook"
|
||||
|
||||
#start on runlevel [2345]
|
||||
stop on runlevel [06]
|
||||
|
||||
script
|
||||
if [ ! -d <%= @piddir %> ]; then
|
||||
mkdir -p <%= @piddir %>
|
||||
chown <%= @user %>:<%= @group %> <%= @piddir %>
|
||||
fi
|
||||
end script
|
||||
|
||||
# If the job exits, restart it. Give up with more than 10 restarts in 30 seconds.
|
||||
respawn
|
||||
respawn limit 10 30
|
||||
|
||||
exec su -s /bin/sh -c 'exec "$0" "$@"' <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
[Unit]
|
||||
Description=Redis (%i) persistent key-value database
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
ExecStart=<%= @bin_path %>/redis-server /etc/redis/%i.conf --daemonize no
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
LimitNOFILE=<%= @limit_nofile %>
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -4,11 +4,15 @@
|
||||
<% if @job_control == 'initd' || @job_control == 'rcinit' %>
|
||||
daemonize yes
|
||||
<% end %>
|
||||
<% if @job_control == 'systemd' %>
|
||||
supervised systemd
|
||||
<% end %>
|
||||
pidfile <%= @piddir %>/sentinel_<%=@name%>.pid
|
||||
loglevel <%=@loglevel%>
|
||||
syslog-enabled <%= @syslogenabled %>
|
||||
syslog-ident redis-<%= @name %>
|
||||
syslog-facility <%= @syslogfacility %>
|
||||
maxclients <%= @maxclients %>
|
||||
<%= "logfile #{@logfile}" unless @logfile.nil? %>
|
||||
|
||||
<% if @sentinel_bind %>
|
||||
@@ -49,23 +53,32 @@ port <%=@sentinel_port%>
|
||||
|
||||
# sentinel monitor <master-name> <ip> <redis-port> <quorum>
|
||||
#
|
||||
# Tells Sentinel to monitor this slave, and to consider it in O_DOWN
|
||||
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
|
||||
# (Objectively Down) state only if at least <quorum> sentinels agree.
|
||||
#
|
||||
# Note that whatever is the ODOWN quorum, a Sentinel will require to
|
||||
# be elected by the majority of the known Sentinels in order to
|
||||
# start a failover, so no failover can be performed in minority.
|
||||
#
|
||||
# Replicas are auto-discovered, so you don't need to specify replicas in
|
||||
# any way. Sentinel itself will rewrite this configuration file adding
|
||||
# the replicas using additional configuration options.
|
||||
# Also note that the configuration file is rewritten when a
|
||||
# replica is promoted to master.
|
||||
#
|
||||
# Note: master name should not include special characters or spaces.
|
||||
# The valid charset is A-z 0-9 and the three characters ".-_".
|
||||
# sentinel monitor mymaster 127.0.0.1 6379 2
|
||||
<% @masters.each do |current| %>
|
||||
<% calc_name = String(current['master_name'] || @name || 'master_name') %>
|
||||
<%= "sentinel monitor #{calc_name} #{current['master_ip']} #{current['master_port']} #{current['quorum_count']}" %>
|
||||
<% end %>
|
||||
# sentinel auth-pass <master-name> <password>
|
||||
#
|
||||
# Set the password to use to authenticate with the master and slaves.
|
||||
# Set the password to use to authenticate with the master and replicas.
|
||||
# Useful if there is a password set in the Redis instances to monitor.
|
||||
#
|
||||
# Note that the master password is also used for slaves, so it is not
|
||||
# possible to set a different password in masters and slaves instances
|
||||
# Note that the master password is also used for replicas, so it is not
|
||||
# possible to set a different password in masters and replicas instances
|
||||
# if you want to be able to monitor these instances with Sentinel.
|
||||
#
|
||||
# However you can have Redis instances without the authentication enabled
|
||||
@@ -81,9 +94,27 @@ port <%=@sentinel_port%>
|
||||
<% calc_name = String(current['master_name'] || @name || 'master_name') %>
|
||||
<%= "sentinel auth-pass #{calc_name} #{current['auth_pass']}" unless current['auth_pass'].nil? %>
|
||||
<% end %>
|
||||
|
||||
<% if @version[:major].to_i >= 6 %>
|
||||
# Using an external ACL file
|
||||
#
|
||||
# Instead of configuring users here in this file, it is possible to use
|
||||
# a stand-alone file just listing users. The two methods cannot be mixed:
|
||||
# if you configure users here and at the same time you activate the external
|
||||
# ACL file, the server will refuse to start.
|
||||
#
|
||||
# The format of the external ACL user file is exactly the same as the
|
||||
# format that is used inside redis.conf to describe users.
|
||||
#
|
||||
# aclfile /etc/redis/sentinel-users.acl
|
||||
<% unless @aclfile.nil? %>
|
||||
aclfile <%= @aclfile %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
# sentinel down-after-milliseconds <master-name> <milliseconds>
|
||||
#
|
||||
# Number of milliseconds the master (or any attached slave or sentinel) should
|
||||
# Number of milliseconds the master (or any attached replica or sentinel) should
|
||||
# be unreachable (as in, not acceptable reply to PING, continuously, for the
|
||||
# specified period) in order to consider it in S_DOWN state (Subjectively
|
||||
# Down).
|
||||
@@ -93,11 +124,11 @@ port <%=@sentinel_port%>
|
||||
<% calc_name = String(current['master_name'] || @name || 'master_name') %>
|
||||
<%= "sentinel down-after-milliseconds #{calc_name} #{current['down_after_milliseconds']}" unless current['down_after_milliseconds'].nil? %>
|
||||
<% end %>
|
||||
# sentinel parallel-syncs <master-name> <numslaves>
|
||||
# sentinel parallel-syncs <master-name> <numreplicas>
|
||||
#
|
||||
# How many slaves we can reconfigure to point to the new slave simultaneously
|
||||
# during the failover. Use a low number if you use the slaves to serve query
|
||||
# to avoid that all the slaves will be unreachable at about the same
|
||||
# How many replicas we can reconfigure to point to the new replica simultaneously
|
||||
# during the failover. Use a low number if you use the replicas to serve query
|
||||
# to avoid that all the replicas will be unreachable at about the same
|
||||
# time while performing the synchronization with the master.
|
||||
<% @masters.each do |current| %>
|
||||
<% calc_name = String(current['master_name'] || @name || 'master_name') %>
|
||||
@@ -105,16 +136,25 @@ port <%=@sentinel_port%>
|
||||
<% end %>
|
||||
# sentinel failover-timeout <master-name> <milliseconds>
|
||||
#
|
||||
# Specifies the failover timeout in milliseconds. When this time has elapsed
|
||||
# without any progress in the failover process, it is considered concluded by
|
||||
# the sentinel even if not all the attached slaves were correctly configured
|
||||
# to replicate with the new master (however a "best effort" SLAVEOF command
|
||||
# is sent to all the slaves before).
|
||||
# Specifies the failover timeout in milliseconds. It is used in many ways:
|
||||
#
|
||||
# Also when 25% of this time has elapsed without any advancement, and there
|
||||
# is a leader switch (the sentinel did not started the failover but is now
|
||||
# elected as leader), the sentinel will continue the failover doing a
|
||||
# "takeover".
|
||||
# - The time needed to re-start a failover after a previous failover was
|
||||
# already tried against the same master by a given Sentinel, is two
|
||||
# times the failover timeout.
|
||||
#
|
||||
# - The time needed for a replica replicating to a wrong master according
|
||||
# to a Sentinel current configuration, to be forced to replicate
|
||||
# with the right master, is exactly the failover timeout (counting since
|
||||
# the moment a Sentinel detected the misconfiguration).
|
||||
#
|
||||
# - The time needed to cancel a failover that is already in progress but
|
||||
# did not produced any configuration change (REPLICAOF NO ONE yet not
|
||||
# acknowledged by the promoted replica).
|
||||
#
|
||||
# - The maximum time a failover in progress waits for all the replicas to be
|
||||
# reconfigured as replicas of the new master. However even after this time
|
||||
# the replicas will be reconfigured by the Sentinels anyway, but not with
|
||||
# the exact parallel-syncs progression as specified.
|
||||
#
|
||||
# Default is 15 minutes.
|
||||
<% @masters.each do |current| %>
|
||||
@@ -122,7 +162,6 @@ port <%=@sentinel_port%>
|
||||
<%= "sentinel failover-timeout #{calc_name} #{current['failover_timeout']}" unless current['failover_timeout'].nil? %>
|
||||
<% end %>
|
||||
|
||||
<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 8 || @version[:major].to_i > 3 %>
|
||||
# SCRIPTS EXECUTION
|
||||
#
|
||||
# sentinel notification-script and sentinel reconfig-script are used in order
|
||||
@@ -167,32 +206,20 @@ port <%=@sentinel_port%>
|
||||
#
|
||||
# sentinel client-reconfig-script <master-name> <script-path>
|
||||
#
|
||||
# When the failover starts, ends, or is aborted, a script can be called in
|
||||
# When the master changed because of a failover a script can be called in
|
||||
# order to perform application-specific tasks to notify the clients that the
|
||||
# configuration has changed and the master is at a different address.
|
||||
#
|
||||
# The script is called in the following cases:
|
||||
#
|
||||
# Failover started (a slave is already promoted)
|
||||
# Failover finished (all the additional slaves already reconfigured)
|
||||
# Failover aborted (in that case the script was previously called when the
|
||||
# failover started, and now gets called again with swapped
|
||||
# addresses).
|
||||
#
|
||||
# The following arguments are passed to the script:
|
||||
#
|
||||
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
|
||||
#
|
||||
# <state> is "start", "end" or "abort"
|
||||
# <state> is currently always "start"
|
||||
# <role> is either "leader" or "observer"
|
||||
#
|
||||
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
|
||||
# the old address of the master and the new address of the elected slave
|
||||
# (now a master) in the case state is "start" or "end".
|
||||
#
|
||||
# For abort instead the "from" is the address of the promoted slave and
|
||||
# "to" is the address of the original master address, since the failover
|
||||
# was aborted.
|
||||
# the old address of the master and the new address of the elected replica
|
||||
# (now a master).
|
||||
#
|
||||
# This script should be resistant to multiple invocations.
|
||||
#
|
||||
@@ -200,4 +227,154 @@ port <%=@sentinel_port%>
|
||||
#
|
||||
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
|
||||
<%= "sentinel client-reconfig-script #{@name} #{@client_reconfig_script}" unless @client_reconfig_script.nil? %>
|
||||
|
||||
################################# TLS/SSL #####################################
|
||||
|
||||
# By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
|
||||
# directive can be used to define TLS-listening ports. To enable TLS on the
|
||||
# default port, use:
|
||||
#
|
||||
# port 0
|
||||
# tls-port 6379
|
||||
<%= "tls-port #{@tlsport}" unless @tlsport.nil? %>
|
||||
|
||||
# Configure a X.509 certificate and private key to use for authenticating the
|
||||
# server to connected clients, masters or cluster peers. These files should be
|
||||
# PEM formatted.
|
||||
#
|
||||
# tls-cert-file redis.crt
|
||||
# tls-key-file redis.key
|
||||
<%= "tls-cert-file #{@tlscertfile}" unless @tlscertfile.nil? %>
|
||||
<%= "tls-key-file #{@tlskeyfile}" unless @tlskeyfile.nil? %>
|
||||
#
|
||||
# If the key file is encrypted using a passphrase, it can be included here
|
||||
# as well.
|
||||
#
|
||||
# tls-key-file-pass secret
|
||||
<%= "tls-key-file-pass #{@tlskeyfilepass}" unless @tlskeyfilepass.nil? %>
|
||||
|
||||
# Normally Redis uses the same certificate for both server functions (accepting
|
||||
# connections) and client functions (replicating from a master, establishing
|
||||
# cluster bus connections, etc.).
|
||||
#
|
||||
# Sometimes certificates are issued with attributes that designate them as
|
||||
# client-only or server-only certificates. In that case it may be desired to use
|
||||
# different certificates for incoming (server) and outgoing (client)
|
||||
# connections. To do that, use the following directives:
|
||||
#
|
||||
# tls-client-cert-file client.crt
|
||||
# tls-client-key-file client.key
|
||||
<%= "tls-client-cert-file #{@tlsclientcertfile}" unless @tlsclientcertfile.nil? %>
|
||||
<%= "tls-client-key-file #{@tlsclientkeyfile}" unless @tlsclientkeyfile.nil? %>
|
||||
#
|
||||
# If the key file is encrypted using a passphrase, it can be included here
|
||||
# as well.
|
||||
#
|
||||
# tls-client-key-file-pass secret
|
||||
<%= "tls-client-key-file-pass #{@tlsclientkeyfilepass}" unless @tlsclientkeyfilepass.nil? %>
|
||||
|
||||
# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange,
|
||||
# required by older versions of OpenSSL (<3.0). Newer versions do not require
|
||||
# this configuration and recommend against it.
|
||||
#
|
||||
# tls-dh-params-file redis.dh
|
||||
<%= "tls-dh-params-file #{@tlsdhparamsfile}" unless @tlsdhparamsfile.nil? %>
|
||||
|
||||
# Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
|
||||
# clients and peers. Redis requires an explicit configuration of at least one
|
||||
# of these, and will not implicitly use the system wide configuration.
|
||||
#
|
||||
# tls-ca-cert-file ca.crt
|
||||
# tls-ca-cert-dir /etc/ssl/certs
|
||||
<%= "tls-ca-cert-file #{@tlscacertfile}" unless @tlscacertfile.nil? %>
|
||||
<%= "tls-ca-cert-dir #{@tlscacertdir}" unless @tlscacertdir.nil? %>
|
||||
|
||||
# By default, clients (including replica servers) on a TLS port are required
|
||||
# to authenticate using valid client side certificates.
|
||||
#
|
||||
# If "no" is specified, client certificates are not required and not accepted.
|
||||
# If "optional" is specified, client certificates are accepted and must be
|
||||
# valid if provided, but are not required.
|
||||
#
|
||||
# tls-auth-clients no
|
||||
# tls-auth-clients optional
|
||||
<%= "tls-auth-clients #{@tlsauthclients}" unless @tlsauthclients.nil? %>
|
||||
|
||||
# By default, a Redis replica does not attempt to establish a TLS connection
|
||||
# with its master.
|
||||
#
|
||||
# Use the following directive to enable TLS on replication links.
|
||||
#
|
||||
# tls-replication yes
|
||||
<%= "tls-replication #{@tlsreplication}" unless @tlsreplication.nil? %>
|
||||
|
||||
# By default, the Redis Cluster bus uses a plain TCP connection. To enable
|
||||
# TLS for the bus protocol, use the following directive:
|
||||
#
|
||||
# tls-cluster yes
|
||||
<%= "tls-cluster #{@tlscluster}" unless @tlscluster.nil? %>
|
||||
|
||||
# By default, only TLSv1.2 and TLSv1.3 are enabled and it is highly recommended
|
||||
# that older formally deprecated versions are kept disabled to reduce the attack surface.
|
||||
# You can explicitly specify TLS versions to support.
|
||||
# Allowed values are case insensitive and include "TLSv1", "TLSv1.1", "TLSv1.2",
|
||||
# "TLSv1.3" (OpenSSL >= 1.1.1) or any combination.
|
||||
# To enable only TLSv1.2 and TLSv1.3, use:
|
||||
#
|
||||
# tls-protocols "TLSv1.2 TLSv1.3"
|
||||
<%= "tls-protocols #{@tlsprotocols}" unless @tlsprotocols.nil? %>
|
||||
|
||||
# Configure allowed ciphers. See the ciphers(1ssl) manpage for more information
|
||||
# about the syntax of this string.
|
||||
#
|
||||
# Note: this configuration applies only to <= TLSv1.2.
|
||||
#
|
||||
# tls-ciphers DEFAULT:!MEDIUM
|
||||
<%= "tls-ciphers #{@tlsciphers}" unless @tlsciphers.nil? %>
|
||||
|
||||
# Configure allowed TLSv1.3 ciphersuites. See the ciphers(1ssl) manpage for more
|
||||
# information about the syntax of this string, and specifically for TLSv1.3
|
||||
# ciphersuites.
|
||||
#
|
||||
# tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256
|
||||
<%= "tls-ciphersuites #{@tlsciphersuites}" unless @tlsciphersuites.nil? %>
|
||||
|
||||
# When choosing a cipher, use the server's preference instead of the client
|
||||
# preference. By default, the server follows the client's preference.
|
||||
#
|
||||
# tls-prefer-server-ciphers yes
|
||||
<%= "tls-prefer-server-ciphers #{@tlspreferserverciphers}" unless @tlspreferserverciphers.nil? %>
|
||||
|
||||
# By default, TLS session caching is enabled to allow faster and less expensive
|
||||
# reconnections by clients that support it. Use the following directive to disable
|
||||
# caching.
|
||||
#
|
||||
# tls-session-caching no
|
||||
<%= "tls-session-caching #{@tlssessioncaching}" unless @tlssessioncaching.nil? %>
|
||||
|
||||
# Change the default number of TLS sessions cached. A zero value sets the cache
|
||||
# to unlimited size. The default size is 20480.
|
||||
#
|
||||
# tls-session-cache-size 5000
|
||||
<%= "tls-session-cache-size #{@tlssessioncachesize}" unless @tlssessioncachesize.nil? %>
|
||||
|
||||
# Change the default timeout of cached TLS sessions. The default timeout is 300
|
||||
# seconds.
|
||||
#
|
||||
# tls-session-cache-timeout 60
|
||||
<%= "tls-session-cache-timeout #{@tlssessioncachetimeout}" unless @tlssessioncachetimeout.nil? %>
|
||||
|
||||
################################## INCLUDES ###################################
|
||||
|
||||
# Include one or more other config files here. This is useful if you
|
||||
# have a standard template that goes to all redis server but also need
|
||||
# to customize a few per-server settings. Include files can include
|
||||
# other files, so use this wisely.
|
||||
#
|
||||
# include /path/to/local.conf
|
||||
# include /path/to/other.conf
|
||||
<% unless @includes.nil? %>
|
||||
<% @includes.each do |include_option| %>
|
||||
<%= "include #{include_option}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Simple Redis init.d script conceived to work on Linux systems
|
||||
# as it does use of the /proc filesystem.
|
||||
#
|
||||
# description: Redis is an in memory key-value store database
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: redissentinel_<%=@name%>
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description:
|
||||
# Description: redissentinel_<%=@name%> init script
|
||||
### END INIT INFO
|
||||
|
||||
SENTINELNAME=<%= @name %>
|
||||
<% case @platform %>
|
||||
<% when 'ubuntu','debian','fedora' %>
|
||||
EXEC="su -s /bin/sh -c '<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${SENTINELNAME}.conf --sentinel' <%= @user %>"
|
||||
<% else %>
|
||||
EXEC="runuser <%= @user %> -c \"<%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/${SENTINELNAME}.conf --sentinel\""
|
||||
<% end %>
|
||||
CLIEXEC=<%= File.join(@bin_path, 'redis-cli') %>
|
||||
|
||||
|
||||
PIDFILE=<%= @piddir %>/${SENTINELNAME}.pid
|
||||
|
||||
if [ ! -d <%= @piddir %> ]; then
|
||||
mkdir -p <%= @piddir %>
|
||||
chown <%= @user %> <%= @piddir %>
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
status)
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
echo "redis$SENTINELNAME $PIDFILE exists, pid is $(cat $PIDFILE), should be running"
|
||||
ps -p $(cat $PIDFILE) >/dev/null 2>&1
|
||||
exit $?
|
||||
else
|
||||
echo "redis$SENTINELNAME $PIDFILE doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
start)
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE exists, process is already running or crashed"
|
||||
else
|
||||
echo "Starting Redis server..."
|
||||
eval $EXEC
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
if [ ! -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE does not exist, process is not running"
|
||||
else
|
||||
PID=$(cat $PIDFILE)
|
||||
echo "Stopping ..."
|
||||
|
||||
kill ${PID}
|
||||
|
||||
while [ -x /proc/${PID} ]
|
||||
do
|
||||
echo "Waiting for Redis to shutdown ..."
|
||||
sleep 1
|
||||
done
|
||||
echo "Redis stopped"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Please use start or stop as first argument"
|
||||
;;
|
||||
esac
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# PROVIDE: sentinel_<%=@name%>
|
||||
# REQUIRE: LOGIN
|
||||
# BEFORE: securelevel
|
||||
# KEYWORD: shutdown
|
||||
|
||||
# Add the following line to /etc/rc.conf to enable `sentinel':
|
||||
#
|
||||
#redis_<%= @name %>_enable="YES"
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="redis_<%= @name %>"
|
||||
rcvar="${name}_enable"
|
||||
|
||||
command="<%= File.join(@bin_path, 'redis-sentinel') %>"
|
||||
pidfile="<%= @piddir %>/<%=@name%>.pid"
|
||||
|
||||
# read configuration and set defaults
|
||||
load_rc_config "$name"
|
||||
: ${sentinel_enable="NO"}
|
||||
: ${sentinel_user="<%= @user %>"}
|
||||
: ${sentinel_config="<%= @configdir %>/<%= @name %>.conf"}
|
||||
|
||||
command_args="${sentinel_config} --daemonize yes --pidfile ${pidfile}"
|
||||
required_files="${sentinel_config}"
|
||||
start_precmd="sentinel_checks"
|
||||
restart_precmd="sentinel_checks"
|
||||
|
||||
sentinel_checks()
|
||||
{
|
||||
if [ x`id -u ${sentinel_user}` != x`stat -f %u ${sentinel_config}` ]; then
|
||||
err 1 "${sentinel_config} must be owned by user ${sentinel_user}"
|
||||
fi
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
||||
@@ -1,19 +0,0 @@
|
||||
description "Start the redis-sentinel instance on port <%= @port %>"
|
||||
author "Installed by chef redisio cookbook"
|
||||
|
||||
#start on runlevel [2345]
|
||||
stop on runlevel [06]
|
||||
|
||||
script
|
||||
if [ ! -d <%= @piddir %> ]; then
|
||||
mkdir -p <%= @piddir %>
|
||||
chown <%= @user %>:<%= @group %> <%= @piddir %>
|
||||
fi
|
||||
end script
|
||||
|
||||
# If the job exits, restart it. Give up with more than 10 restarts in 30 seconds.
|
||||
respawn
|
||||
respawn limit 10 30
|
||||
|
||||
exec su -s /bin/sh -c 'exec "$0" "$@"' -- <%= @user %> <%= File.join(@bin_path, 'redis-server') %> <%= @configdir %>/<%= @name %>.conf --sentinel
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# The PAM configuration file for the Shadow `su' service
|
||||
#
|
||||
# This file modified by Chef to enable ulimit switching with `su`
|
||||
#
|
||||
|
||||
# This allows root to su without passwords (normal operation)
|
||||
auth sufficient pam_rootok.so
|
||||
|
||||
# Uncomment this to force users to be a member of group root
|
||||
# before they can use `su'. You can also add "group=foo"
|
||||
# to the end of this line if you want to use a group other
|
||||
# than the default "root" (but this may have side effect of
|
||||
# denying "root" user, unless she's a member of "foo" or explicitly
|
||||
# permitted earlier by e.g. "sufficient pam_rootok.so").
|
||||
# (Replaces the `SU_WHEEL_ONLY' option from login.defs)
|
||||
# auth required pam_wheel.so
|
||||
|
||||
# Uncomment this if you want wheel members to be able to
|
||||
# su without a password.
|
||||
# auth sufficient pam_wheel.so trust
|
||||
|
||||
# Uncomment this if you want members of a specific group to not
|
||||
# be allowed to use su at all.
|
||||
# auth required pam_wheel.so deny group=nosu
|
||||
|
||||
# Uncomment and edit /etc/security/time.conf if you need to set
|
||||
# time restrainst on su usage.
|
||||
# (Replaces the `PORTTIME_CHECKS_ENAB' option from login.defs
|
||||
# as well as /etc/porttime)
|
||||
# account requisite pam_time.so
|
||||
|
||||
# This module parses environment configuration file(s)
|
||||
# and also allows you to use an extended config
|
||||
# file /etc/security/pam_env.conf.
|
||||
#
|
||||
# parsing /etc/environment needs "readenv=1"
|
||||
session required pam_env.so readenv=1
|
||||
# locale variables are also kept into /etc/default/locale in etch
|
||||
# reading this file *in addition to /etc/environment* does not hurt
|
||||
session required pam_env.so readenv=1 envfile=/etc/default/locale
|
||||
|
||||
# Defines the MAIL environment variable
|
||||
# However, userdel also needs MAIL_DIR and MAIL_FILE variables
|
||||
# in /etc/login.defs to make sure that removing a user
|
||||
# also removes the user's mail spool file.
|
||||
# See comments in /etc/login.defs
|
||||
#
|
||||
# "nopen" stands to avoid reporting new mail when su'ing to another user
|
||||
session optional pam_mail.so nopen
|
||||
|
||||
# Sets up user limits, please uncomment and read /etc/security/limits.conf
|
||||
# to enable this functionality.
|
||||
# (Replaces the use of /etc/limits in old login)
|
||||
session required pam_limits.so
|
||||
|
||||
# The standard Unix authentication modules, used with
|
||||
# NIS (man nsswitch) as well as normal /etc/passwd and
|
||||
# /etc/shadow entries.
|
||||
@include common-auth
|
||||
@include common-account
|
||||
@include common-session
|
||||
@@ -1,32 +0,0 @@
|
||||
# Limits settings for <%= @ulimit_user %>
|
||||
<% unless @filehandle_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - nofile <%= @filehandle_limit %>
|
||||
<% else -%><% unless @filehandle_soft_limit.nil? -%><%= @ulimit_user -%> soft nofile <%= @filehandle_soft_limit %><% end -%>
|
||||
<% unless @filehandle_hard_limit.nil? -%><%= @ulimit_user -%> hard nofile <%= @filehandle_hard_limit %><% end -%>
|
||||
<% end -%>
|
||||
<% unless @process_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - nproc <%= @process_limit %>
|
||||
<% else -%><% unless @process_soft_limit.nil? -%><%= @ulimit_user -%> soft nproc <%= @process_soft_limit %><% end -%>
|
||||
<% unless @process_hard_limit.nil? -%><%= @ulimit_user -%> hard nproc <%= @process_hard_limit %><% end -%>
|
||||
<% end -%>
|
||||
<% unless @memory_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - memlock <%= @memory_limit %>
|
||||
<% end -%>
|
||||
<% unless @core_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - core <%= @core_limit %>
|
||||
<% else -%><% unless @core_soft_limit.nil? -%><%= @ulimit_user -%> soft core <%= @core_soft_limit %><% end -%>
|
||||
<% unless @core_hard_limit.nil? -%><%= @ulimit_user -%> hard core <%= @core_hard_limit %><% end -%>
|
||||
<% end -%>
|
||||
<% unless @stack_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - stack <%= @stack_limit %>
|
||||
<% else -%><% unless @stack_soft_limit.nil? -%><%= @ulimit_user -%> soft stack <%= @stack_soft_limit %><% end -%>
|
||||
<% unless @stack_hard_limit.nil? -%><%= @ulimit_user -%> hard stack <%= @stack_hard_limit %><% end -%>
|
||||
<% end -%>
|
||||
<% unless @rtprio_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - rtprio <%= @rtprio_limit %>
|
||||
<% else -%><% unless @rtprio_soft_limit.nil? -%><%= @ulimit_user -%> soft rtprio <%= @rtprio_soft_limit %><% end -%>
|
||||
<% unless @rtprio_hard_limit.nil? -%><%= @ulimit_user -%> hard rtprio <%= @rtprio_hard_limit %><% end -%>
|
||||
<% end -%>
|
||||
<% unless @virt_limit.nil? -%>
|
||||
<%= @ulimit_user -%> - as <%= @virt_limit %>
|
||||
<% end -%>
|
||||
@@ -3,3 +3,5 @@ config:
|
||||
line-length: false # MD013
|
||||
no-duplicate-heading: false # MD024
|
||||
reference-links-images: false # MD052
|
||||
ignores:
|
||||
- .github/copilot-instructions.md
|
||||
|
||||
@@ -2,6 +2,48 @@
|
||||
|
||||
This file is used to list changes made in each version of the selinux cookbook.
|
||||
|
||||
## 6.2.4 - *2025-09-04*
|
||||
|
||||
## 6.2.3 - *2025-06-08*
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.2.2 - *2024-11-18*
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.2.1 - *2024-08-13*
|
||||
|
||||
- fix documentation for `selinux_fcontext`
|
||||
|
||||
## 6.2.0 - *2024-07-15*
|
||||
|
||||
## 6.1.19 - *2024-07-15*
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
Standardise files with files in sous-chefs/repo-management
|
||||
|
||||
## 6.1.18 - *2024-05-03*
|
||||
|
||||
- resolved cookstyle error: resources/install.rb:5:1 refactor: `Chef/Style/CopyrightCommentFormat`
|
||||
- resolved cookstyle error: resources/module.rb:5:1 refactor: `Chef/Style/CopyrightCommentFormat`
|
||||
- resolved cookstyle error: resources/state.rb:5:1 refactor: `Chef/Style/CopyrightCommentFormat`
|
||||
|
||||
## 6.1.17 - *2024-05-03*
|
||||
|
||||
## 6.1.16 - *2024-05-03*
|
||||
|
||||
## 6.1.15 - *2023-09-29*
|
||||
|
||||
## 6.1.14 - *2023-09-04*
|
||||
|
||||
## 6.1.13 - *2023-09-04*
|
||||
|
||||
## 6.1.12 - *2023-05-17*
|
||||
|
||||
## 6.1.11 - *2023-04-17*
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"recipes": {
|
||||
|
||||
},
|
||||
"version": "6.1.12",
|
||||
"version": "6.2.4",
|
||||
"source_url": "https://github.com/sous-chefs/selinux",
|
||||
"issues_url": "https://github.com/sous-chefs/selinux/issues",
|
||||
"privacy": false,
|
||||
|
||||
@@ -3,7 +3,7 @@ maintainer 'Sous Chefs'
|
||||
maintainer_email 'help@sous-chefs.org'
|
||||
license 'Apache-2.0'
|
||||
description 'Manages SELinux policy state and rules.'
|
||||
version '6.1.12'
|
||||
version '6.2.4'
|
||||
source_url 'https://github.com/sous-chefs/selinux'
|
||||
issues_url 'https://github.com/sous-chefs/selinux/issues'
|
||||
chef_version '>= 15.3'
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:base"],
|
||||
"packageRules": [{
|
||||
"packageRules": [
|
||||
{
|
||||
"groupName": "Actions",
|
||||
"matchUpdateTypes": ["patch", "pin", "digest"],
|
||||
"matchUpdateTypes": ["minor", "patch", "pin"],
|
||||
"automerge": true,
|
||||
"addLabels": ["Release: Patch", "Skip: Announcements"]
|
||||
},
|
||||
|
||||
@@ -93,7 +93,14 @@ action :add do
|
||||
return
|
||||
end
|
||||
|
||||
unless current_file_context
|
||||
# "add" is performed in two scenarios.
|
||||
# 1: The local file_contexts.local has an entry for new_resource.file_spec, but secontext <> new_resource.secontext
|
||||
# 2. The local file_contexts.local does NOT have an entry for new_resource.file_spec, AND
|
||||
# either the system default (file_contexts) does not have an entry for new_resource.file_spec, or the secontext <> new_resource.secontext
|
||||
# In both scenarios, file_contexts.local is created with a new entry, or the secontext is updated.
|
||||
|
||||
cfc = current_file_context
|
||||
unless cfc && cfc == new_resource.secontext
|
||||
converge_by "adding label #{new_resource.secontext} to #{new_resource.file_spec}" do
|
||||
shell_out!("semanage fcontext -a -f #{new_resource.file_type} -t #{new_resource.secontext} '#{new_resource.file_spec}'")
|
||||
relabel_files
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Cookbook:: selinux
|
||||
# Resource:: install
|
||||
#
|
||||
# Copyright:: 2016-2023, Chef Software, Inc.
|
||||
# Copyright:: 2016-2024, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Cookbook:: selinux
|
||||
# Resource:: module
|
||||
#
|
||||
# Copyright:: 2016-2023, Chef Software, Inc.
|
||||
# Copyright:: 2016-2024, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Cookbook:: selinux
|
||||
# Resource:: state
|
||||
#
|
||||
# Copyright:: 2016-2023, Chef Software, Inc.
|
||||
# Copyright:: 2016-2024, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "redis",
|
||||
"password": {
|
||||
"encrypted_data": "M2Cr7oNhL735D3coHnMc9yLuUzYlhkl+TfyMx1ccplFOyVZ+fXRF9UdDqxJ2\nyFIDJ+Yg\n",
|
||||
"iv": "nEQz0SCUuFAEmxMd\n",
|
||||
"auth_tag": "uuwSJdMZfLcRs7yjVrRlAQ==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
}
|
||||
}
|
||||
+1
-1
Submodule nodes updated: 5020b10aa8...a0396e959b
@@ -40,6 +40,7 @@ production_run_list = %w(
|
||||
kosmos-ipfs::nginx_public_gateway
|
||||
kosmos-mastodon::nginx
|
||||
remotestorage_discourse::nginx
|
||||
sockethub::nginx
|
||||
role[tor_proxy]
|
||||
)
|
||||
|
||||
|
||||
+11
-9
@@ -1,15 +1,17 @@
|
||||
name "redis_replica"
|
||||
|
||||
run_list %w(
|
||||
default_run_list = %w(
|
||||
kosmos_redis::replica
|
||||
)
|
||||
|
||||
production_run_list = %w(
|
||||
kosmos_redis::replica
|
||||
kosmos_redis::firewall
|
||||
)
|
||||
# TODO: Replace the old backup
|
||||
|
||||
default_attributes({
|
||||
'redisio' => {
|
||||
'default_settings' => {
|
||||
'slaveservestaledata' => 'yes',
|
||||
'slavereadonly' => 'yes'
|
||||
}
|
||||
}
|
||||
})
|
||||
env_run_lists(
|
||||
'_default' => default_run_list,
|
||||
'development' => default_run_list,
|
||||
'production' => production_run_list
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ default_run_list = %w(
|
||||
production_run_list = %w(
|
||||
kosmos_redis::default
|
||||
kosmos_redis::firewall
|
||||
kosmos_redis::backup
|
||||
)
|
||||
# TODO: Replace the old backup
|
||||
|
||||
env_run_lists(
|
||||
'_default' => default_run_list,
|
||||
|
||||
+4
-3
@@ -1,10 +1,11 @@
|
||||
name "sockethub"
|
||||
|
||||
default_attributes 'sockethub' => {
|
||||
'version' => '5.0.0-alpha.1'
|
||||
default_attributes 'kosmos_redis' => {
|
||||
'requirepass' => false
|
||||
}
|
||||
|
||||
run_list %w(
|
||||
kosmos_redis::default
|
||||
sockethub::default
|
||||
sockethub::proxy
|
||||
sockethub::firewall
|
||||
)
|
||||
|
||||
@@ -17,6 +17,10 @@ ROOT_URL = https://%(DOMAIN)s
|
||||
# LETSENCRYPT_DIRECTORY = /data/gitea/https
|
||||
# LETSENCRYPT_EMAIL = ops@5apps.com
|
||||
|
||||
[cors]
|
||||
ENABLED = true
|
||||
ALLOW_DOMAIN = *
|
||||
|
||||
[database]
|
||||
DB_TYPE = postgres
|
||||
HOST = <%= @postgresql_host %>
|
||||
@@ -29,6 +33,7 @@ MAX_OPEN_CONNS = 20
|
||||
[repository]
|
||||
ROOT = <%= @repository_root_directory %>
|
||||
DISABLE_DOWNLOAD_SOURCE_ARCHIVES = true
|
||||
ACCESS_CONTROL_ALLOW_ORIGIN = *
|
||||
|
||||
[repository.signing]
|
||||
SIGNING_KEY = <%= @git_home_directory %>/.ssh/id_ed25519.pub
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
node.override["redisio"]["version"] = "7.0.11"
|
||||
# frozen_string_literal: true
|
||||
|
||||
default["kosmos_redis"]["add_redisio_repository"] = true
|
||||
default["kosmos_redis"]["package_name"] = "redis"
|
||||
default["kosmos_redis"]["port"] = 6379
|
||||
default["kosmos_redis"]["requirepass"] = true
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
name 'kosmos_redis'
|
||||
maintainer 'Kosmos'
|
||||
maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'redis wrapper cookbook'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.2.0'
|
||||
# frozen_string_literal: true
|
||||
|
||||
depends 'redisio'
|
||||
depends 'backup'
|
||||
depends 'kosmos-base'
|
||||
name "kosmos_redis"
|
||||
maintainer "Kosmos"
|
||||
maintainer_email "mail@kosmos.org"
|
||||
license "MIT"
|
||||
description "redisio wrapper cookbook"
|
||||
version "0.2.0"
|
||||
chef_version "~> 18.0" # apt_repository resource
|
||||
|
||||
depends "redisio"
|
||||
depends "backup"
|
||||
depends "kosmos-base"
|
||||
depends "apt"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Cookbook Name:: kosmos_redis
|
||||
# Cookbook:: kosmos_redis
|
||||
# Recipe:: backup
|
||||
#
|
||||
|
||||
databases = node['redisio']['servers'].map do |server, _|
|
||||
"dump-#{server['port']}"
|
||||
databases = node["redisio"]["servers"].map do |server, _|
|
||||
"dump-#{server["port"]}"
|
||||
end
|
||||
node.override["backup"]["redis"]["databases"] = databases
|
||||
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Cookbook Name:: kosmos_redis
|
||||
# Cookbook:: kosmos_redis
|
||||
# Recipe:: default
|
||||
#
|
||||
|
||||
node.normal['redisio']['servers'] = [{
|
||||
'port' => '6379',
|
||||
'protected_mode' => 'no'
|
||||
}]
|
||||
include_recipe "kosmos_redis::repo" if node["kosmos_redis"]["add_redisio_repository"]
|
||||
|
||||
include_recipe 'redisio::default'
|
||||
include_recipe 'redisio::enable'
|
||||
credentials = data_bag_item("credentials", "redis") if node["kosmos_redis"]["requirepass"]
|
||||
|
||||
redisio_install "default" do
|
||||
package_install true
|
||||
package_name node["kosmos_redis"]["package_name"]
|
||||
end
|
||||
|
||||
redisio_server node["kosmos_redis"]["port"].to_s do
|
||||
package_install true
|
||||
package_name node["kosmos_redis"]["package_name"]
|
||||
requirepass credentials["password"] if node["kosmos_redis"]["requirepass"]
|
||||
end
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Cookbook Name:: kosmos_redis
|
||||
# Cookbook:: kosmos_redis
|
||||
# Recipe:: firewall
|
||||
#
|
||||
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
ports = node['redisio']['servers'].map do |server, _|
|
||||
server['port']
|
||||
end
|
||||
|
||||
firewall_rule "redis" do
|
||||
port ports
|
||||
source "10.1.1.0/24" # zerotier
|
||||
port node["kosmos_redis"]["port"]
|
||||
source "10.1.1.0/24" # zerotier
|
||||
protocol :tcp
|
||||
command :allow
|
||||
command :allow
|
||||
end
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Cookbook Name:: kosmos_redis
|
||||
# Cookbook:: kosmos_redis
|
||||
# Recipe:: replica
|
||||
#
|
||||
|
||||
primary_host = search(:node, 'role:redis_server').first['knife_zero']['host'] rescue nil
|
||||
primary_host = search(:node, "role:redis_server").first&.dig("knife_zero", "host")
|
||||
|
||||
if primary_host.nil?
|
||||
Chef::Log.warn("No node found with 'redis_server' role. Stopping here.")
|
||||
return
|
||||
end
|
||||
|
||||
node.normal['redisio']['servers'] = [{
|
||||
'port' => '6379',
|
||||
'replicaof' => { 'address' => primary_host, 'port' => '6379' }
|
||||
}]
|
||||
credentials = data_bag_item("credentials", "redis")
|
||||
|
||||
include_recipe 'redisio::default'
|
||||
include_recipe 'redisio::enable'
|
||||
redisio_install "default" do
|
||||
package_install true
|
||||
package_name node["kosmos_redis"]["package_name"]
|
||||
end
|
||||
|
||||
redisio_server node["kosmos_redis"]["port"].to_s do
|
||||
package_install true
|
||||
package_name node["kosmos_redis"]["package_name"]
|
||||
replicaof({"address" => primary_host, "port" => node["kosmos_redis"]["port"]})
|
||||
requirepass credentials["password"]
|
||||
masterauth credentials["password"]
|
||||
end
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Cookbook:: kosmos_redis
|
||||
# Recipe:: repo
|
||||
#
|
||||
|
||||
# Download+dearmor exactly like the manual command
|
||||
execute "create redis signing keyring" do
|
||||
command "curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg"
|
||||
creates "/usr/share/keyrings/redis-archive-keyring.gpg"
|
||||
end
|
||||
|
||||
file "/usr/share/keyrings/redis-archive-keyring.gpg" do
|
||||
mode "0644"
|
||||
end
|
||||
|
||||
# # Add Redis repo
|
||||
# apt_repository "redis" do
|
||||
# uri "https://packages.redis.io/deb"
|
||||
# components ["main"]
|
||||
# end
|
||||
|
||||
# Ensure apt sources.list.d entry uses signed-by (Chef's apt_repository doesn't
|
||||
# always expose signed-by cleanly)
|
||||
file "/etc/apt/sources.list.d/redis.list" do
|
||||
content "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb #{node["lsb"]["codename"]} main\n"
|
||||
mode "0644"
|
||||
notifies :update, "apt_update[redis repo]", :immediately
|
||||
end
|
||||
|
||||
apt_update "redis repo"
|
||||
@@ -1,6 +1,14 @@
|
||||
sockethub CHANGELOG
|
||||
===================
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
0.3.0
|
||||
-----
|
||||
- Update to sockethub 5.0.0-alpha.25
|
||||
- Serve via openresty proxy (tls_cert_for + openresty_site) instead of
|
||||
a directly managed nginx on the VM
|
||||
- Generate sockethub.config.json (trustProxy, reconnectIpSource)
|
||||
- Restrict the service port to the internal 10.1.1.0/24 network
|
||||
|
||||
0.1.0
|
||||
-----
|
||||
- [Greg Karékinian] - Initial release of sockethub
|
||||
- Initial release of sockethub cookbook
|
||||
|
||||
@@ -7,27 +7,10 @@ Attributes
|
||||
----------
|
||||
|
||||
#### sockethub::default
|
||||
<table>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>['sockethub']['port']</tt></td>
|
||||
<td>Integer</td>
|
||||
<td>The local port to run sockethub on</td>
|
||||
<td><tt>10551</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>['sockethub']['external_port']</tt></td>
|
||||
<td>Integer</td>
|
||||
<td>The external port to run sockethub on. This will also open the port on the firewall</td>
|
||||
<td><tt>10550</tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Right now the nginx vhost is hardcoded: sockethub.kosmos.org
|
||||
|
||||
Sockethub will be available under https://sockethub.kosmos.org:10550
|
||||
| Key | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| `['sockethub']['version']` | String | The npm version of sockethub to install | `5.0.0-alpha.25` |
|
||||
| `['sockethub']['port']` | Integer | The local port to run sockethub on | `10550` |
|
||||
| `['sockethub']['domain']` | String | The public domain served by the openresty proxy | `sockethub.kosmos.org` |
|
||||
| `['sockethub']['log_level']` | String | Console log level (error, warn, info, debug) | `info` |
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
node.default['sockethub']['port'] = '10551'
|
||||
node.default['sockethub']['external_port'] = '10550'
|
||||
node.default['sockethub']['version'] = '4.1.0'
|
||||
node.default['sockethub']['nginx']['server_name'] = 'sockethub.kosmos.org'
|
||||
node.default['sockethub']['debug_logs'] = 'sockethub*'
|
||||
node.default['sockethub']['version'] = '5.0.0-alpha.25'
|
||||
node.default['sockethub']['port'] = '10550'
|
||||
node.default['sockethub']['domain'] = 'sockethub.kosmos.org'
|
||||
node.default['sockethub']['log_level'] = 'info'
|
||||
@@ -4,9 +4,9 @@ maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/Configures sockethub'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.2.0'
|
||||
version '0.3.0'
|
||||
|
||||
depends 'firewall'
|
||||
depends 'redisio'
|
||||
depends 'kosmos-base'
|
||||
depends 'kosmos-nodejs'
|
||||
depends 'kosmos-nginx'
|
||||
depends 'kosmos_openresty'
|
||||
@@ -3,10 +3,7 @@
|
||||
# Recipe:: default
|
||||
#
|
||||
|
||||
include_recipe 'redisio::default'
|
||||
include_recipe 'redisio::enable'
|
||||
|
||||
node.override["kosmos_nodejs"]["version"] = "24.18.0"
|
||||
node.override["kosmos_nodejs"]["version"] = "24.21.0"
|
||||
include_recipe 'kosmos-nodejs'
|
||||
|
||||
user = "sockethub"
|
||||
@@ -27,6 +24,24 @@ end
|
||||
|
||||
npm_package "sockethub" do
|
||||
version node['sockethub']['version']
|
||||
auto_update false
|
||||
end
|
||||
|
||||
directory "/etc/sockethub" do
|
||||
owner user
|
||||
group group
|
||||
mode 0750
|
||||
end
|
||||
|
||||
template "/etc/sockethub/sockethub.config.json" do
|
||||
source "sockethub.config.json.erb"
|
||||
owner user
|
||||
group group
|
||||
mode 0640
|
||||
variables port: node['sockethub']['port'],
|
||||
domain: node['sockethub']['domain'],
|
||||
log_level: node['sockethub']['log_level']
|
||||
notifies :restart, 'systemd_unit[sockethub_nodejs.service]', :delayed
|
||||
end
|
||||
|
||||
execute "systemctl daemon-reload" do
|
||||
@@ -34,17 +49,6 @@ execute "systemctl daemon-reload" do
|
||||
action :nothing
|
||||
end
|
||||
|
||||
environment_variables = {
|
||||
'PORT' => node['sockethub']['port'],
|
||||
# Use the second database (index starts at 0)
|
||||
'REDIS_URL' => "redis://localhost:6379/1"
|
||||
}
|
||||
unless node['sockethub']['debug_logs'].nil?
|
||||
environment_variables['DEBUG'] = node['sockethub']['debug_logs']
|
||||
end
|
||||
|
||||
environment = environment_variables.map{|k, v| "'#{k}=#{v}'"}.join(' ')
|
||||
|
||||
systemd_unit "sockethub_nodejs.service" do
|
||||
content <<-EOF
|
||||
[Unit]
|
||||
@@ -56,7 +60,7 @@ After=redis@6379.service
|
||||
ExecStart=#{entry}
|
||||
User=#{user}
|
||||
Group=#{group}
|
||||
Environment=#{environment}
|
||||
Environment=SOCKETHUB_CONFIG=/etc/sockethub/sockethub.config.json
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -7,7 +7,8 @@ unless node.chef_environment == "development"
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
firewall_rule 'sockethub' do
|
||||
port node['sockethub']['external_port'].to_i
|
||||
port node['sockethub']['port'].to_i
|
||||
source '10.1.1.0/24'
|
||||
protocol :tcp
|
||||
command :allow
|
||||
end
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Cookbook Name:: sockethub
|
||||
# Recipe:: nginx
|
||||
#
|
||||
|
||||
domain = node['sockethub']['domain']
|
||||
|
||||
sockethub_node = search(:node, 'role:sockethub').first
|
||||
|
||||
if sockethub_node.nil?
|
||||
Chef::Log.warn("No node found with 'sockethub' role. Not configuring openresty site.")
|
||||
return
|
||||
end
|
||||
|
||||
tls_cert_for domain do
|
||||
auth 'gandi_dns'
|
||||
action :create
|
||||
end
|
||||
|
||||
openresty_site domain do
|
||||
template 'nginx_conf_sockethub.erb'
|
||||
variables domain: domain,
|
||||
upstream_host: sockethub_node['knife_zero']['host'],
|
||||
upstream_port: node['sockethub']['port'],
|
||||
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
|
||||
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
|
||||
end
|
||||
@@ -1,58 +0,0 @@
|
||||
#
|
||||
# Cookbook Name:: sockethub
|
||||
# Recipe:: proxy
|
||||
#
|
||||
|
||||
include_recipe 'sockethub::firewall'
|
||||
include_recipe 'kosmos-nginx'
|
||||
include_recipe "kosmos-base::letsencrypt"
|
||||
|
||||
server_name = node['sockethub']['nginx']['server_name']
|
||||
|
||||
nginx_post_hook = <<-EOF
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
systemctl reload nginx
|
||||
EOF
|
||||
|
||||
file "/etc/letsencrypt/renewal-hooks/post/nginx" do
|
||||
content nginx_post_hook
|
||||
mode 0755
|
||||
owner "root"
|
||||
group "root"
|
||||
end
|
||||
|
||||
gandi_api_credentials = data_bag_item('credentials', 'gandi_api')
|
||||
|
||||
template "/root/gandi_dns_certbot_hook.sh" do
|
||||
variables gandi_api_key: gandi_api_credentials["key"]
|
||||
mode 0770
|
||||
end
|
||||
|
||||
# Generate a Let's Encrypt cert (only if no cert has been generated before).
|
||||
# The systemd timer will take care of renewing
|
||||
execute "letsencrypt cert for sockethub" do
|
||||
command "certbot certonly --manual --preferred-challenges dns --manual-public-ip-logging-ok --agree-tos --manual-auth-hook \"/root/gandi_dns_certbot_hook.sh auth\" --manual-cleanup-hook \"/root/gandi_dns_certbot_hook.sh cleanup\" --deploy-hook \"/etc/letsencrypt/renewal-hooks/post/nginx\" --email ops@kosmos.org -d #{server_name} -n"
|
||||
not_if do
|
||||
File.exist?("/etc/letsencrypt/live/#{server_name}/fullchain.pem")
|
||||
end
|
||||
end
|
||||
|
||||
template "#{node['nginx']['dir']}/sites-available/#{server_name}" do
|
||||
source 'nginx_conf_sockethub.erb'
|
||||
owner 'www-data'
|
||||
mode 0640
|
||||
variables sockethub_port: node['sockethub']['port'],
|
||||
sockethub_external_port: node['sockethub']['external_port'],
|
||||
server_name: server_name,
|
||||
ssl_cert: "/etc/letsencrypt/live/#{server_name}/fullchain.pem",
|
||||
ssl_key: "/etc/letsencrypt/live/#{server_name}/privkey.pem"
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
|
||||
nginx_site server_name do
|
||||
action :enable
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# Generated by Chef
|
||||
upstream _sockethub {
|
||||
server localhost:<%= @sockethub_port %>;
|
||||
server <%= @upstream_host %>:<%= @upstream_port %>;
|
||||
}
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
@@ -9,34 +8,25 @@ map $http_upgrade $connection_upgrade {
|
||||
}
|
||||
|
||||
server {
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
listen <%= @sockethub_external_port %> ssl http2;
|
||||
add_header Strict-Transport-Security "max-age=15768000";
|
||||
<% else -%>
|
||||
listen <%= @sockethub_external_port %>;
|
||||
<% end -%>
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
|
||||
server_name <%= @server_name %>;
|
||||
access_log "/var/log/nginx/<%= @domain %>.access.log" json;
|
||||
error_log "/var/log/nginx/<%= @domain %>.error.log";
|
||||
|
||||
access_log <%= node[:nginx][:log_dir] %>/sockethub.access.log json;
|
||||
error_log <%= node[:nginx][:log_dir] %>/sockethub.error.log warn;
|
||||
|
||||
# We might need real ETags, disable those for now
|
||||
gzip off;
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
|
||||
location / {
|
||||
# Increase number of buffers. Default is 8
|
||||
proxy_buffers 1024 8k;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_pass http://_sockethub;
|
||||
proxy_http_version 1.1;
|
||||
# Enable WebSockets
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
<% end -%>
|
||||
}
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"examples": false,
|
||||
"logging": {
|
||||
"level": "<%= @log_level %>",
|
||||
"file": ""
|
||||
},
|
||||
"public": {
|
||||
"protocol": "https",
|
||||
"host": "<%= @domain %>",
|
||||
"port": 443,
|
||||
"path": "/"
|
||||
},
|
||||
"redis": {
|
||||
"url": "redis://127.0.0.1:6379/0"
|
||||
},
|
||||
"sockethub": {
|
||||
"port": <%= @port.to_i %>,
|
||||
"host": "0.0.0.0",
|
||||
"path": "/sockethub",
|
||||
"trustProxy": 1
|
||||
},
|
||||
"credentialCheck": {
|
||||
"reconnectIpSource": "proxy",
|
||||
"proxyHeader": "x-forwarded-for"
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
|
||||
set -euf -o pipefail
|
||||
|
||||
# ************** USAGE **************
|
||||
#
|
||||
# Example usage (with this hook file saved in /root/):
|
||||
#
|
||||
# sudo su -
|
||||
# certbot certonly --manual --preferred-challenges dns --manual-public-ip-logging-ok --agree-tos -d "5apps.com" -d muc.5apps.com -d "xmpp.5apps.com" \
|
||||
# --manual-auth-hook "/root/letsencrypt_hook.sh auth" --manual-cleanup-hook "/root/letsencrypt_hook.sh cleanup"
|
||||
#
|
||||
# This hook requires configuration, continue reading.
|
||||
#
|
||||
# ************** CONFIGURATION **************
|
||||
#
|
||||
# GANDI_API_KEY: Your Gandi Live API key
|
||||
#
|
||||
# PROVIDER_UPDATE_DELAY:
|
||||
# How many seconds to wait after updating your DNS records. This may be required,
|
||||
# depending on how slow your DNS host is to begin serving new DNS records after updating
|
||||
# them via the API. 30 seconds is a safe default, but some providers can be very slow
|
||||
# (e.g. Linode).
|
||||
#
|
||||
# Defaults to 30 seconds.
|
||||
#
|
||||
GANDI_API_KEY="<%= @gandi_api_key %>"
|
||||
PROVIDER_UPDATE_DELAY=30
|
||||
|
||||
regex='.*\.(.*\..*)'
|
||||
if [[ $CERTBOT_DOMAIN =~ $regex ]]
|
||||
then
|
||||
DOMAIN="${BASH_REMATCH[1]}"
|
||||
else
|
||||
DOMAIN="${CERTBOT_DOMAIN}"
|
||||
fi
|
||||
|
||||
# To be invoked via Certbot's --manual-auth-hook
|
||||
function auth {
|
||||
curl -s -D- -H "Content-Type: application/json" \
|
||||
-H "X-Api-Key: ${GANDI_API_KEY}" \
|
||||
-d "{\"rrset_name\": \"_acme-challenge.${CERTBOT_DOMAIN}.\",
|
||||
\"rrset_type\": \"TXT\",
|
||||
\"rrset_ttl\": 3600,
|
||||
\"rrset_values\": [\"${CERTBOT_VALIDATION}\"]}" \
|
||||
"https://dns.api.gandi.net/api/v5/domains/${DOMAIN}/records"
|
||||
|
||||
|
||||
sleep ${PROVIDER_UPDATE_DELAY}
|
||||
}
|
||||
|
||||
# To be invoked via Certbot's --manual-cleanup-hook
|
||||
function cleanup {
|
||||
curl -s -X DELETE -H "Content-Type: application/json" \
|
||||
-H "X-Api-Key: ${GANDI_API_KEY}" \
|
||||
https://dns.api.gandi.net/api/v5/domains/${DOMAIN}/records/_acme-challenge.${CERTBOT_DOMAIN}./TXT
|
||||
}
|
||||
|
||||
HANDLER=$1; shift;
|
||||
if [ -n "$(type -t $HANDLER)" ] && [ "$(type -t $HANDLER)" = function ]; then
|
||||
$HANDLER "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user