From 6993db729d10ffa53a76e7bfe20d644dffc5271e Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 13:40:51 -0700 Subject: [PATCH 1/7] Adds support for bootstrap-expect configuration and kitchen suites. --- .kitchen.yml | 7 +++++++ README.md | 8 +++++++- attributes/default.rb | 1 + metadata.rb | 2 +- recipes/_service.rb | 4 ++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index 5b72bbcd..e55d087d 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -43,3 +43,10 @@ suites: consul: serve_ui: true client_interface: eth0 + - name: cluster + run_list: + - recipe[consul::default] + attributes: + consul: + service_mode: cluster + bootstrap_expect: 1 diff --git a/README.md b/README.md index 837ebcc7..dabf6af8 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,13 @@ Installs and configures [Consul][1]. ['consul']['service_mode'] String - Mode to run consul as: bootstrap, server, or client + Mode to run consul as: bootstrap, bootstrap-cluster, server, or client + bootstrap + + + ['consul'][bootstrap_expect] + String + When bootstrapping a cluster, the number of server nodes to expect. bootstrap diff --git a/attributes/default.rb b/attributes/default.rb index 7ed69d6a..329dc648 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -42,6 +42,7 @@ default['consul']['service_user'] = 'consul' default['consul']['service_group'] = 'consul' + # Optionally bind to a specific interface default['consul']['bind_interface'] = nil default['consul']['advertise_interface'] = nil diff --git a/metadata.rb b/metadata.rb index 7f33ff63..ce1cf1bb 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache v2.0' description 'Installs/Configures consul' long_description 'Installs/Configures consul' -version '0.4.1' +version '0.4.2' recipe 'consul', 'Installs and starts consul service.' recipe 'consul::install_binary', 'Installs consul service from binary.' diff --git a/recipes/_service.rb b/recipes/_service.rb index 3ddb20b5..49b0f0e2 100644 --- a/recipes/_service.rb +++ b/recipes/_service.rb @@ -19,6 +19,7 @@ # Configure directories consul_directories = [] +consul_directories << node['consul']['data_dir'] consul_directories << node['consul']['config_dir'] consul_directories << '/var/lib/consul' @@ -69,6 +70,9 @@ when 'bootstrap' service_config['server'] = true service_config['bootstrap'] = true +when 'cluster' + service_config['server'] = true + service_config['bootstrap_expect'] = node['consul']['bootstrap_expect'] when 'server' service_config['server'] = true service_config['start_join'] = node['consul']['servers'] From d68127ccb75ce97c7679c918df0924a37f08b620 Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 14:03:22 -0700 Subject: [PATCH 2/7] Adds logic for handling a bootstrap-expect of 1. --- recipes/_service.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes/_service.rb b/recipes/_service.rb index 49b0f0e2..41d5f46e 100644 --- a/recipes/_service.rb +++ b/recipes/_service.rb @@ -66,13 +66,18 @@ service_config = {} service_config['data_dir'] = node['consul']['data_dir'] +num_cluster = node['consul']['bootstrap_expect'] case node['consul']['service_mode'] when 'bootstrap' service_config['server'] = true service_config['bootstrap'] = true when 'cluster' service_config['server'] = true - service_config['bootstrap_expect'] = node['consul']['bootstrap_expect'] + if num_cluster > 1 + service_config['bootstrap_expect'] = num_cluster + else + service_config['bootstrap'] = true + end when 'server' service_config['server'] = true service_config['start_join'] = node['consul']['servers'] From a1c987a8b84fe06fac46938ea5b0e1b855bb14f7 Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 14:04:47 -0700 Subject: [PATCH 3/7] Bumps version number. --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index ce1cf1bb..19d6307a 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache v2.0' description 'Installs/Configures consul' long_description 'Installs/Configures consul' -version '0.4.2' +version '0.4.3' recipe 'consul', 'Installs and starts consul service.' recipe 'consul::install_binary', 'Installs consul service from binary.' From 78495f7e9f68680f8dc7cf3a7517d1c6079eb67f Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 14:46:48 -0700 Subject: [PATCH 4/7] Moves casting to before case statement. Updates readme. --- README.md | 2 +- recipes/_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dabf6af8..4f501186 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Installs and configures [Consul][1]. ['consul']['service_mode'] String - Mode to run consul as: bootstrap, bootstrap-cluster, server, or client + Mode to run consul as: bootstrap, cluster, server, or client bootstrap diff --git a/recipes/_service.rb b/recipes/_service.rb index 41d5f46e..3e5dce74 100644 --- a/recipes/_service.rb +++ b/recipes/_service.rb @@ -65,8 +65,8 @@ # Determine service params service_config = {} service_config['data_dir'] = node['consul']['data_dir'] +num_cluster = node['consul']['bootstrap_expect'].to_i -num_cluster = node['consul']['bootstrap_expect'] case node['consul']['service_mode'] when 'bootstrap' service_config['server'] = true From 3416411443dd4df59646cea81914918510623c95 Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 14:46:48 -0700 Subject: [PATCH 5/7] Moves casting to before case statement. Updates readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f501186..71146495 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Installs and configures [Consul][1]. ['consul'][bootstrap_expect] String When bootstrapping a cluster, the number of server nodes to expect. - bootstrap + ['consul']['data_dir'] From ea0d50786545839d6c8abba55f1626c446beb5ac Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 14:46:48 -0700 Subject: [PATCH 6/7] Moves casting to before case statement. Updates readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71146495..f872db40 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Installs and configures [Consul][1]. ['consul'][bootstrap_expect] String When bootstrapping a cluster, the number of server nodes to expect. - + nil ['consul']['data_dir'] From c09dbfdd929582a9c3ab0490038eb20bb5e0239b Mon Sep 17 00:00:00 2001 From: Erik Blas Date: Sat, 6 Sep 2014 14:55:45 -0700 Subject: [PATCH 7/7] Whitespace cleanup and getting the cookbook version in sync. --- attributes/default.rb | 1 - metadata.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 329dc648..7ed69d6a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -42,7 +42,6 @@ default['consul']['service_user'] = 'consul' default['consul']['service_group'] = 'consul' - # Optionally bind to a specific interface default['consul']['bind_interface'] = nil default['consul']['advertise_interface'] = nil diff --git a/metadata.rb b/metadata.rb index 19d6307a..ce1cf1bb 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache v2.0' description 'Installs/Configures consul' long_description 'Installs/Configures consul' -version '0.4.3' +version '0.4.2' recipe 'consul', 'Installs and starts consul service.' recipe 'consul::install_binary', 'Installs consul service from binary.'