Skip to content

Commit

Permalink
Change consul cluster check logic (#9)
Browse files Browse the repository at this point in the history
* Change consul cluster check logic

---------

Co-authored-by: Carlos Gonzalez <[email protected]>
  • Loading branch information
carlosgo13 and Carlos Gonzalez authored Jun 5, 2024
1 parent f5acf0c commit 01c34aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: nephelaiio
name: consul
version: 0.0.8
version: 0.0.9
readme: README.md
authors:
- Ted Cook <[email protected]>
Expand Down
52 changes: 21 additions & 31 deletions playbooks/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,25 @@
ansible.builtin.reboot:
reboot_timeout: "{{ consul_reboot_timeout | default(300) }}"

- name: Verify Consul cluster status
block:
- name: Query Consul node cluster status
ansible.builtin.shell: "consul members listNode | grep {{ inventory_hostname }} | awk '{print $3}'"
register: _consul_node_status
changed_when: false
no_log: true
- name: Query Consul node cluster status
ansible.builtin.shell: "consul members listNode | grep {{ inventory_hostname }} | awk '{print $3}'"
vars:
_status: "{{ _consul_node_status.stdout }}"
_expected: 'alive'
register: _consul_node_status
retries: "{{ consul_task_retries | default('10') }}"
delay: "{{ consul_task_delay | default('10') }}"
until: _status == _expected
changed_when: false
no_log: true

- name: Check Consul node cluster status
ansible.builtin.assert:
that: _status == _expected
fail_msg: "Expected consul node type '{{ _expected }}', got '{{ _status }}'"
success_msg: "Consul node type is '{{ _status }}'"
vars:
_status: "{{ _consul_node_status.stdout }}"
_expected: 'alive'

- name: Verify Consul node type status
block:
- name: Query consul node cluster status
ansible.builtin.shell: "consul members listNode | grep {{ inventory_hostname }} | awk '{print $4}'"
register: _consul_node_type
changed_when: false

- name: Check consul node cluster status
ansible.builtin.assert:
that: _status == _expected
fail_msg: "Expected consul node type '{{ _expected }}', got '{{ _status }}'"
success_msg: "Consul node type is '{{ _status }}'"
vars:
_status: "{{ _consul_node_type.stdout }}"
_expected: 'server'
- name: Query consul node cluster status
ansible.builtin.shell: "consul members listNode | grep {{ inventory_hostname }} | awk '{print $4}'"
vars:
_status: "{{ _consul_node_type.stdout }}"
_expected: 'server'
register: _consul_node_type
retries: "{{ consul_task_retries | default('10') }}"
delay: "{{ consul_task_delay | default('10') }}"
until: _status == _expected
changed_when: false

0 comments on commit 01c34aa

Please sign in to comment.