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

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

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

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?

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.

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