fix(security): stop ansible.builtin.command from expanding $VARs in argv scripts

8ab950f13c hands the postgres, MediaWiki and XWiki scripts to bash -c as argv text, and ansible.builtin.command runs os.path.expandvars over every argv item unless expand_argument_vars is false. Any $NAME that also exists in the task environment was replaced before bash ran: with container=docker set in the dev container, set_postgres_superuser_password.sh targeted a container named docker and retried its outer loop until the deploy hung. The four argv tasks now pass expand_argument_vars: false.

Verified through Ansible replicas: postgres rc=0 with every exec on the right container and 0 ps -ww hits, MediaWiki 1.46 installed with 0 ps -ww hits, the XWiki hash matches; a live deploy reports [UNCHANGED] for the shared postgres.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-28 16:53:39 +01:00
1 parent 1002909f8c
commit 94ed66f1e3
4 files changed
+4

No files matched your search

+1
View File
@@ -53,6 +53,7 @@
- "{{ POSTGRES_CONTAINER_ADDRESS }}"
- postgres
stdin: "{{ POSTGRES_PASSWORD }}"
expand_argument_vars: false
register: postgres_pw_result
delegate_to: "{{ STACK_HOST }}"
run_once: true
@@ -34,6 +34,7 @@
- "{{ lookup('database', application_id, 'container') }}"
- "{{ lookup('database', application_id, 'username') }}"
stdin: "{{ lookup('database', application_id, 'password') }}"
expand_argument_vars: false
register: _app_db_realign
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
changed_when: _app_db_realign.stdout is search('\\[CHANGED\\]')
@@ -22,6 +22,7 @@
stdin: |-
{{ lookup('database', application_id, 'password') }}
{{ MEDIAWIKI_ADMINISTRATOR_PASSWORD }}
expand_argument_vars: false
environment:
MW_CUSTOM_IMAGE: "{{ MEDIAWIKI_CUSTOM_IMAGE_REF }}"
MW_LOCALSETTINGS_HOST_PATH: "{{ MEDIAWIKI_LOCALSETTINGS_HOST_PATH }}"
@@ -32,6 +32,7 @@
- "{{ (_super_check_ext.content | default(''))[:600] | replace('\n','\\n') }}"
- "{{ XWIKI_CONTAINER }}"
stdin: "{{ XWIKI_SUPERADMIN_PASSWORD }}"
expand_argument_vars: false
register: _dbg_superadmin
changed_when: false
failed_when: false