2016-04-22 08:35:04 -04:00
|
|
|
{% from "consul/map.jinja" import consul with context %}
|
2015-10-22 15:29:19 -04:00
|
|
|
|
2016-04-08 06:35:36 -04:00
|
|
|
consul-dep-unzip:
|
|
|
|
pkg.installed:
|
|
|
|
- name: unzip
|
2015-10-22 15:29:19 -04:00
|
|
|
|
2016-04-08 06:35:36 -04:00
|
|
|
consul-bin-dir:
|
2015-10-22 15:29:19 -04:00
|
|
|
file.directory:
|
2016-04-08 06:35:36 -04:00
|
|
|
- name: /usr/local/bin
|
2015-10-22 15:29:19 -04:00
|
|
|
- makedirs: True
|
|
|
|
|
|
|
|
# Create consul user
|
|
|
|
consul-user:
|
|
|
|
group.present:
|
|
|
|
- name: consul
|
|
|
|
user.present:
|
|
|
|
- name: consul
|
|
|
|
- createhome: false
|
|
|
|
- system: true
|
|
|
|
- groups:
|
|
|
|
- consul
|
|
|
|
- require:
|
|
|
|
- group: consul
|
|
|
|
|
|
|
|
# Create directories
|
|
|
|
consul-config-dir:
|
|
|
|
file.directory:
|
|
|
|
- name: /etc/consul.d
|
|
|
|
- user: consul
|
|
|
|
- group: consul
|
|
|
|
|
|
|
|
consul-runtime-dir:
|
|
|
|
file.directory:
|
|
|
|
- name: /var/consul
|
|
|
|
- user: consul
|
|
|
|
- group: consul
|
|
|
|
|
|
|
|
consul-data-dir:
|
|
|
|
file.directory:
|
|
|
|
- name: /usr/local/share/consul
|
|
|
|
- user: consul
|
|
|
|
- group: consul
|
2016-04-22 06:40:14 -04:00
|
|
|
- makedirs:
|
|
|
|
|
2015-10-22 15:29:19 -04:00
|
|
|
# Install agent
|
|
|
|
consul-download:
|
|
|
|
file.managed:
|
2016-01-11 18:48:06 -05:00
|
|
|
- name: /tmp/consul_{{ consul.version }}_linux_amd64.zip
|
|
|
|
- source: https://releases.hashicorp.com/consul/{{ consul.version }}/consul_{{ consul.version }}_linux_amd64.zip
|
|
|
|
- source_hash: sha256={{ consul.hash }}
|
2015-10-22 15:29:19 -04:00
|
|
|
- unless: test -f /usr/local/bin/consul-{{ consul.version }}
|
|
|
|
|
|
|
|
consul-extract:
|
|
|
|
cmd.wait:
|
2016-01-11 18:48:06 -05:00
|
|
|
- name: unzip /tmp/consul_{{ consul.version }}_linux_amd64.zip -d /tmp
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-download
|
|
|
|
|
|
|
|
consul-install:
|
|
|
|
file.rename:
|
|
|
|
- name: /usr/local/bin/consul-{{ consul.version }}
|
|
|
|
- source: /tmp/consul
|
|
|
|
- require:
|
|
|
|
- file: /usr/local/bin
|
|
|
|
- watch:
|
|
|
|
- cmd: consul-extract
|
|
|
|
|
|
|
|
consul-clean:
|
|
|
|
file.absent:
|
2016-01-11 18:48:06 -05:00
|
|
|
- name: /tmp/consul_{{ consul.version }}_linux_amd64.zip
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-install
|
|
|
|
|
|
|
|
consul-link:
|
|
|
|
file.symlink:
|
|
|
|
- target: consul-{{ consul.version }}
|
|
|
|
- name: /usr/local/bin/consul
|
|
|
|
- watch:
|
|
|
|
- file: consul-install
|
|
|
|
|
|
|
|
# Install UI
|
|
|
|
consul-ui-download:
|
|
|
|
file.managed:
|
2016-01-11 18:48:06 -05:00
|
|
|
- name: /tmp/consul_{{ consul.ui_version }}_web_ui.zip
|
|
|
|
- source: https://releases.hashicorp.com/consul/{{ consul.version }}/consul_{{ consul.ui_version }}_web_ui.zip
|
|
|
|
- source_hash: sha256={{ consul.ui_hash }}
|
2015-10-22 15:29:19 -04:00
|
|
|
- unless: test -d /usr/local/share/consul/ui-{{ consul.ui_version }}
|
|
|
|
|
|
|
|
consul-ui-extract:
|
|
|
|
cmd.wait:
|
2016-01-11 18:48:06 -05:00
|
|
|
- name: unzip /tmp/consul_{{ consul.ui_version }}_web_ui.zip -d /tmp/dist
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-ui-download
|
|
|
|
|
|
|
|
consul-ui-install:
|
|
|
|
file.rename:
|
|
|
|
- name: /usr/local/share/consul/ui-{{ consul.ui_version }}
|
|
|
|
- source: /tmp/dist
|
|
|
|
- require:
|
|
|
|
- file: /usr/local/share/consul
|
|
|
|
- watch:
|
|
|
|
- cmd: consul-ui-extract
|
|
|
|
|
|
|
|
consul-ui-clean:
|
|
|
|
file.absent:
|
2016-01-11 18:48:06 -05:00
|
|
|
- name: /tmp/consul_{{ consul.ui_version }}_web_ui.zip
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-ui-install
|
|
|
|
|
|
|
|
consul-ui-link:
|
|
|
|
file.symlink:
|
|
|
|
- target: ui-{{ consul.ui_version }}
|
|
|
|
- name: /usr/local/share/consul/ui
|
|
|
|
- watch:
|
|
|
|
- file: consul-ui-install
|