Hi all,

I've been trying the docker module as a way to provision containers for a 
local development environment.
I'm facing some issues.

- I declare only one host in my inventory named docker-host
- I expect the docker module to build an ssh-enabled base image and start 
some containers
- I register these containers via add_host
- I use these hosts on the rest of the playbook

This works well if those containers are not already started or if the 
requested container state is reloaded or restarted.
But when I request the started state, the docker_containers fact is empty.

- name: create docker containers
  hosts: docker-host
  tasks:
    - name: "ensure base image is build"
      docker_image: path="docker/docker-build-ubuntu-sshd-services" 
name="ubuntu/sshd-services" state=build

    - name: "ensure webapp container is started"
      docker:
        name: webapp
        image: ubuntu/sshd-services
        state: started # here, if state is "reloaded", everything works fine

    - name: "add webapp container as app-web in inventory"
      add_host: name="app-web" groups=app-web,env-dev ansible_ssh_host="{{ 
item.NetworkSettings.IPAddress }}" ansible_ssh_port=22 
ansible_ssh_user=root ansible_ssh_pass=docker
      with_items: docker_containers

    - name: "show docker containers fact"
      debug: var=docker_containers

- name: Provision web server 
  hosts: app-web
  roles:
    - php
    - ...

Command output at the second run:

TASK [debug] 
*******************************************************************
ok: [localhost] => {
    "docker_containers": []
}

I couldn't find any documentation about this docker_containers fact, I just 
found it on this post of this mailing list 
<https://groups.google.com/d/msg/ansible-project/hTRPDNkJiF8/SmsWkuycnkYJ>. 
Am I on the wrong direction ?

Thanks for your help,

Regards

PS: more infos
- Python 2.7.6
- ansible-playbook 2.0.0.2
- Docker version 1.9.1, build a34a1d5

-- 
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/9f812248-4e7b-4943-966a-c4aa4f000a7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to