Ansible playbook shell output

后端 未结 7 1051
长发绾君心
长发绾君心 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:51

    Expanding on what leucos said in his answer, you can also print information with Ansible's humble debug module:

    - hosts: all
      gather_facts: no
      tasks:
        - shell: ps -eo pcpu,user,args | sort -r -k1 | head -n5
          register: ps
    
        # Print the shell task's stdout.
        - debug: msg={{ ps.stdout }}
    
        # Print all contents of the shell task's output.
        - debug: var=ps
    
    0 讨论(0)
提交回复
热议问题