37 lines
1.1 KiB
YAML
37 lines
1.1 KiB
YAML
|
---
|
||
|
|
||
|
# Load distribution specific variables
|
||
|
- include_vars: "{{ item }}"
|
||
|
with_first_found:
|
||
|
- "{{ role_path }}/vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||
|
- "{{ role_path }}/vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
|
||
|
- "{{ role_path }}/vars/{{ ansible_distribution }}.yml"
|
||
|
- "{{ role_path }}/vars/{{ ansible_os_family }}.yml"
|
||
|
tags: consul
|
||
|
|
||
|
- set_fact: consul_install_mode='none'
|
||
|
tags: consul
|
||
|
|
||
|
- name: Detect if consul is installed
|
||
|
stat: path=/usr/local/bin/consul
|
||
|
register: consul_bin
|
||
|
tags: consul
|
||
|
|
||
|
- when: not consul_bin.stat.exists
|
||
|
set_fact: consul_install_mode='install'
|
||
|
tags: consul
|
||
|
|
||
|
- when: consul_bin.stat.exists
|
||
|
block:
|
||
|
- name: Detect installed version
|
||
|
shell: /usr/local/bin/consul version | head -1 | perl -pe 's/Consul v(\d+(\.\d+)*)/$1/'
|
||
|
changed_when: False
|
||
|
register: consul_current_version
|
||
|
- set_fact: consul_current_version={{ consul_current_version.stdout }}
|
||
|
tags: consul
|
||
|
|
||
|
- when: consul_bin.stat.exists and consul_current_version != consul_version
|
||
|
set_fact: consul_install_mode='upgrade'
|
||
|
tags: consul
|
||
|
|