From cadfb3a287828761fc356dcdc3d1f81817bf4b3d Mon Sep 17 00:00:00 2001 From: pietro Date: Sun, 2 Oct 2016 22:45:03 +0200 Subject: [PATCH 1/4] changed consul to 0.6.4 (with integrated ui) --- defaults/main.yml | 5 ++--- meta/.galaxy_install_info | 1 + tasks/install_linux.yml | 16 ++++------------ tasks/install_osx.yml | 13 +++---------- 4 files changed, 10 insertions(+), 25 deletions(-) create mode 100644 meta/.galaxy_install_info diff --git a/defaults/main.yml b/defaults/main.yml index bac4794..89aa79f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,12 +1,11 @@ # install related variables -consul_version: 0.4.1 +consul_version: 0.6.4 consul_dir: '/opt/consul_{{consul_version}}' consul_conf_dir: '{{consul_dir}}/conf.d' consul_data_dir: '{{consul_dir}}/data' consul_log_dir: '{{consul_dir}}/logs' consul_ui_dir: '{{consul_dir}}/dist' -consul_url: https://dl.bintray.com/mitchellh/consul/{{consul_version}} -consul_ui_url: https://dl.bintray.com/mitchellh/consul/{{consul_version}}_web_ui.zip +consul_url: https://releases.hashicorp.com/consul/{{consul_version}} consul_user: consul consul_group: consul consul_log_level: info diff --git a/meta/.galaxy_install_info b/meta/.galaxy_install_info new file mode 100644 index 0000000..78626ff --- /dev/null +++ b/meta/.galaxy_install_info @@ -0,0 +1 @@ +{install_date: 'Sun Oct 2 18:12:56 2016', version: master} diff --git a/tasks/install_linux.yml b/tasks/install_linux.yml index 110ad04..4cc336a 100644 --- a/tasks/install_linux.yml +++ b/tasks/install_linux.yml @@ -1,10 +1,7 @@ -- get_url: url='{{consul_url}}_linux_amd64.zip' dest=/tmp/consul.zip validate_certs=no - -- get_url: url='{{consul_ui_url}}' dest=/tmp/consul_ui.zip validate_certs=no - when: consul_server == true +- get_url: url='{{consul_url}}/consul_{{consul_version}}_linux_amd64.zip' dest=/tmp/consul.zip validate_certs=no - group: name={{consul_group}} - + - user: name={{consul_user}} group={{consul_group}} - name: create consul dir @@ -15,26 +12,21 @@ - '{{consul_conf_dir}}' - '{{consul_data_dir}}' - '{{consul_log_dir}}' - + - name: copy over distro agnostic unpack script template: src=unpack dest=/tmp/unpack mode=755 - name: unpack the consul archive command: /tmp/unpack /tmp/consul.zip {{consul_dir}}/bin -- name: unpack the consul_ui archive - command: /tmp/unpack /tmp/consul_ui.zip {{consul_dir}} - when: consul_server == true - - name: remove tmp consul zips file: path=/tmp/{{item}}.zip state=absent with_items: - - consul_ui - consul - name: make link to consul folder file: src='{{consul_dir}}' dest=/opt/consul state=link - + - name: make consul executable file: path="{{consul_dir}}/bin/consul" mode=755 diff --git a/tasks/install_osx.yml b/tasks/install_osx.yml index c21f07e..3e0945c 100644 --- a/tasks/install_osx.yml +++ b/tasks/install_osx.yml @@ -1,6 +1,4 @@ -- get_url: url='{{consul_url}}_darwin_amd64.zip' dest=/tmp/consul.zip validate_certs=no - -- get_url: url='{{consul_ui_url}}' dest=/tmp/consul_ui.zip validate_certs=no +- get_url: url='{{consul_url}}/consul_{{consul_version}}_darwin_amd64.zip' dest=/tmp/consul.zip validate_certs=no - name: create consul dir file: path={{item}} state=directory @@ -10,22 +8,17 @@ - '{{consul_conf_dir}}' - '{{consul_data_dir}}' - '{{consul_log_dir}}' - + - name: copy over distro agnostic unpack script template: src=unpack dest=/tmp/unpack mode=755 - name: unpack the consul archive command: /tmp/unpack /tmp/consul.zip {{consul_dir}}/bin -- name: unpack the consul_ui archive - command: /tmp/unpack /tmp/consul_ui.zip {{consul_dir}} - when: consul_server == true - - name: remove tmp consul zips file: path=/tmp/{{item}}.zip state=absent with_items: - - consul_ui - consul - + - name: make consul executable file: path="{{consul_dir}}/bin/consul" mode=755 From f15fc39412c5d0d6b7e126e5f74d56ebce948308 Mon Sep 17 00:00:00 2001 From: pietro Date: Sun, 2 Oct 2016 22:48:33 +0200 Subject: [PATCH 2/4] removed .galaxy_install_info --- meta/.galaxy_install_info | 1 - 1 file changed, 1 deletion(-) delete mode 100644 meta/.galaxy_install_info diff --git a/meta/.galaxy_install_info b/meta/.galaxy_install_info deleted file mode 100644 index 78626ff..0000000 --- a/meta/.galaxy_install_info +++ /dev/null @@ -1 +0,0 @@ -{install_date: 'Sun Oct 2 18:12:56 2016', version: master} From 4654b5da8ed9548a16a29379d63440f833e925a5 Mon Sep 17 00:00:00 2001 From: pietro Date: Mon, 3 Oct 2016 09:43:09 +0200 Subject: [PATCH 3/4] restructured wrongly placed parameters in consul config --- templates/connections.json | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/templates/connections.json b/templates/connections.json index 7c00547..f7ad7a8 100644 --- a/templates/connections.json +++ b/templates/connections.json @@ -11,9 +11,10 @@ "addresses": { {%if consul_dns_enabled %}"dns": "{{consul_dns_address}}",{% endif %} "http": "{{consul_http_address}}", - "rpc": "{{consul_rpc_address}}", - "advertise_addr": "{{consul_advertise_address}}" -}, + "rpc": "{{consul_rpc_address}}" + }, + +"advertise_addr": "{{consul_advertise_address}}", "client_addr": "{{consul_client_address}}", @@ -33,9 +34,10 @@ "dns_config": { "max_stale": "{{consul_dns_max_stale}}", "node_ttl": "{{consul_dns_node_ttl}}", - "enable_truncate": {{consul_dns_enable_truncate}}, - "domain": "{{consul_dns_domain}}" -}{% endif %} + "enable_truncate": {{consul_dns_enable_truncate}} +}, +"domain": "{{consul_dns_domain}}" +{% endif %} {%if consul_dns_recursor_enabled %}"recursor": "{{consul_dns_recursor}}",{% endif %} } From 0925da991a0d70f2a3190377038b59e4473f0c23 Mon Sep 17 00:00:00 2001 From: pietro Date: Mon, 3 Oct 2016 10:48:35 +0200 Subject: [PATCH 4/4] managed status of consul to have it eventually always running --- tasks/install_linux.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasks/install_linux.yml b/tasks/install_linux.yml index 4cc336a..cfcb9d0 100644 --- a/tasks/install_linux.yml +++ b/tasks/install_linux.yml @@ -13,6 +13,11 @@ - '{{consul_data_dir}}' - '{{consul_log_dir}}' +- name: stop consul (in case it's running, else data folder will be locked) + supervisorctl: name=consul state=stopped + when: consul_supervisor_enabled and not ansible_os_family == 'Darwin' + ignore_errors: yes + - name: copy over distro agnostic unpack script template: src=unpack dest=/tmp/unpack mode=755 @@ -32,3 +37,7 @@ - name: make consul available on the path command: update-alternatives --install "/usr/bin/consul" "consul" "{{consul_dir}}/bin/consul" 100 + +- name: restart consul (in case it was just stopped) + supervisorctl: name=consul state=restarted + when: consul_supervisor_enabled and not ansible_os_family == 'Darwin'