Skip to content

Commit

Permalink
Merge pull request #248 from eliasp/check-mode-dont-fail
Browse files Browse the repository at this point in the history
Further check mode fixes
  • Loading branch information
MonolithProjects committed Sep 18, 2024
2 parents 09bd728 + 18cd57c commit 10fe5d9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tasks/change_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
delay: 15
delegate_to: "{{ active_server | default(groups[rke2_servers_group_name].0) }}"
run_once: true
when: not ansible_check_mode

- name: Wait for all pods to be ready again
ansible.builtin.shell: |
Expand All @@ -34,4 +35,6 @@
delay: 15
delegate_to: "{{ active_server | default(groups[rke2_servers_group_name].0) }}"
run_once: true
when: rke2_wait_for_all_pods_to_be_ready
when:
- not ansible_check_mode
- rke2_wait_for_all_pods_to_be_ready
12 changes: 9 additions & 3 deletions tasks/first_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
--token {{ rke2_token }}
register: task_output # <- Registers the command output.
changed_when: task_output.rc != 0 # <- Uses the return code to define when the task has changed.
when: not ansible_check_mode

- name: Restore etcd from s3
when: do_etcd_restore_from_s3 is defined
Expand All @@ -86,6 +87,7 @@
--token {{ rke2_token }}
register: task_output # <- Registers the command output.
changed_when: task_output.rc != 0 # <- Uses the return code to define when the task has changed.
when: not ansible_check_mode

- name: Start RKE2 service on the first server
ansible.builtin.systemd:
Expand Down Expand Up @@ -116,7 +118,9 @@
- ('"cni plugin not initialized" in node_status.stdout' or '"kubelet is posting ready status." in node_status.stdout')
retries: 100
delay: 15
when: rke2_cni == 'none'
when:
- not ansible_check_mode
- rke2_cni == 'none'

- name: Wait for the first server be ready - with CNI
ansible.builtin.shell: |
Expand All @@ -130,7 +134,9 @@
'" Ready " in first_server.stdout'
retries: 40
delay: 15
when: rke2_cni != 'none'
when:
- not ansible_check_mode
- rke2_cni != 'none'

- name: Restore etcd - remove old <node>.node-password.rke2 secrets
ansible.builtin.shell: |
Expand All @@ -140,7 +146,7 @@
executable: /bin/bash
with_items: "{{ groups[rke2_cluster_group_name] }}"
changed_when: false
when: inventory_hostname != item and (do_etcd_restore is defined or do_etcd_restore_from_s3 is defined)
when: not ansible_check_mode and inventory_hostname != item and (do_etcd_restore is defined or do_etcd_restore_from_s3 is defined)

- name: Set an Active Server variable
ansible.builtin.set_fact:
Expand Down
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- name: Restore etcd specific tasks
ansible.builtin.include_tasks: first_server_restore.yml
when:
- active_server is defined
- inventory_hostname == active_server or inventory_hostname == groups[rke2_servers_group_name].0
- do_etcd_restore is defined or do_etcd_restore_from_s3 is defined

Expand All @@ -72,7 +73,9 @@
loop_var: _host_item
when:
- hostvars[_host_item].inventory_hostname == inventory_hostname
- installed_version is defined
- installed_version != "not installed"
- rke2_version is defined
- rke2_version != running_version

- name: Flush handlers
Expand Down
1 change: 1 addition & 0 deletions tasks/remaining_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@
retries: 100
delay: 15
when:
- not ansible_check_mode
- rke2_cni != 'none'
- inventory_hostname == active_server or inventory_hostname == groups[rke2_servers_group_name].0
4 changes: 2 additions & 2 deletions tasks/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- ('"cni plugin not initialized" in node_status.stdout' or '"kubelet is posting ready status." in node_status.stdout')
retries: 100
delay: 15
when: rke2_cni == 'none'
when: not ansible_check_mode and rke2_cni == 'none'

- name: Wait for the first server be ready - with CNI
ansible.builtin.shell: |
Expand All @@ -64,4 +64,4 @@
- '" Ready " in first_server.stdout'
retries: 40
delay: 15
when: rke2_cni != 'none'
when: not ansible_check_mode rke2_cni != 'none'
1 change: 1 addition & 0 deletions tasks/summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
delegate_to: localhost
become: false
when:
- not ansible_check_mode
- rke2_download_kubeconf | bool

- name: Summary
Expand Down

0 comments on commit 10fe5d9

Please sign in to comment.