The error was: 'unicode object' has no attribute 'stdout'

311 views
Skip to first unread message

Cornelis van Ginkel

unread,
Apr 19, 2021, 12:10:12 PM4/19/21
to Ansible Project
Hi All,

I have the following in my role:
```
    - name: "UPTOM_30 - Determine version from Tomcat file {{ uptom_tomcat_tar_src }}"
      shell: "echo '{{ uptom_tomcat_tar_src }}' | awk -F '-' '{print $NF}' | sed 's/.tar.gz//g'"
      register: uptom_new_tomcat_version

    - name: Debug1
      debug:
        msg: "{{ uptom_opt_dir }}/apache-tomcat-{{ uptom_new_tomcat_version.stdout }}"
```
this works in a normal playbook, but when used in a role it will give me:
```
TASK [update_tomcat : Debug1] **********************************************************************************************************************************************************************************
Monday 19 April 2021  18:02:09 +0200 (0:00:00.847)       0:00:13.738 **********
fatal: [tstdlatoml01]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'unicode object' has no attribute 'stdout'\n\nThe error appears to have been in '/home/people/cginkel/automation_projects/roles/update_tomcat/tasks/main.yml': line 55, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Debug1\n      ^ here\n"}
```
why is my stdout missing all of a sudden?
I googled it first of course, but I don't find anything related to what I am doing here.
Plus that it works in a playbook, which throws me off.

I don't get it.

Thanks in advance.

With kind regards,

Cornelis

Brian Coca

unread,
Apr 19, 2021, 12:36:23 PM4/19/21
to Ansible Project
'unicode object' leads me to believe you are overwriting the variable
with a string value, registered variables are always a dictionary.

----------
Brian Coca

Cornelis van Ginkel

unread,
Apr 19, 2021, 12:42:01 PM4/19/21
to ansible...@googlegroups.com
Hi Brian,

Thanks for the quick response.
It will give a number like output, like 9.0.41
So I want to use that to get the full path to the folder.

Does that make sense?

Op ma 19 apr. 2021 18:36 schreef Brian Coca <bc...@redhat.com>:
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/96wSgd2rzrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7dC%3DoWpxLbFaPkybXWTcLt3xKNHKeFV56uL_PVtXqR4mg%40mail.gmail.com.

Brian Coca

unread,
Apr 19, 2021, 6:25:32 PM4/19/21
to Ansible Project
yes, but please check you are not setting the variable in other ways,
as in my previous message, the error points to the data not being what
the register creates.





--
----------
Brian Coca

Cornelis van Ginkel

unread,
Apr 20, 2021, 2:45:08 AM4/20/21
to ansible...@googlegroups.com
I think I found the culprit. I am indeed using the same variable name in a shell script before I run the role, so the conflict is there. 

Thanks fr the responses!

With kind regards,

Cornelis

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/96wSgd2rzrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages