Hi,
I have a URL that I call with a GET, and that returns an XML response.
I'd like to parse that response (I could use grep), but I'm struggling to
get the response content.
- name: Get OHP Group Passcode
uri:
url: "{{ node_protocol }}://{{ inventory_hostname
}}:/admin/configuration/environment/current"
headers:
"accept": "application/Configuration.6_10+xml"
"X-Requested-With": "ansible"
method: GET
user: "{{ auth_user }}"
password: "{{ local_password }}"
force_basic_auth: yes
validate_certs: no
return_content: yes
register: webpage
until: webpage.content.find("passcode") != -1
retries: 60
delay: 10
delegate_to: localhost
when: inventory_hostname == groups["backend_nodes"][0]
- name: Output current env details
debug:
msg: "{{ webpage.content }}"
- name: Get the group passcode
command: "echo {{ webpage.content }} | grep -oP
'(?<=<passcode>).*?(?=</passcode>)'"
delegate_to: localhost
register: passcode
I assumed I could just debug out the webpage.content again, but I get an
error
TASK [ansible-ohp-win-installer : Output current env details]
**********************************************************
fatal: [192.168.50.4]: FAILED! => {"msg": "The task includes an option with
an undefined variable. The error was: 'dict object' has no attribute
'content'\n\nThe error appears to have been in
'/mnt/c/Work/ansible/roles/ansible-ohp-win-installer/tasks/main.yml': line
185, 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:
Output current env details\n ^ here\n\nexception type: <class
'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no
attribute 'content'"}
--
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/b375c3e2-0108-44cd-aec8-b79a0c6b57d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.