2
我正試圖編寫一個在linux主機中運行的進程數不等於2時顯示失敗的劇本。以下劇本的作品,但是有沒有更好的方法呢?像是有任何具體的Ansible模塊來檢查進程的Linux主機?ansible playbook:check linux process count
---
- hosts: web
become: yes
become_method: su
become_user: webuser
tasks:
- name: process check
shell: ps -ef|grep -i etas|grep -v grep|wc -l
register: command_result
failed_when: "'2' not in command_result.stdout"
謝謝。它工作完美。順便說一句我使用Ansible版本:2.2 – clicks010