I pretend to execute a bash file inside a docker container with ansible. The firts task its sucess.
My task:
- name: Copy tickscripts
copy:
src: /home/debian/github/tick_playbook/roles/alertas
dest: /var/lib/docker/volumes/kapacitor_storage/_data/
- name: Execute tickscripts
shell: bash /var/lib/docker/volumes/kapacitor_storage/_data/alertas/run_alertas.sh
Container name: tick_kapacitor volume container: kapaciotr_sotage
Run playbook and 1 task is ok
root@teste:/# cat /var/lib/docker/volumes/kapacitor_storage/_data/alertas/
run_alertas.sh tasks/ tickscripts/
root@teste:/# cat /var/lib/docker/volumes/kapacitor_storage/_data/alertas/
#
I try also:
- name: Execute tickscripts
shell: docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh
Resp:
TASK [alertas : Execute tickscripts] *******************************************
fatal: [192.168.85.79]: FAILED! => {"changed": true, "cmd": "docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh", "delta": "0:00:00.043861", "end": "2019-03-18 17:52:50.542327", "failed": true, "rc": 1, "start": "2019-03-18 17:52:50.498466", "stderr": "the input device is not a TTY", "stdout": "", "stdout_lines": [], "warnings": []}
to retry, use: --limit @/home/debian/github/tick_playbook/teste.retry
i go to the machine and put
docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh
Resp:
var/lib/kapacitor/alertas/tickscripts/cpu99_alert_stream.tick
Remove the -ti
flag from your shell command.
It is used for starting a persistent, interactive session - neither of which you are interested in while running an Ansible play.