fix: make Ansible reruns faster and idempotent
Deploy Cluster / Terraform (push) Successful in 28s
Deploy Cluster / Ansible (push) Has been cancelled

This commit is contained in:
2026-04-24 11:44:11 +00:00
parent c89c31adea
commit 3f52bad854
4 changed files with 72 additions and 18 deletions
+16 -1
View File
@@ -45,9 +45,16 @@
state: present
lock_timeout: 600
- name: Check active swap
command: swapon --noheadings
register: active_swap
changed_when: false
failed_when: false
- name: Disable swap
command: swapoff -a
changed_when: true
when: active_swap.stdout | trim | length > 0
- name: Remove swap from fstab
lineinfile:
@@ -100,9 +107,17 @@
failed_when: false
when: tailscale_auth_key | length > 0
- name: Parse tailscale connection state
set_fact:
tailscale_backend_state: "{{ (tailscale_status.stdout | from_json).BackendState | default('') }}"
when:
- tailscale_auth_key | length > 0
- tailscale_status.rc == 0
- tailscale_status.stdout | length > 0
- name: Connect node to tailnet
command: tailscale up --authkey {{ tailscale_auth_key }} --hostname {{ inventory_hostname }} --ssh={{ tailscale_ssh | ternary('true', 'false') }} --accept-routes={{ tailscale_accept_routes | ternary('true', 'false') }}
when:
- tailscale_auth_key | length > 0
- tailscale_status.rc != 0 or '"BackendState":"Running"' not in tailscale_status.stdout
- tailscale_status.rc != 0 or (tailscale_backend_state | default('')) != 'Running'
changed_when: true