title: How to get public IP from Ansible azure_rm_publicipaddress_facts module into a variable to use with add_host?
body: <p>I'm trying to set up a pipeline for Azure automation with Ansible, all working, except when I try to get the public IP address into a variable to use with add_host.
  Here is my example task:</p>
  
  <pre><code>---
  - name: Get Public IP
    azure_rm_publicipaddress_facts:
      resource_group: '{{ my_resource_group }}'
      name: '{{ my_name }}'
    register: azure_ip
  
  - debug: var=azure_ip verbosity=2
  
  - name: Add new instance to host group
    add_host:
      hostname: '{{ item.ipAddress }}'
      groupname: launched
    with_items: azure_ip.azure_publicipaddresses
  </code></pre>
  
  <p>With this giving me the following error:</p>
  
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined.</p>
  </blockquote>
  
  <p>However the value is there as shown :</p>
  
  <pre><code>TASK [azure : debug] ***********************************************************
  task path: mytest/roles/azure/tasks/get_ip.yml:14
  ok: [localhost] =&gt; {
      "azure_ip": {
          "ansible_facts": {
              "azure_publicipaddresses": [
                  {
                      "etag": “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                      "id": "/subscriptions/0000000000000/resourceGroups/myrgrp/providers/Microsoft.Network/publicIPAddresses/my_ip_001",
                      "location": “euwest",
                      "name": “my_ip_001",
                      "properties": {
                          "idleTimeoutInMinutes": 4,
                          "ipAddress": “20.113.125.63",
                          "ipConfiguration": {
                              "id": "/subscriptions/000000000000/resourceGroups/mygrprgrp/providers/Microsoft.Network/networkInterfaces/myrgrp-nic001/ipConfigurations/default"
                          },
                          "provisioningState": "Succeeded",
                          "publicIPAddressVersion": "IPv4",
                          "publicIPAllocationMethod": "Dynamic",
                          "resourceGuid": “fffff-4444444-cccccc"
                      },
                      "type": "Microsoft.Network/publicIPAddresses"
                  }
              ]
          },
          "changed": false
      }
  }
  </code></pre>
  
  <p>So, I guess I'm missing something, could anybody point me to the right direction?</p>