Skip to content

Commit

Permalink
etcd: compatibility with check mode (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Sep 14, 2023
1 parent bf5e48d commit ff7713a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
loop:
- etcd
- etcdctl
when: installation_method == "repo" and etcd_package_repo | length > 0
when:
- installation_method == "repo"
- etcd_package_repo | length > 0
- not ansible_check_mode
tags: etcd, etcd_install

- block: # install etcd package from file
Expand All @@ -64,7 +67,10 @@
loop:
- etcd
- etcdctl
when: installation_method == "file" and etcd_package_file | length > 0
when:
- installation_method == "file"
- etcd_package_file | length > 0
- not ansible_check_mode
tags: etcd, etcd_install

- name: Add etcd user
Expand Down Expand Up @@ -123,17 +129,24 @@
ansible.builtin.command: >
/usr/local/bin/etcdctl endpoint health
--endpoints=http://{{ inventory_hostname }}:2379
environment:
ETCDCTL_API: "3"
register: etcd_health_result
until: "'is healthy' in etcd_health_result.stdout"
until: >
'is healthy' in etcd_health_result.stdout or
'is healthy' in etcd_health_result.stderr
retries: 10
delay: 10
changed_when: false
ignore_errors: false
check_mode: false

- name: cluster health
ansible.builtin.debug:
msg: "{{ etcd_health_result.stdout }}"
msg: >
{{ etcd_health_result.stdout
if etcd_health_result.stdout | length > 0
else etcd_health_result.stderr }}
when: not ansible_check_mode
tags: etcd, etcd_start, etcd_status

...

0 comments on commit ff7713a

Please sign in to comment.