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

**URL:** <https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014>\
**Category:** Ansible Project\
**Created:** [April 19, 2021, 4:10pm UTC](https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014 "2021-04-19T16:10:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cornelis\_van\_Ginkel](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Cornelis\_van\_Ginkel](https://forum.ansible.com/u/Cornelis_van_Ginkel)\
**Post date:** [April 19, 2021, 4:10pm UTC](https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014/1 "2021-04-19T16:10:12Z")

</div>

Hi All,

I have the following in my role:

```auto

- 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:

```auto

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 19, 2021, 4:35pm UTC](https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014/2 "2021-04-19T16:35:49Z")

</div>

'unicode object' leads me to believe you are overwriting the variable  
with a string value, registered variables are always a dictionary.

---

<div class="post-metadata">

**Author:** ![Cornelis\_van\_Ginkel](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Cornelis\_van\_Ginkel](https://forum.ansible.com/u/Cornelis_van_Ginkel)\
**Post date:** [April 19, 2021, 4:41pm UTC](https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014/3 "2021-04-19T16:41:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 19, 2021, 10:24pm UTC](https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014/4 "2021-04-19T22:24:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cornelis\_van\_Ginkel](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Cornelis\_van\_Ginkel](https://forum.ansible.com/u/Cornelis_van_Ginkel)\
**Post date:** [April 20, 2021, 6:44am UTC](https://forum.ansible.com/t/the-error-was-unicode-object-has-no-attribute-stdout/35014/5 "2021-04-20T06:44:43Z")

</div>

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
