Thanks Kai, that worked. Seems obvious now I look at it, but wasnt at the
time!

On 27 October 2017 at 19:51, Kai Stian Olstad <
[email protected]> wrote:

> On 27.10.2017 18:55, Marc L wrote:
>
>> 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.
>>
>
> In 2.4 you have the xml module you could use.
>
>
> - 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 }}"
>>
>
> <snip />
>
> 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'"}
>>
>
> Your host 192.168.50.4 is not groups["backend_nodes"][0]
>
> "Get OHP Group Passcode" run only on one host 'groups["backend_nodes"][0]'
> because of the when statement.
> But your debug task run on all the host in the playbook, but they don't
> have the variable webpage, so you get the error message on them, so you
> need to include the when on the debug task also.
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/ansible-project/BGsBZEnT0-c/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ms
> gid/ansible-project/dbfca1ec28fd254e9e15e0b64546ce06%40olstad.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CADOW8SP1DvbVC_q0SC-Bj8_NAPJC1a5H16ttbLfVoA7OHYCjWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to