diff --git a/files/ansible-playbooks/sot-updater-upgradecmd.yml b/files/ansible-playbooks/sot-updater-upgradecmd.yml index e8ac095..8194dc4 100644 --- a/files/ansible-playbooks/sot-updater-upgradecmd.yml +++ b/files/ansible-playbooks/sot-updater-upgradecmd.yml @@ -101,22 +101,29 @@ - "upgrade_cmd line (exact): {{ nb_upgrade_line | default('') }}" - "found? {{ (nb_upgrade_line | length) > 0 }}" - - name: "NB preflight | Parse value after '=' (split once)" + - name: "NB preflight | Parse value after '=' via awk" when: nb_upgrade_line | length > 0 delegate_to: localhost - vars: - parts: "{{ nb_upgrade_line.split('=', 1) }}" - set_fact: - nb_upgrade_cmd: "{{ (parts | length > 1) | ternary(parts[1] | trim, '') }}" - nb_upgrade_cmd_len: "{{ nb_upgrade_cmd | length }}" + shell: | + printf '%s\n' "{{ nb_upgrade_line }}" | awk -F'=' '{print $2}' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' + args: + executable: /bin/bash + register: up_cmd_sh + changed_when: false - - name: "NB preflight | Debug parsed upgrade_cmd (should be just the value)" + - name: "NB preflight | Set and show parsed upgrade_cmd" + when: nb_upgrade_line | length > 0 + delegate_to: localhost + set_fact: + nb_upgrade_cmd: "{{ up_cmd_sh.stdout | default('') | trim }}" + + - name: "NB preflight | Debug parsed upgrade_cmd" when: nb_upgrade_line | length > 0 delegate_to: localhost debug: msg: - "upgrade_cmd value: '{{ nb_upgrade_cmd }}'" - - "len={{ nb_upgrade_cmd_len }}" + - "len={{ nb_upgrade_cmd | length }}" - name: "NB preflight | STOP here (temporary)" meta: end_play