I have playbook to retrieve the Instance id of Openstack nodes.Now everything works fine but the resgitered value for instid.stdout_lines gets an undefined error. The error was: ‘dict object’ has no attribute ‘stdout_lines’ … but when i debug the complete registered variable instid i see stdout_lines. but why its failing when i debug it using instid.stdout_lines
I had already tried it it gives me o/p as same as :
debug:
msg: {{ instid }}
Both the o/ps are similar.
Now i want the stdout_lines for each item as my desired o/p
something like:
e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2
7865dvgsf-17f3-4b80-a935-03164211a804 TOMICS1
abc12345g-17f3-4b80-a935-03164211a804 TOMIAS2
I could do achieve what i intended. I made the following changes using Jinja format and my issue solved.
Thanks for the help. Th echanges i made was:
In the Instance id section i used the foloing formula and it worked like a charm.
name: Set fact for Instance id from Tenant ID
delegate_to: localhost
set_fact:
id_list: “{% for item in instid.results %}
{{ item.stdout_lines[0].split()[0] }}
{% endfor %}”
name: Set fact for Desired Instance ids
set_fact:
desired_instid: “{{ id_list.split() }}”