2020-08-20 04:02:35 +00:00
|
|
|
---
|
2020-08-21 04:26:07 +00:00
|
|
|
- name: ensure consul group
|
|
|
|
group:
|
|
|
|
name: consul
|
|
|
|
state: present
|
|
|
|
system: True
|
|
|
|
|
|
|
|
- name: ensure consul user
|
|
|
|
user:
|
|
|
|
name: consul
|
|
|
|
state: present
|
|
|
|
group: consul
|
|
|
|
system: True
|
|
|
|
|
|
|
|
- name: ensure consul config dir
|
|
|
|
file:
|
|
|
|
path: /usr/local/etc/consul.d/
|
|
|
|
state: directory
|
|
|
|
owner: consul
|
|
|
|
group: consul
|
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: ensure consul data dir
|
|
|
|
file:
|
|
|
|
path: /opt/consul
|
|
|
|
state: directory
|
|
|
|
owner: consul
|
|
|
|
group: consul
|
|
|
|
mode: 0755
|
|
|
|
|
2020-08-20 05:11:33 +00:00
|
|
|
- name: check consul version
|
|
|
|
shell:
|
|
|
|
cmd: "consul --version | head -1 | cut -d'v' -f2"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
changed_when: False
|
|
|
|
failed_when: False
|
|
|
|
register: installed_consul_version
|
2020-08-21 04:26:07 +00:00
|
|
|
check_mode: false
|
2020-08-20 05:11:33 +00:00
|
|
|
|
|
|
|
- name: get consul
|
2020-08-21 04:26:07 +00:00
|
|
|
pkgng:
|
|
|
|
name: consul-{{ consul_version }}
|
|
|
|
state: present
|
2020-08-20 05:11:33 +00:00
|
|
|
|
2020-08-21 04:26:07 +00:00
|
|
|
- name: template consul config
|
|
|
|
template:
|
|
|
|
src: templates/consul.hcl.j2
|
|
|
|
dest: /usr/local/etc/consul.d/consul.hcl
|
2020-08-20 05:11:33 +00:00
|
|
|
owner: root
|
2020-08-20 17:49:46 +00:00
|
|
|
group: staff
|
2020-08-21 04:26:07 +00:00
|
|
|
mode: 0755
|
|
|
|
notify: restart_consul_fbsd
|
|
|
|
|
|
|
|
- name: enable and start consul
|
|
|
|
service:
|
|
|
|
name: consul
|
|
|
|
state: started
|
|
|
|
enabled: yes
|