Ansible playbook shell output

后端 未结 7 1163
长发绾君心
长发绾君心 2020-12-23 09:27

I would like to quickly monitor some hosts using commands like ps,dstat etc using ansible-playbook. The ansible command itself perfectly does what I want, for i

7条回答
  •  甜味超标
    2020-12-23 09:39

    This is a start may be :

    - hosts: all
      gather_facts: no
      tasks:
        - shell: ps -eo pcpu,user,args | sort -r -k1 | head -n5
          register: ps
    
        - local_action: command echo item
          with_items: ps.stdout_lines
    

    NOTE: Docs regarding ps.stdout_lines are covered here: ('Register Variables' chapter).

提交回复
热议问题