MySQL服务为running时,停止MySQL服务
[root@m01 ansible-playbook]# cat test_1103.yml --- - hosts: webserver tasks: - file: path=/tmp/{{ item }} state=touch with_items: - a.txt - b.txt - hosts: db01 tasks: - shell: /etc/init.d/mysqld status register: result # - shell: echo "{{ result.stdout }}" >>/tmp/aa.txt - service: name=mysqld state=stopped when: result.stdout.find('running') != -1 [root@db01 ~]# /etc/init.d/mysqld status SUCCESS! MySQL running (1356) [root@db01 ~]# /etc/init.d/mysqld status ERROR! MySQL is not running
转自
ansible result.stdout.find('running') != -1 判断状态 - 滴滴滴 - 博客园
https://www.cnblogs.com/gaoyuechen/p/7776376.html
标签:stdout,running,ansible,result,MySQL,find From: https://www.cnblogs.com/paul8339/p/17023899.html