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/tasks/install_linux.yml b/tasks/install_linux.yml index 110ad04..cfcb9d0 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,28 +12,32 @@ - '{{consul_conf_dir}}' - '{{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 - 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 - 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' 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 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 %} }