【发布时间】:2018-10-06 20:44:52
【问题描述】:
我想将剧本中的特定任务运行到单个主机。有没有更好的方法来做到这一点?
自定义剧本
---
- hosts: swarm_manager
roles:
- custom_role
roles/custom_role/tasks/main.yml
---
- name: checking for ip
shell: docker service ps service | grep Running | head -n1 | awk '{print $1}'
register: ip
- name: killing the container
**hosts: "{{ip.stdout}}"**
shell: docker kill $(docker service ps | grep service | awk '{print $1}')
【问题讨论】:
标签: linux automation ansible devops