fix(ansible): use dict-form shell tasks with explicit bash
Free-form split_args breaks on quotes/Jinja at AWX runtime, and default dash rejects pipefail.
This commit is contained in:
@@ -89,7 +89,9 @@
|
||||
run_once: true
|
||||
|
||||
- name: Probe target-host port occupancy (SQL + GR)
|
||||
ansible.builtin.shell: |
|
||||
# cmd 字典形式不经过 free-form split_args 解析,避免引号/Jinja 块导致的解析失败。
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
set -o pipefail
|
||||
for p in {{ mysql_probe_ports | join(' ') }}; do
|
||||
if ss -lntH "sport = :${p}" | grep -q .; then
|
||||
@@ -100,7 +102,6 @@
|
||||
fi
|
||||
fi
|
||||
done
|
||||
args:
|
||||
executable: /bin/bash
|
||||
vars:
|
||||
mysql_probe_ports: "{{ [mysql_port_value, mysql_gr_port_value] if topology == 'mgr_3' else [mysql_port_value] }}"
|
||||
@@ -284,7 +285,9 @@
|
||||
timeout: 60
|
||||
|
||||
- name: Configure local administrative accounts
|
||||
ansible.builtin.shell: |
|
||||
# cmd 字典形式不经过 free-form split_args 解析,heredoc SQL 中的奇数个单引号才不会报错。
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
set -euo pipefail
|
||||
client_file="$(mktemp)"
|
||||
sql_file="$(mktemp)"
|
||||
@@ -309,7 +312,6 @@
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
/usr/bin/mysql --defaults-extra-file="$client_file" <"$sql_file"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
no_log: true
|
||||
|
||||
Reference in New Issue
Block a user