mirror of
https://github.com/natelandau/ansible-homelab-config.git
synced 2025-11-18 01:43:40 -05:00
Improve version checking
Adopt the Ansible conditional checking format of `when: var1 is version(var2, '<') as explained here: https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#comparing-versions
This commit is contained in:
@@ -50,6 +50,11 @@
|
|||||||
consul_download_uri: "https://releases.hashicorp.com/consul/{{ consul_version }}/consul_{{ consul_version }}_darwin_amd64.zip"
|
consul_download_uri: "https://releases.hashicorp.com/consul/{{ consul_version }}/consul_{{ consul_version }}_darwin_amd64.zip"
|
||||||
when: mac_intel
|
when: mac_intel
|
||||||
|
|
||||||
|
- name: "set variable: Set Consul download Binary (MacOSX)"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
consul_download_uri: "https://releases.hashicorp.com/consul/{{ consul_version }}/consul_{{ consul_version }}_darwin_arm64.zip"
|
||||||
|
when: mac_arm
|
||||||
|
|
||||||
- name: Assert that we can install Consul
|
- name: Assert that we can install Consul
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -227,7 +232,7 @@
|
|||||||
- not consul_binary_file_location.stat.exists
|
- not consul_binary_file_location.stat.exists
|
||||||
|
|
||||||
- name: Check current version of Consul
|
- name: Check current version of Consul
|
||||||
ansible.builtin.command:
|
ansible.builtin.shell:
|
||||||
cmd: /usr/local/bin/consul --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'
|
cmd: /usr/local/bin/consul --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@@ -243,7 +248,7 @@
|
|||||||
when:
|
when:
|
||||||
- consul_download_uri is defined
|
- consul_download_uri is defined
|
||||||
- not need_consul_install
|
- not need_consul_install
|
||||||
- installed_consul_version.stdout != consul_version
|
- installed_consul_version.stdout is version(consul_version, '<')
|
||||||
|
|
||||||
- name: install Consul
|
- name: install Consul
|
||||||
become: true
|
become: true
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
- name: Install or Update Nomad
|
- name: Install or Update Nomad
|
||||||
block:
|
block:
|
||||||
- name: "set fact: do we need a nomad install?"
|
- name: "set fact: do we need a nomad install?"
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
need_nomad_install: false
|
need_nomad_install: false
|
||||||
|
|
||||||
- name: Check if nomad is installed
|
- name: Check if nomad is installed
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
register: nomad_binary_file_location
|
register: nomad_binary_file_location
|
||||||
|
|
||||||
- name: "set fact: do we need a nomad install"
|
- name: "set fact: do we need a nomad install"
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
need_nomad_install: true
|
need_nomad_install: true
|
||||||
when:
|
when:
|
||||||
- not nomad_binary_file_location.stat.exists
|
- not nomad_binary_file_location.stat.exists
|
||||||
@@ -186,15 +186,15 @@
|
|||||||
- not need_nomad_install
|
- not need_nomad_install
|
||||||
|
|
||||||
- name: "set fact: do we need a nomad install"
|
- name: "set fact: do we need a nomad install"
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
need_nomad_install: true
|
need_nomad_install: true
|
||||||
when:
|
when:
|
||||||
- not need_nomad_install
|
- not need_nomad_install
|
||||||
- current_nomad_version.stdout != nomad_version
|
- current_nomad_version.stdout is version(nomad_version, '<')
|
||||||
|
|
||||||
- name: install Nomad
|
- name: install Nomad
|
||||||
become: true
|
become: true
|
||||||
unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "{{ nomad_download_file_uri }}"
|
src: "{{ nomad_download_file_uri }}"
|
||||||
dest: /usr/local/bin
|
dest: /usr/local/bin
|
||||||
remote_src: true
|
remote_src: true
|
||||||
|
|||||||
Reference in New Issue
Block a user