---
- name: test
hosts: localhost
gather_facts: false
vars:
output:
msg: This is a test.
tasks:
- script: test.py {{ output.msg }}
args:
executable: python3
register: script1
- script: test.py "{{ output.msg }}"
args:
executable: python3
register: script2
- debug:
msg:
- "{{ script1.stdout }}"
- "{{ script2.stdout }}"
在哪里?
test.py
只是:
import sys
print('argv[1]: ', sys.argv[1])
最终任务输出:
TASK [debug] *********************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": [
"argv[1]: This\n",
"argv[1]: This is a test.\n"
]
}