Hi,
[root@ansible ansible]# cat library/hello.sh#!/bin/bashsource ${1}echo ${msg1} ${msg2} >&2echo -n "{\"rc\": 0 ,\"changed\": true ,\"msg\": {\"msg1\": \"${msg1}\" ,\"msg2\": \"${msg2}\"}}"exit 0[root@ansible ansible]# cat hello.yml## ansible loop test#---- hosts: localhosttasks:
- hello.sh: msg1="hello_world" msg2="hello world"register: results- debug: var=results.msg[root@ansible ansible]#
=========================================================================================
<< ansible1.9 >>
[root@ansible ansible]# ansible --versionansible 1.9.4configured module search path = None[root@ansible ansible]# ANSIBLE_KEEP_REMOTE_FILES=True ansible-playbook hello.ymlPLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]TASK: [hello.sh msg1="hello_world" msg2="hello world"] ************************
changed: [localhost]TASK: [debug var=results.msg] *************************************************
ok: [localhost] => {"var": {"results.msg": {"msg1": "hello_world","msg2": "hello world"}}}PLAY RECAP ********************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=0[root@ansible ansible]# ls ~/.ansible/tmp/*/root/.ansible/tmp/ansible-tmp-1458001760.22-38044543181627:setup/root/.ansible/tmp/ansible-tmp-1458001761.76-64661619210720:
arguments hello.sh[root@ansible ansible]# cat ~/.ansible/tmp/ansible-tmp-1458001761.76-64661619210720/argumentsmsg1="hello_world" msg2="hello world"[root@ansible ansible]#
=========================================================================================
<< ansible2.0 >>
[root@ansible ansible]# ansible --versionansible 2.0.1.0config file = /etc/ansible/ansible.cfgconfigured module search path = Default w/o overrides[root@ansible ansible]# ANSIBLE_KEEP_REMOTE_FILES=True ansible-playbook hello.ymlPLAY ***************************************************************************TASK [setup] *******************************************************************
ok: [localhost]TASK [hello.sh] ****************************************************************
changed: [localhost]TASK [debug] *******************************************************************
ok: [localhost] => {"results.msg": {"msg1": "hello_world","msg2": "'hello world'"}}PLAY RECAP *********************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=0[root@ansible ansible]# ls ~/.ansible/tmp/*
/root/.ansible/tmp/ansible-tmp-1458002520.4-267495855326593:setup/root/.ansible/tmp/ansible-tmp-1458002521.22-261328355840387:
args hello.sh[root@ansible ansible]# cat /root/.ansible/tmp/ansible-tmp-1458002521.22-261328355840387/argsmsg1="hello_world" msg2="'hello world'"[root@ansible ansible]#[root@ansible ansible]#
※msg2 is added a pair of quotation marks!!