【问题标题】:using Ansible for netstat command and format on playbook在 playbook 上使用 Ansible for netstat 命令和格式
【发布时间】:2020-01-16 11:07:06
【问题描述】:

使用ansible运行一个nesat命令,然后使用grep获取IP地址

但是当它在剧本中运行时,很难从终端读取。看起来格式已关闭,但IP 地址也没有回来。

我已经在选择的服务器上测试了这个命令,它完成了它应该做的事情

 - name: netstat check
       command: netstat -tulnp | awk grep -e 'PADDRESS HERE'
       register: netstat
 - debug: msg="{{netstat.stdout}}"

任何帮助都会很棒

【问题讨论】:

    标签: python linux unix ansible


    【解决方案1】:

    您可以尝试以下方法来获得正确的格式

    - debug: msg="{{netstat.stdout_lines}}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-09
      • 1970-01-01
      • 1970-01-01
      • 2019-11-21
      • 2018-02-06
      • 2020-03-28
      相关资源
      最近更新 更多