Ansible task crash if using with_items

96 views
Skip to first unread message

Eino Tuominen

unread,
Sep 10, 2015, 12:08:32 PM9/10/15
to Ansible Project
Hello, 

I have:

Red Hat Enterprise Linux Server release 6.7 (Santiago)

Linux x.utu.fi 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux


# ansible --version

ansible 2.0.0

  config file = /etc/ansible/ansible.cfg

  configured module search path = /etc/ansible/library


# cat reproduce.yml 

---

- hosts: localhost

  tasks:

    - name: foo

      shell: "true"

      with_items:

        - foo

        - bar

# ansible-playbook reproduce.yml -vvv

...

TASK [foo] *********************************************************************

ESTABLISH LOCAL CONNECTION FOR USER: root

127.0.0.1 EXEC mkdir -p "$HOME/.ansible/tmp/ansible-tmp-1441900074.83-151106908408783" && echo "$HOME/.ansible/tmp/ansible-tmp-1441900074.83-151106908408783"

127.0.0.1 PUT /tmp/tmp2XuR76 TO /root/.ansible/tmp/ansible-tmp-1441900074.83-151106908408783/command

127.0.0.1 EXEC LANG=C LC_MESSAGES=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1441900074.83-151106908408783/command; rm -rf "/root/.ansible/tmp/

ansible-tmp-1441900074.83-151106908408783/" > /dev/null 2>&1

ESTABLISH LOCAL CONNECTION FOR USER: root

127.0.0.1 EXEC mkdir -p "$HOME/.ansible/tmp/ansible-tmp-1441900074.91-107992728137762" && echo "$HOME/.ansible/tmp/ansible-tmp-1441900074.91-107992728137762"

127.0.0.1 PUT /tmp/tmppaIjQW TO /root/.ansible/tmp/ansible-tmp-1441900074.91-107992728137762/command

127.0.0.1 EXEC LANG=C LC_MESSAGES=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1441900074.91-107992728137762/command; rm -rf "/root/.ansible/tmp/

ansible-tmp-1441900074.91-107992728137762/" > /dev/null 2>&1

An exception occurred during task execution. The full traceback is:

Traceback (most recent call last):

  File "/usr/lib/python2.6/site-packages/ansible-2.0.0-py2.6.egg/ansible/executor/process/worker.py", line 119, in run

    executor_result = TaskExecutor(host, task, job_vars, new_play_context, self._new_stdin, self._loader, shared_loader_obj).run()

  File "/usr/lib/python2.6/site-packages/ansible-2.0.0-py2.6.egg/ansible/executor/task_executor.py", line 127, in run

    result = json.dumps(res, default=json_variable_cleaner)

  File "/usr/lib64/python2.6/json/__init__.py", line 237, in dumps

    **kw).encode(obj)

  File "/usr/lib64/python2.6/json/encoder.py", line 367, in encode

    chunks = list(self.iterencode(o))

  File "/usr/lib64/python2.6/json/encoder.py", line 309, in _iterencode

    for chunk in self._iterencode_dict(o, markers):

  File "/usr/lib64/python2.6/json/encoder.py", line 275, in _iterencode_dict

    for chunk in self._iterencode(value, markers):

  File "/usr/lib64/python2.6/json/encoder.py", line 306, in _iterencode

    for chunk in self._iterencode_list(o, markers):

  File "/usr/lib64/python2.6/json/encoder.py", line 204, in _iterencode_list

    for chunk in self._iterencode(value, markers):

  File "/usr/lib64/python2.6/json/encoder.py", line 309, in _iterencode

    for chunk in self._iterencode_dict(o, markers):

  File "/usr/lib64/python2.6/json/encoder.py", line 275, in _iterencode_dict

    for chunk in self._iterencode(value, markers):

  File "/usr/lib64/python2.6/json/encoder.py", line 294, in _iterencode

    yield encoder(o)

TypeError: first argument must be a string or unicode, not UnsafeProxy(AnsibleUnicode)


fatal: [localhost]: FAILED! => {"failed": true, "stdout": ""}


I tried to google around, but I didn't manage to find anything obvious. I have another test server with Ubuntu that doesn't have this problem. I also tried to install Python 2.7, but that didn't help either.

-- 
  Eino Tuominen

Brian Coca

unread,
Sep 10, 2015, 5:11:19 PM9/10/15
to Ansible Project
this will probably be fixed soon, we are trying to introduce a
'unsafe' type into current devel to allow for good data sanitation.


--
Brian Coca

James Cammarata

unread,
Sep 13, 2015, 8:39:55 PM9/13/15
to ansible...@googlegroups.com
Hi Eino, this appears to be working now:

TASK [foo] *********************************************************************
changed: [localhost] => (item=foo) => {"changed": true, "cmd": "true", "delta": "0:00:00.002933", "end": "2015-09-13 20:38:31.761057", "item": "foo", "rc": 0, "start": "2015-09-13 20:38:31.758124", "stderr": "", "stdout": "", "stdout_lines": [], "warnings": []}
changed: [localhost] => (item=bar) => {"changed": true, "cmd": "true", "delta": "0:00:00.003014", "end": "2015-09-13 20:38:31.826862", "item": "bar", "rc": 0, "start": "2015-09-13 20:38:31.823848", "stderr": "", "stdout": "", "stdout_lines": [], "warnings": []}

Let us know if you continue seeing problems with this.

Thanks!



James Cammarata
Director, Ansible Core Engineering
github: jimi-c

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fef0e26a-84cd-4bb0-a569-8690ad36efc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eino Tuominen

unread,
Sep 14, 2015, 8:21:19 AM9/14/15
to ansible...@googlegroups.com

Hi James,

 

It seems that it's now working with Python 2.7 on RHEL. The distribution supplied Python (2.6) still produces the same error.

 

--

 Eino Tuominen

Reply all
Reply to author
Forward
0 new messages