diff --git a/files/ansible-playbooks/ptsd-migrate.yml b/files/ansible-playbooks/ptsd-migrate.yml index 797f475..a482ade 100644 --- a/files/ansible-playbooks/ptsd-migrate.yml +++ b/files/ansible-playbooks/ptsd-migrate.yml @@ -734,6 +734,23 @@ ansible.builtin.fail: msg: "DEV2 md5sum for /tmp/config.json is empty; file missing or md5sum unavailable." + - name: PHASE 1 | DEV2 backup original config to /tmp/config-orig.json + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="cp /tmp/config.json /tmp/config-orig.json" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + changed_when: true + + - name: PHASE 1 | DEV2 set /tmp/ptsd.inprogress marker before controller config copy + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="touch /tmp/ptsd.inprogress" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + changed_when: true + + - name: PHASE 1 | Download /tmp/config.json from DEV2 to controller (tunnel) when: dev2_conn_final == "tunnel" delegate_to: localhost @@ -995,6 +1012,30 @@ - "DEV2 md5={{ dev2_dhcp_md5.stdout | trim }}" + - name: PHASE 1 | DEV2 copy uploaded config to /tmp/config-test.json + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="cp /tmp/config-dhcp.json /tmp/config-test.json" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + changed_when: true + + - name: PHASE 1 | DEV2 arm parachute reboot delayed 600 seconds + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="reboot -d 600 &" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + changed_when: true + + - name: PHASE 1 | DEV2 simulate upgrade marker AA_startedupgrade + delegate_to: localhost + ansible.builtin.shell: | + export DEV2_CMD="touch AA_startedupgrade" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + changed_when: true + post_tasks: - name: Cleanup note diff --git a/files/ansible-playbooks/ptsd_reacquire_attempt.yml b/files/ansible-playbooks/ptsd_reacquire_attempt.yml index 188e660..05e2595 100644 --- a/files/ansible-playbooks/ptsd_reacquire_attempt.yml +++ b/files/ansible-playbooks/ptsd_reacquire_attempt.yml @@ -563,7 +563,7 @@ cleanup_report: >- {{ cleanup_report - ~ '; ' + ~ ', ' ~ ( 'pending reboot found and cancelled' if (reboot_present.stdout | default('') | trim) == 'FOUND' @@ -572,6 +572,95 @@ }} changed_when: false + - name: CASE A DEV2 touch confirming_success marker + when: dhcp_migrated_ok | bool + delegate_to: localhost + ansible.builtin.shell: | + set -e + export DEV2_CMD="touch /tmp/confirming_success >/dev/null 2>&1 && echo OK || echo FAIL" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + register: confirming_success_touch + changed_when: false + failed_when: false + + - name: CASE A append confirming_success marker result + when: dhcp_migrated_ok | bool + delegate_to: localhost + ansible.builtin.set_fact: + cleanup_report: >- + {{ + cleanup_report + ~ ', ' + ~ ( + 'touched /tmp/confirming_success' + if (confirming_success_touch.stdout | default('') | trim) == 'OK' + else 'failed to touch /tmp/confirming_success' + ) + }} + changed_when: false + + - name: CASE A sleep 5 seconds + when: dhcp_migrated_ok | bool + ansible.builtin.pause: + seconds: 5 + + - name: CASE A DEV2 move config test to config with dhcp + when: dhcp_migrated_ok | bool + delegate_to: localhost + ansible.builtin.shell: | + set -e + export DEV2_CMD="mv /tmp/config-test.json /tmp/config-with-dhcp.json >/dev/null 2>&1 && echo OK || echo FAIL" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + register: mv_config_result + changed_when: false + failed_when: false + + - name: CASE A append config move result + when: dhcp_migrated_ok | bool + delegate_to: localhost + ansible.builtin.set_fact: + cleanup_report: >- + {{ + cleanup_report + ~ ', ' + ~ ( + 'moved /tmp/config-test.json to /tmp/config-with-dhcp.json' + if (mv_config_result.stdout | default('') | trim) == 'OK' + else 'failed to move /tmp/config-test.json to /tmp/config-with-dhcp.json' + ) + }} + changed_when: false + + - name: CASE A DEV2 remove ptsd inprogress marker + when: dhcp_migrated_ok | bool + delegate_to: localhost + ansible.builtin.shell: | + set -e + export DEV2_CMD="rm -f /tmp/ptsd.inprogress >/dev/null 2>&1 && echo OK || echo FAIL" + {{ dev2_exec_cmd }} + args: { executable: /bin/bash } + register: rm_inprogress_result + changed_when: false + failed_when: false + + - name: CASE A append ptsd inprogress removal result + when: dhcp_migrated_ok | bool + delegate_to: localhost + ansible.builtin.set_fact: + cleanup_report: >- + {{ + cleanup_report + ~ ', ' + ~ ( + 'removed /tmp/ptsd.inprogress' + if (rm_inprogress_result.stdout | default('') | trim) == 'OK' + else 'failed to remove /tmp/ptsd.inprogress' + ) + }} + changed_when: false + - name: CASE A final cumulative cleanup report when: dhcp_migrated_ok | bool delegate_to: localhost @@ -584,7 +673,7 @@ - name: Cleanup note delegate_to: localhost ansible.builtin.debug: - msg: "Cleanup best-effort closing tunnel removing temp IP removing staged passfiles" + msg: "Cleanup best-effort, closing tunnel, removing temp IP, removing staged passfiles" changed_when: false - name: Close SSH ControlMaster (best-effort) @@ -623,4 +712,3 @@ del_ip.rc != 0 and ('Cannot assign requested address' not in (del_ip.stdout | default(''))) and ('Cannot assign requested address' not in (del_ip.stderr | default(''))) -