https://www.yuque.com/docs/share/1ba5577f-8902-4381-a6a9-2828f160fa80
1. 查看服务是否是运行状态
- name: Check docker daemon status
shell: echo `service docker status`
register: docker_daemon_status
- name: Remove container registry
shell: docker ps -a| grep -v CONTAINER| awk '{print $1}'| xargs docker rm -fv
when: docker_daemon_status.stdout.find(" active (running) ") != -1
说明:
- 上面是先查看docker daemon的状态,如果是active状态,那么删除所有的容器及容器挂载的volume(-v)
- find() == "-1" 表示没有找到
2. 删除目录
- name: Remove /var/lib/docker/registry
file:
path: /var/lib/docker/registry
state: absent
3. 本地执行远程节点上的命令
- name: Get k8s nodes reserve for paas
shell: ssh 10.11.11.1 "kubectl get nodes | grep -v NAME | grep -v master |cut -d ' ' -f 1"
4. shell模块使用方法
- name: Agility deploy k8s
shell: echo my_param
args:
chdir: "/tmp/"
my_param: "guan"
说明:
- chdir: 修改执行路径
- my_param:参数