---
|
|
- name: install consul in client mode latest centos
|
|
hosts: consul-clients
|
|
|
|
vars:
|
|
source_dir: "/opt/consul/"
|
|
|
|
tasks:
|
|
- name: check linux version
|
|
debug:
|
|
var: ansible_os_family
|
|
|
|
- name: create dirs
|
|
file: path={{ item }} state=directory
|
|
loop:
|
|
- /var/consul
|
|
- /etc/consul.d/
|
|
- /etc/consul.d/client
|
|
- /etc/consul.d/bootstrap
|
|
|
|
|
|
- name: move consul .service
|
|
copy: src={{ source_dir }}consul.service dest=/etc/systemd/system/consul.service
|
|
notify:
|
|
- restart consul centos
|
|
|
|
|
|
- name: move consul exec
|
|
copy: src={{ source_dir }}consul dest=/usr/local/bin/ mode=0755
|
|
notify:
|
|
- restart consul centos
|
|
|
|
- name: generate consul config
|
|
template: src={{ source_dir }}config.j2 dest=/etc/consul.d/config.json
|
|
notify:
|
|
- restart consul centos
|
|
|
|
|
|
- name: enable and start consul
|
|
service: name=consul state=started enabled=yes
|
|
|
|
handlers:
|
|
- name: restart consul centos
|
|
service: name=consul state=restarted
|
Powered by TurnKey Linux.