You say "I suspect the "with_dict" calls because without this it works, 
weiird!".  What are you saying "works"?

The registered var from your os_server task will have the 
form 
http://docs.ansible.com/ansible/latest/playbooks_loops.html#iterating-over-the-results-of-a-program-execution
 
.  I don't think you want to use with_dict here.  


On Saturday, September 2, 2017 at 7:04:17 AM UTC-4, Soufiane Benmalek wrote:
>
> Hi,
>
> I use Ansible to create servers on OpenStack and to install mysql on it.
> All is done once, so in my code I want to register the public IP of the 
> new server and store it in my Ansible hosts file. But it does not seem to 
> work:
>
>     - name: launch an instance
>       os_server:
>         state: present
>         auth:
>           auth_url: "{{ item.value.auth_url }}"
>           username: "{{ item.value.username }}"
>           password: "{{ item.value.password }}"
>           project_name: "{{ item.value.project_name }}"
>         region_name: "{{ item.value.region_name }}"
>         name: "{{ item.value.name }}"
>         image: "{{ item.value.image }}"
>         state: present
>         network: "{{ item.value.network }}"
>         flavor: "{{ item.value.flavor }}"
>         key_name: "{{ item.value.key_name }}"
>         user_data: "{{ item.value.user_data }}"
>       with_dict: "{{ openstack_hosts }}"
>       register: mysqlserver
>     
>     
>     
>     #- set_fact: public_v4="{{ mysqlserver.server.public_v4 }}"
>     - name: output of the registred variable
>       debug:
>         var: "{{ item.key }}"
>       with_dict: "{{ openstack_hosts }}"
>
>
> If I make a debug of "mysqlserver" variable it shows me a big JSON output 
> where I can see the public IP address but "mysqlserver.server.public_v4" 
> doest not output anything. 
>
> I suspect the "with_dict" calls because without this it works, weiird!
> I need "with_dict" because I want to have many servers.
>
> Any ideas please?
>
>

-- 
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/852584b0-eba8-42a4-a932-eb3e6112d973%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to