1021
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
# ptsd-migration.yml — PPPoE to super DHCP
|
# ptsd-migration.yml — PPPoE to super DHCP
|
||||||
# Phase 0: connectivity + safe identity guard
|
# Phase 0: reliable DEV2 connectivity + wrapper build (no DEV2 commands)
|
||||||
# Phase 1: wrapper only (no device commands yet)
|
# Phase 1: DEV2 commands via wrapper (initially uptime)
|
||||||
|
|
||||||
- name: "PPPoE to super DHCP | Phase 0+1 | Reliable DEV2 connectivity + wrapper"
|
- name: "PPPoE to super DHCP | Phase 0+1 | Reliable DEV2 connectivity + wrapper + uptime"
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
((dev1_host_read.stdout | trim) != (inventory_hostname | string))
|
((dev1_host_read.stdout | trim) != (inventory_hostname | string))
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
# ============================ LLDP DISCOVERY (IPv4 + IPv6) ============================
|
# ============================ PHASE 0: LLDP DISCOVERY (IPv4 + IPv6) ============================
|
||||||
- name: Compute hostname digits key for LLDP lookup (DEV2)
|
- name: Compute hostname digits key for LLDP lookup (DEV2)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
dev2_lldp_digits: "{{ (inventory_hostname | string) | regex_replace('[^0-9]', '') }}"
|
dev2_lldp_digits: "{{ (inventory_hostname | string) | regex_replace('[^0-9]', '') }}"
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
- "LLDP IPv4 class={{ lldp_ip_class | default('none') }}"
|
- "LLDP IPv4 class={{ lldp_ip_class | default('none') }}"
|
||||||
- "LLDP IPv6 candidate={{ lldp_dev2_ip6 | default('<none>') }}"
|
- "LLDP IPv6 candidate={{ lldp_dev2_ip6 | default('<none>') }}"
|
||||||
|
|
||||||
# ============================ PRIMARY PATH DECISION ============================
|
# ============================ PHASE 0: PRIMARY PATH DECISION ============================
|
||||||
- name: Override dev2_host from LLDP when candidate is 192.168.x.x
|
- name: Override dev2_host from LLDP when candidate is 192.168.x.x
|
||||||
when: (lldp_ip_class | trim) == "192_168" and (lldp_dev2_ip | trim | length > 0)
|
when: (lldp_ip_class | trim) == "192_168" and (lldp_dev2_ip | trim | length > 0)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
dev2_conn_method: "{{ 'direct_lldp' if ((lldp_ip_class | trim) == '10') else 'tunnel' }}"
|
dev2_conn_method: "{{ 'direct_lldp' if ((lldp_ip_class | trim) == '10') else 'tunnel' }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
# ============================ DIRECT LLDP IPv4 AUTH (10.x) ============================
|
# ============================ PHASE 0: DIRECT LLDP IPv4 AUTH (10.x) ============================
|
||||||
- name: Try DEV2 login via direct LLDP IPv4 (10.x) with basicpass
|
- name: Try DEV2 login via direct LLDP IPv4 (10.x) with basicpass
|
||||||
when: dev2_conn_method == "direct_lldp"
|
when: dev2_conn_method == "direct_lldp"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
dev2_passfile_used_direct: "basicpass2"
|
dev2_passfile_used_direct: "basicpass2"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
# ============================ TUNNEL PREP (DEV1 temp IP + ARP + tunnel) ============================
|
# ============================ PHASE 0: TUNNEL PREP (DEV1 temp IP + ARP + tunnel) ============================
|
||||||
- name: Add temporary IP on DEV1 (tolerate 'File exists')
|
- name: Add temporary IP on DEV1 (tolerate 'File exists')
|
||||||
when: dev2_conn_method == "tunnel"
|
when: dev2_conn_method == "tunnel"
|
||||||
ansible.builtin.raw: >
|
ansible.builtin.raw: >
|
||||||
@@ -353,7 +353,7 @@
|
|||||||
dev2_passfile_used_tunnel: "basicpass2"
|
dev2_passfile_used_tunnel: "basicpass2"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
# ============================ SAFETY GUARD: MAC CHECK (only if tunnel auth succeeded) ============================
|
# ============================ PHASE 0: SAFETY GUARD (MAC CHECK) ============================
|
||||||
- name: Read remote eth0 MAC via tunnel (guard, sanitized)
|
- name: Read remote eth0 MAC via tunnel (guard, sanitized)
|
||||||
when:
|
when:
|
||||||
- dev2_conn_method == "tunnel"
|
- dev2_conn_method == "tunnel"
|
||||||
@@ -402,7 +402,7 @@
|
|||||||
Safety stop: tunnel reached wrong device.
|
Safety stop: tunnel reached wrong device.
|
||||||
expected_dev2_mac={{ dev2_mac }}, remote_eth0_mac={{ remote_eth0_mac }}
|
expected_dev2_mac={{ dev2_mac }}, remote_eth0_mac={{ remote_eth0_mac }}
|
||||||
|
|
||||||
# ============================ FALLBACKS (only if tunnel auth failed) ============================
|
# ============================ PHASE 0: FALLBACKS (only if tunnel auth failed) ============================
|
||||||
- name: Try DEV2 login via LLDP IPv4 10.x (fallback if tunnel auth failed)
|
- name: Try DEV2 login via LLDP IPv4 10.x (fallback if tunnel auth failed)
|
||||||
when:
|
when:
|
||||||
- dev2_conn_method == "tunnel"
|
- dev2_conn_method == "tunnel"
|
||||||
@@ -491,7 +491,7 @@
|
|||||||
dev2_passfile_used_lldp6: "{{ (dev2_auth_lldp6.rc == 0) | ternary((dev2_auth_lldp6.stdout | trim), 'NONE') }}"
|
dev2_passfile_used_lldp6: "{{ (dev2_auth_lldp6.rc == 0) | ternary((dev2_auth_lldp6.stdout | trim), 'NONE') }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
# ============================ FINAL DECISION + WRAPPER FACTS ============================
|
# ============================ PHASE 0: FINAL DECISION + WRAPPER FACTS ============================
|
||||||
- name: Decide final DEV2 connection mode (direct_lldp > tunnel > lldp4 > lldp6)
|
- name: Decide final DEV2 connection mode (direct_lldp > tunnel > lldp4 > lldp6)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
@@ -588,6 +588,24 @@
|
|||||||
esac
|
esac
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
# ============================ PHASE 1: FIRST ON-DEVICE COMMAND (uptime) ============================
|
||||||
|
- name: "PHASE 1 | DEV2 uptime via wrapper"
|
||||||
|
delegate_to: localhost
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
export DEV2_CMD="uptime"
|
||||||
|
{{ dev2_exec_cmd }}
|
||||||
|
args: { executable: /bin/bash }
|
||||||
|
register: dev2_uptime
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: "PHASE 1 | Output DEV2 uptime (stdout)"
|
||||||
|
delegate_to: localhost
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg:
|
||||||
|
- "DEV2 uptime via {{ dev2_conn_final }}:"
|
||||||
|
- "{{ (dev2_uptime.stdout | default('')) | regex_replace('\r','') }}"
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: Cleanup note
|
- name: Cleanup note
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|||||||
Reference in New Issue
Block a user