Say I've created a docker host with the docker_image and docker modules.

In the same playbook where I apply the role that creates the host, I'd like 
to apply a role to the newly created host.

The problem I'm running into is ansible's inventory doesn't know about the 
newly created host.  How can ansible know about the new host?  A dynamic 
inventory script that queries docker to return the hosts and IPs doesn't do 
it because of the caching ansible does.  Using that dynamic inventory 
script I have to call ansible on that playbook twice to get the desired 
result.

Anybody got any ideas or different approaches?


Here's a playbook to illustrate:

- hosts: localhost
  sudo: True
  roles:
    - { role: phusion-baseimage-ubuntu-14.04-docker, new_hostname: limbo }

- hosts: limbo
  roles:
    - limbo-packages


And here's the role main task:

- name: check or build container for {{ new_hostname }}
  docker_image: >
    path="docker-files/{{ new_hostname }}"
    name="xxx/limbo"
    state=present

- name: bring up container for {{ new_hostname }}
  docker: >
    dns=8.8.8.8
    hostname={{ new_hostname }}
    image=xxx/limbo
    state=present
    name="{{ new_hostname }}"
    expose=22
    ports="127.0.0.1:5022:22"


-- 
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/ca329c67-2a0b-446f-bc62-60d377a20b68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to