Ansible 执行命令 shell bash 到 docker 容器或卷
Ansible execute a command shell bash to docker container or volume
我假装使用 ansible 在 docker 容器中执行 bash 文件。第一个任务成功。
我的任务:
- 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
容器名称:tick_kapacitor
体积容器:kapaciotr_sotage
运行 剧本和 1 个任务就可以了
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/
#
我也试试:
- name: Execute tickscripts
shell: docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh
回复:
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
我去机器把
docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh
回复:
var/lib/kapacitor/alertas/tickscripts/cpu99_alert_stream.tick
从您的 shell 命令中删除 -ti
标志。
它用于启动持久的交互式会话 - 在 运行 Ansible 播放时您对这两者都不感兴趣。
我假装使用 ansible 在 docker 容器中执行 bash 文件。第一个任务成功。
我的任务:
- 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
容器名称:tick_kapacitor 体积容器:kapaciotr_sotage
运行 剧本和 1 个任务就可以了
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/
#
我也试试:
- name: Execute tickscripts
shell: docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh
回复:
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
我去机器把
docker exec -ti tick_kapacitor /bin/bash var/lib/kapacitor/alertas/run_alertas.sh
回复:
var/lib/kapacitor/alertas/tickscripts/cpu99_alert_stream.tick
从您的 shell 命令中删除 -ti
标志。
它用于启动持久的交互式会话 - 在 运行 Ansible 播放时您对这两者都不感兴趣。