Home

Awesome

Etcd Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

The Etcd Cookbook is a library cookbook that provides custom resources for use in recipes.

Scope

This cookbook is concerned with the Etcd distributed key/value store as distributed by CoreOS, Inc.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Platform Support

The following platforms have been tested with Test Kitchen. It will most likely work on other platforms as well

|---------------+--------+
|               | 3.2.15 |
|---------------+--------+
| amazonlinux 2 |   X    |
|---------------+--------+
| centos-7      |   X    |
|---------------+--------+
| debian-9      |   X    |
|---------------+--------+
| debian-10     |   X    |
|---------------+--------+
| fedora        |   X    |
|---------------+--------+
| ubuntu-16.04  |   X    |
|---------------+--------+
| ubuntu-18.04  |   X    |
|---------------+--------+
| ubuntu-20.04  |   X    |
|---------------+--------+
| opensuse-leap |   X    |
|---------------+--------+

Cookbook Dependencies

Usage

etcd_service 'etcd0' do
  advertise_client_urls 'http://127.0.0.1:2379'
  listen_client_urls 'http://0.0.0.0:2379'
  initial_advertise_peer_urls 'http://127.0.0.1:2380'
  listen_peer_urls 'http://0.0.0.0:2380'
  initial_cluster_token 'etcd-cluster-1'
  initial_cluster 'etcd0=http://127.0.0.1:2380,etcd1=http://127.0.0.1:3380,etcd2=http://127.0.0.1:4380'
  initial_cluster_state 'new'
  action :start
  ignore_failure true # required for the first cluster build
end

etcd_service 'etcd1' do
  advertise_client_urls 'http://127.0.0.1:3379'
  listen_client_urls 'http://0.0.0.0:3379'
  initial_advertise_peer_urls 'http://127.0.0.1:3380'
  listen_peer_urls 'http://0.0.0.0:3380'
  initial_cluster_token 'etcd-cluster-1'
  initial_cluster 'etcd0=http://127.0.0.1:2380,etcd1=http://127.0.0.1:3380,etcd2=http://127.0.0.1:4380'
  initial_cluster_state 'new'
  action :start
  ignore_failure true
end

etcd_service 'etcd2' do
  advertise_client_urls 'http://127.0.0.1:4379'
  listen_client_urls 'http://0.0.0.0:4379'
  initial_advertise_peer_urls 'http://127.0.0.1:4380'
  listen_peer_urls 'http://0.0.0.0:4380'
  initial_cluster_token 'etcd-cluster-1'
  initial_cluster 'etcd0=http://127.0.0.1:2380,etcd1=http://127.0.0.1:3380,etcd2=http://127.0.0.1:4380'
  initial_cluster_state 'new'
  action :start
  ignore_failure true
end

By default reosource creates etcd-NODE_NAME unit file name. Sometimes it's not comfortable.

If you don't run multi etcd service in node, you can change this action to default service name.

etcd_service 'etcd' do
  action :start
  default_service_name true
...
end

Test Cookbooks as Examples

The cookbooks ran under test-kitchen make excellent usage examples.

The test recipes are found at:

test/cookbooks/etcd_test/

Resources Overview

Resources Details

etcd_installation

The etcd_installation resource auto-selects one of the below resources with the provider resolution system. Defaults to binary installation.

Example

etcd_installation 'default' do
  action :create
end

etcd_installation_binary

The etcd_installation_binary resource copies the precompiled Go binary onto the disk.

Example

etcd_installation_binary 'default' do
  version '3.2.6'
  source 'https://my.computers.biz/dist/etcd'
  checksum '90aff7364caa43932fd46974825af20e0ecb70fe7e01981e2d3a496106f147e7'
  action :create
end

etcd_installation_docker

The etcd_installation_docker resource uses the docker_image resource to pull an image to the DOCKER_HOST.

Properties

etcd_service_manager

The etcd_service_manager resource auto-selects one of the below resources with the provider resolution system. The etcd_service family all share a common set of properties, which are listed under the etcd_service composite resource.

Warning

etcd startup behavior is a bit quirky. etcd loops indefinitely on startup until quorum can be established. Due to this the first nodes service start will fail unless all nodes come up at the same time. Due to this there is an ignore_failure property for the systemd service managers which allows you to continue on in the chef run if the service fails to start. systemd will automatically keep restarting the service until all nodes are up and the cluster is healthy. For sys-v init you're on your own.

Example

etcd_service_manager 'default' do
  action :start
end

properties

etcd_service_manager_systemd

Example

etcd_service_manager_systemd 'default' do
  action :start
end

properties

etcd_service_manager_docker

Example

etcd_service_manager_docker 'default' do
  action :start
end

properties

etcd_service

The etcd_service: resource is a composite resource that uses etcd_installation and etcd_service_manager resources to install and manage the etcd service.

The service management strategy for the host platform is dynamically chosen based on platform, but can be overridden.

Properties

The etcd_service resource property list corresponds to the options found in

Etcd Configuration Flags documentation

Member properties
Clustering properties
Proxy properties
Security properties
Logging properties
Profiling properties
Auth Flpropertiesags
Unsafe properties
Misc properties

etcd_key

The etcd_key resource sets, watches and deletes keys in etcd.

Actions

Properties

Examples

etcd_key "/test" do
  value "a_test_value"
  action :set
end

Contributors

This project exists thanks to all the people who contribute.

Additional Contributors

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

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

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website