Script to be run from the ansible module docker_container

13 views
Skip to first unread message

MHM Reddy

unread,
Nov 10, 2016, 1:38:56 PM11/10/16
to Ansible Project
Hi All,

I am very new to ansible and trying to explore.
I have requirement of launching docker container out of my box and execute series of scripts in the docker container.

  - name: Execute xpcgen inside the container
    docker_container:
      image: ubuntu-xpc
      name: XPCGEN
      volumes_from: CREATE_CONTAINER
      command: "{{ view_path }}/{{ compile_path }}/script.sh"
      state: started
    register: xpcgen
  - debug: var=xpcgen

The above code is written in my ansible yml file and it suppose to create a docker container out of my customized docker image ubuntu-xpc and script "script.sh" to be run from the docker container.
But the problem here is, the commands inside the script will be initiated and ansible will comeout without any errors.
When i checked docker logs, the log will say, the process has started.
But ansible is not waiting until the script finishes its job.
Any help would be higly appreciable.

Thanks,
MHM
Reply all
Reply to author
Forward
0 new messages