From 9480988a7ae1f677edaf4446c8380962df831926 Mon Sep 17 00:00:00 2001 From: pavel Date: Tue, 20 Jan 2026 11:11:56 +0200 Subject: [PATCH] 1111 --- files/ansible-playbooks/ptsd-migrate.yml | 54 +++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/files/ansible-playbooks/ptsd-migrate.yml b/files/ansible-playbooks/ptsd-migrate.yml index e1d2e58..cc053cc 100644 --- a/files/ansible-playbooks/ptsd-migrate.yml +++ b/files/ansible-playbooks/ptsd-migrate.yml @@ -588,6 +588,58 @@ esac changed_when: false + + # ============================ PHASE 0 (LAST): DEV2 STATE GUARD (OLD PPP EXPECTED) ============================ + - name: "PHASE 0 (LAST) | DEV2 check: ppp0 has IPv4 (old expected) via wrapper" + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="ip -4 addr show dev ppp0 2>/dev/null | grep -m1 'inet ' >/dev/null 2>&1 && echo YES || echo NO" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + register: dev2_ppp0_has_ipv4 + changed_when: false + failed_when: false + + - name: "PHASE 0 (LAST) | DEV2 check: eth0.4000 exists (new/migrated indicator) via wrapper" + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="ip link show eth0.4000 >/dev/null 2>&1 && echo YES || echo NO" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + register: dev2_eth04000_exists + changed_when: false + failed_when: false + + - name: "PHASE 0 (LAST) | Summarize DEV2 pre-migration eligibility" + delegate_to: localhost + ansible.builtin.set_fact: + dev2_ppp_old_ok: "{{ (dev2_ppp0_has_ipv4.stdout | default('') | trim) == 'YES' }}" + dev2_eth04000_present: "{{ (dev2_eth04000_exists.stdout | default('') | trim) == 'YES' }}" + dev2_pre_migration_ok: >- + {{ + ((dev2_ppp0_has_ipv4.stdout | default('') | trim) == 'YES') + and + ((dev2_eth04000_exists.stdout | default('') | trim) != 'YES') + }} + changed_when: false + + - name: "PHASE 0 (LAST) | Stop if DEV2 is NOT a pure old PPP device" + when: not (dev2_pre_migration_ok | bool) + delegate_to: localhost + ansible.builtin.debug: + msg: + - "We shall not continue: DEV2 is not a pure old PPP device." + - "ppp0_has_ipv4={{ dev2_ppp_old_ok }}" + - "eth0.4000_exists={{ dev2_eth04000_present }}" + - "dev2_conn_final={{ dev2_conn_final }}" + changed_when: false + + - name: "PHASE 0 (LAST) | End host if DEV2 is NOT a pure old PPP device" + when: not (dev2_pre_migration_ok | bool) + ansible.builtin.meta: end_host + + + # ============================ PHASE 1: FIRST ON-DEVICE COMMAND (uptime) ============================ - name: "PHASE 1 | DEV2 uptime via wrapper" delegate_to: localhost @@ -857,7 +909,7 @@ ansible.builtin.fail: msg: "DEV2 md5sum for {{ dev2_config_dhcp_remote_path }} is empty; upload failed or md5sum unavailable." - - name: PHASE 1 | Compare controller vs DEV2 md5sum for config-dhcp.json (fail on mismatch) + - name: PHASE 1 | Compare controller vs DEV2 md5sum for config-dhcp.json (Ok, to be skipped. fail on mismatch) delegate_to: localhost ansible.builtin.fail: msg: >-