This commit is contained in:
2025-11-18 11:42:21 +02:00
parent afcab4a64a
commit 5c6dd30f5a

View File

@@ -29,14 +29,12 @@
ssh_opts_common: "-o PreferredAuthentications=password -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NumberOfPasswordPrompts=1 -o ConnectTimeout=30" ssh_opts_common: "-o PreferredAuthentications=password -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NumberOfPasswordPrompts=1 -o ConnectTimeout=30"
# Image to stage on DEV2 (we validate first; the actual write happens later) # Image to stage on DEV2 (we validate first; the actual write happens later)
image_filename: "2.2.1-r6801.bin" image_filename: "fox200-2.2.1-r6801.bin"
image_md5: "56b7211709de617e058b98d4204e2562" image_md5: "56b7211709de617e058b98d4204e2562"
# Optional SHA256; leave empty to skip SHA256 checks # Optional SHA256; leave empty to skip SHA256 checks
image_sha256: "" image_sha256: ""
dev2_image_dir: "/tmp" dev2_image_dir: "/tmp"
dev2_image_path: "{{ dev2_image_dir }}/{{ image_filename }}" dev2_image_path: "{{ dev2_image_dir }}/{{ image_filename }}"
# Image URL for legacy (1.x) DEV2 that can't scp (downloaded directly from the internet on DEV2)
image_url: "https://cloud.ikeja.co.za/firmwares/fox200/{{ image_filename }}"
# Reboot delay in HOURS (integer). Consumer always passes hours; 0 means immediate (~20s grace). # Reboot delay in HOURS (integer). Consumer always passes hours; 0 means immediate (~20s grace).
rebootin: "" rebootin: ""
@@ -440,6 +438,7 @@
changed_when: false changed_when: false
failed_when: false failed_when: false
- name: Debug listeners on picked port (after starting tunnel) - name: Debug listeners on picked port (after starting tunnel)
when: dev2_conn_method == "tunnel" when: dev2_conn_method == "tunnel"
delegate_to: localhost delegate_to: localhost
@@ -1122,7 +1121,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1149,7 +1147,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=30 \ -o ConnectTimeout=30 \
@@ -1160,19 +1157,15 @@
register: dev2_md5_before register: dev2_md5_before
changed_when: false changed_when: false
# === HERE: split copy logic based on firmware major (scp for non-1.x, curl for 1.x) === - name: Copy image to DEV2 if missing or md5 mismatch
- name: Copy image to DEV2 with scp if missing or md5 mismatch (non-legacy firmware) when: local_img.stat.exists and dev2_passfile_used != "NONE" and not (_blocked | default(false)) and ((dev2_md5_before.stdout | trim) != image_md5)
when: local_img.stat.exists
and dev2_passfile_used != "NONE"
and not (_blocked | default(false))
and ((dev2_md5_before.stdout | trim) != image_md5)
and not ((banner_raw | default('') | trim).startswith('1.'))
delegate_to: localhost delegate_to: localhost
ansible.builtin.shell: | ansible.builtin.shell: |
set -e set -e
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" scp \ sshpass -f "{{ dev2_passfile_used }}" scp \
-O \
-P "$PORT" \ -P "$PORT" \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
"{{ image_filename }}" "{{ dev2_ssh_user }}@${HOST}:{{ dev2_ssh_user == 'root' | ternary('/', '') }}{{ dev2_image_dir }}/" "{{ image_filename }}" "{{ dev2_ssh_user }}@${HOST}:{{ dev2_ssh_user == 'root' | ternary('/', '') }}{{ dev2_image_dir }}/"
@@ -1181,28 +1174,6 @@
register: scp_push register: scp_push
changed_when: true changed_when: true
- name: Copy image to DEV2 with curl if missing or md5 mismatch (legacy 1.x firmware)
when: local_img.stat.exists
and dev2_passfile_used != "NONE"
and not (_blocked | default(false))
and ((dev2_md5_before.stdout | trim) != image_md5)
and ((banner_raw | default('') | trim).startswith('1.'))
delegate_to: localhost
ansible.builtin.shell: |
set -e
HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=30 \
-p "$PORT" "{{ dev2_ssh_user }}@${HOST}" \
"curl -L --fail --silent --show-error -k -o {{ dev2_image_path }} {{ image_url }}"
args:
executable: /bin/bash
register: scp_push
changed_when: true
# === END copy split ===
- name: Compute md5 of image on DEV2 after copy (or if already present) - name: Compute md5 of image on DEV2 after copy (or if already present)
when: local_img.stat.exists and dev2_passfile_used != "NONE" and not (_blocked | default(false)) when: local_img.stat.exists and dev2_passfile_used != "NONE" and not (_blocked | default(false))
@@ -1212,7 +1183,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=30 \ -o ConnectTimeout=30 \
@@ -1239,7 +1209,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1270,7 +1239,7 @@
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=30 \ -o ConnectTimeout=30 \
-p "$PORT" "{{ dev2_ssh_user }}@${HOST }}" \ -p "$PORT" "{{ dev2_ssh_user }}@${HOST}" \
"update -c '{{ dev2_image_path }}' 2>&1 || true" "update -c '{{ dev2_image_path }}' 2>&1 || true"
args: args:
executable: /bin/bash executable: /bin/bash
@@ -1410,7 +1379,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1439,7 +1407,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1464,7 +1431,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1483,7 +1449,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1503,7 +1468,6 @@
HOST="{{ dev2_ssh_host }}" HOST="{{ dev2_ssh_host }}"
PORT="{{ dev2_ssh_port }}" PORT="{{ dev2_ssh_port }}"
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
@@ -1526,7 +1490,6 @@
SECS="{{ _reboot_seconds | int }}" SECS="{{ _reboot_seconds | int }}"
CMD='/sbin/reboot -d '"${SECS}"' >/dev/null 2>&1 &' CMD='/sbin/reboot -d '"${SECS}"' >/dev/null 2>&1 &'
sshpass -f "{{ dev2_passfile_used }}" ssh \ sshpass -f "{{ dev2_passfile_used }}" ssh \
-o AddressFamily=inet \
-o StrictHostKeyChecking=no -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o PubkeyAuthentication=no \
-o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \ -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \