Hi,

since Ansible 2.0 it is possible to deploy directly to a docker container 
via connection=docker. Now I want to create a Role which is starting a 
Docker container and deploying some stuff to it. Here is an arbitrary 
example of my current solution:

- name: create docker container
  docker:
    name: mycontainer
    image: my/container
    ports:
      - "2222:22"
    state: running

- name: add aci_jenkins to inventory
  add_host:
    name: mycontainer
    ansible_connection: docker

- name: copy jenkins private key
  delegate_to: mycontainer
  copy:
    content: "{{ ID_RSA }}"
    dest: /home/user/.ssh/id_rsa
    mode: 0700

This approach works quite fine since I deploy the role on my localhost. 
Because the deletage_to directive is delegating from the ansible machine 
(my localhost) it will find the docker container started. If I deploy the 
Role on a remote host, the container will be started on the remote host, 
but the delegate_to directive will looking for the container on the local 
host. Currently there is no documentation of the docker connection. Does 
anybody know how I redirect the docker connection to the remote host I 
started the container in?

-- 
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/3f07ef59-aace-4eca-80af-049283871a15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to