Chef coookbook to install and manage Twemproxy.
None.
- Centos 6+
- RedHat 6+
This cookbook can be used both by including its recipes and being attribute-driven or simply by calling the available providers within your own cookbook.
Attribute | Type | Description | Options | Default |
---|---|---|---|---|
['twemproxy']['mirror'] | String | Artifact mirror | - | https://github.com/twitter/twemproxy/archive |
['twemproxy']['version'] | String | Artifact version | - | v0.4.1 |
['twemproxy']['file_name'] | String | Artifact name | Defaults to nil since it fetches from the github archives. | nil |
['twemproxy']['artifact_type'] | String | Artifact type | - | tar.gz |
<['twemproxy']['update_config']/tt> | TrueClass/FalseClass | Manage twemproxy configs after the initial run - you want to disable this is you update configs via sentinels | - | true |
<['twemproxy']['config_dir']/tt> | String | Config directory | - | /etc/nutcracker |
<['twemproxy']['log_dir']/tt> | String | Log directory | - | /var/log/nutcracker |
<['twemproxy']['pid_dir']/tt> | String | PID directory | - | /var/run/nutcracker |
<['twemproxy']['user']/tt> | String | User to run as | - | nutcracker |
<['twemproxy']['group']/tt> | String | Group to run as | - | nutcracker |
<['twemproxy']['config']/tt> | String | Config hash to be converted as the yaml nutcracker configuration file | Required - the run will fail if you don't set this attribute - be warned! | nil |
All of this cookbook recipes use the available providers under the hood as described below in the providers section.
Installs, configures and enable/starts the twemproxy service.
Install twemproxy by compiling it from a source artifact.
Configure twemproxy by doing all the system required tasks (create users, create directories, etc.) and build the yaml configuration file.
Set twemproxy as a service and enable/start it.
Add the twemproxy
cookbook as a dependency:
depends 'twemproxy'
Set a twemproxy config as:
default['twemproxy']['config'] = {
'default' => {
'listen' => '0.0.0.0:6379',
'hash' => 'fnv1a_64',
'distribution' => 'ketama',
'auto_eject_hosts' => false,
'redis' => true,
'preconnect' => true,
'server_retry_timeout' => 2000,
'server_failure_limit' => 1,
'servers' => [
'172.31.254.103:6380:1 redis_1',
]
}
}
Include the twemproxy::default
recipe:
include_recipe 'twemproxy::default'
Include the twemproxy::install
and twemproxy::configure
recipe:
include_recipe 'twemproxy::install'
include_recipe 'twemproxy::configure'
The twemproxy_install
provider downloads and install twemproxy from a source artifact.
It does not configure or starts it.
It only has a default :run
action available.
The majority of the available attributes mimic the node attributes used by the recipes above.
Attribute | Type | Required |
---|---|---|
mirror | String | No |
version | String | No |
file_name | String | No |
download_dir | String | No |
artifact_type | String | No |
Install twemproxy
with the default options:
twemproxy_install 'twemproxy'
Install twemproxy
by providing the download options:
twemproxy_install 'twemproxy' do
mirror 'https://github.com/twitter/twemproxy/archive''
version 'v0.4.1'
file_name ''
download_dir '/var/tmp'
artifact_type 'tar.gz'
end
The twemproxy_twemproxy
provider performs all the required system tasks and deploys the yaml configuration file.
It does not install or starts it.
It only has a default :run
action available.
The majority of the available attributes mimic the node attributes used by the recipes above.
Attribute | Type | Required |
---|---|---|
config | Hash | Yes |
update_config | TrueClass/FalseClass | No |
config_dir | String | No |
log_dir | String | No |
pid_dir | String | No |
user | String | No |
group | String | No |
Configure twemproxy
with the default options and the provided config:
twemproxy_configuration 'twemproxy' do
config config_hash
end
The twemproxy_service
provider performs all the required system tasks to start and/or enable twemproxy as a service.
It deploys a sysV init script - feel free to add support for other init systems and PR your changes.
It does not install or configure it.
It has a default :run
action available which is the equivalent to using the [:enable, :restart]
actions.
Available actions:
Actions | Description |
---|---|
:run | Default action - enable and restarts the service |
:enable | Enable the service |
:start | Start the service |
:restart | Restart the service |
The majority of the available attributes mimic the node attributes used by the recipes above.
Attribute | Type | Required |
---|---|---|
config_dir | String | No |
log_dir | String | No |
pid_dir | String | No |
user | String | No |
Enable and restart twemproxy
service with the default options:
twemproxy_service 'twemproxy'
Enable and restart twemproxy
service with custom options:
twemproxy_service 'twemproxy' do
config_dir '/etc/nutcracker'
log_dir '/var/log/nutcracker'
pid_dir '/var/run/nutcracker'
user 'nutcracker'
end
$ git clone git@github.com:Mindera/twemproxy-cookbook.git
$ cd twemproxy-cookbook
$ bundle install
To run unit tests (chefspec):
$ bundle exec rake unit
To run lint tests (rubocop, foodcritic):
$ bundle exec rake lint
To run integration tests (kitchen-ci, serverspec):
$ bundle exec rake integration