Id from multiple machines?

Hi. I’m attempting to retrieve a specific id from multiple machines with the uri module.

The below ansible tasks can achieve the operation on one machine.

What is the best way to retrieve the ID from several machines?

  • name: Retrieve Orchid MID
    uri:
    url: “{{ myurl }}”
    force_basic_auth: yes
    user: admin
    password: “{{ mypassword }}”
    timeout: 20
    register: machineid

  • name: DEBUG Retrieve Orchid MID
    debug:
    msg: “{{ machineid.json.orchids[0].mid }}”

I am pretty sure that if you loop, the registered variable will contain a list of results, one from each iteration.

  • name: Retrieve Orchid MID
    uri:
    url: “{{ item.url }}”
    force_basic_auth: yes
    user: admin
    password: “{{ item.password }}”
    timeout: 20
    with_items: “{{ my_list_of_urls }}”

register: machineids

Your list would look like this:

vars:

my_list_of_urls:

  • url: url_1

password: password_1

  • url: url_2

password: password_2

  • url: url_3

password: password_3

And afterwards, machineids should contain a list of machineid results. Use debug to check the exact internal structure of the variable.

I HAVE NOT TESTED THIS, it is just a guess.

Regards, K.