On 19.06.2019 08:29, Punit Jain wrote:
Hi,
I have a part of playbook task as below:
- name: get url data
uri:
uri: <path>
method: GET
user: username
password: password
register: dns_result
no_log: true
- set_fact:
dns_content: "{{ dns_result.content.records}}"
Gives an error:
"msg" : The task includes an option with an undefined variable. The
error
was ansible.vars.unsafe_proxy.AnsibleUnsafeText object' has no
attribute
'records'
That is because is doesn't exist, you need to check what is contains
with
- debug: var=dns_result
however when I set_fact separately as below, it works :
- name: get url data
uri:
uri: <path>
method: GET
user: username
password: password
register: dns_result
no_log: true
- set_fact:
dns_content: "{{ dns_result.content}}"
- debug:
msg: "{dns_contents.records}"
You only have one curly brackets so this is not treated as a variable
but as a string.
And if you add the missing curly brackets it will fail since you are
using dns_contents and not dns_content.
--
Kai Stian Olstad
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/00268525a8c184eff0795059cad93ea6%40olstad.com.
For more options, visit https://groups.google.com/d/optout.