Problem with updating Ansible from 1.9 to 2.0

48 views
Skip to first unread message

taro kinst

unread,
Mar 24, 2016, 9:00:12 AM3/24/16
to Ansible Project, kansho...@hitachi.co.jp

Hi,


I've been made a orchistration tool by Ansible1.9, and trying to update Ansible to the 2.0version.
I found there are some syntax rules that were changed (maybe bugs?) in Ansbile2.0.

I have to use modules in playbook, which are written as bash scripts,
and there are some parameters that contain space in their arguments.
When I execute playbook in Ansbile1.9, result showed the argument like var="argument A".
While in Ansbile 2.0, it is now shown as var="'argument A'".
The argument will be added a pair of quotation marks inside the double quotation marks.

I'm wondering why the difference happened? Which of the two results should be right?
If this is a bug in Ansible2.0, can I expect that it will be fixed?
Here is the sample module. And results in both version of Ansible.
 
=========================================================================================
<< sample module >>
[root@ansible ansible]# cat library/hello.sh
#!/bin/bash
source ${1}
echo ${msg1} ${msg2} >&2
echo -n "{\"rc\": 0 ,\"changed\": true ,\"msg\": {\"msg1\": \"${msg1}\" ,\"msg2\": \"${msg2}\"}}"
exit 0
[root@ansible ansible]# cat hello.yml
#
# ansible loop test
#
---
- hosts: localhost

  tasks:

  - hello.sh: msg1="hello_world" msg2="hello world"
    register: results
  - debug: var=results.msg
[root@ansible ansible]#

=========================================================================================

<< ansible1.9 >>

[root@ansible ansible]# ansible --version
ansible 1.9.4
  configured module search path = None
[root@ansible ansible]# ANSIBLE_KEEP_REMOTE_FILES=True ansible-playbook hello.yml

PLAY [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/arguments
msg1="hello_world" msg2="hello world"
[root@ansible ansible]#

=========================================================================================

<< ansible2.0 >>

[root@ansible ansible]# ansible --version
ansible 2.0.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
[root@ansible ansible]# ANSIBLE_KEEP_REMOTE_FILES=True ansible-playbook hello.yml
PLAY ***************************************************************************

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/args
msg1="hello_world" msg2="'hello world'"
[root@ansible ansible]#
[root@ansible ansible]#

※msg2 is added a pair of quotation marks!!

=========================================================================================

Best regards!!

Reply all
Reply to author
Forward
0 new messages