How to connect to cdh docker image using Ansible

I want to use Hadoop from CDH docker image. CDH image is already installed on my machine and I can run it.

docker ps -a

CONTAINER ID        IMAGE               COMMAND                        CREATED             STATUS              PORTS                                              NAMES
07a55a9d4cb9        4239cd2958c6        "/usr/bin/docker-quickstart"   18 minutes ago      Up 18 minutes       0.0.0.0:32774->7180/tcp, 0.0.0.0:32773->8888/tcp   container

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container

172.17.0.2

Local, I am writing an ansible playbook and I need to set Hadoop conf dir in CDH which is: “/etc/hadoop/conf”. How can I set the running docker image in my ansible playbook?

I tried:

- name: run cloudera
  docker_container:
    name: "container"
    image: quickstart/cloudera
    command: /usr/bin/docker-quickstart"
    state: started
    ports:
      - 8888:8888
      - 7180:7180

But this command runs another docker image and I would like to connect to the running one.

Probably the easiest thing to do is forward a port to ssh in your container when you launch it and then connect to that in Ansible like a standard host. That should be quite easy to do.

A quick google also shows this…

https://docs.ansible.com/ansible/latest/plugins/connection/docker.html

Not used it but again it looks simple enough.

R