task打印执行结果

使用debug输出task执行的register:

- name: check extract session
#  script: /app/ansiblecfg/XXX/roles/test/tasks/psgrep.sh > /home/shdxspark/psgrep.log
  script: /app/ansiblecfg/XXX/roles/test/tasks/psgrep.sh
  register: psgrep_output

#通过debug方式打印psgrep.sh脚本的返回结果psgrep_output
- debug: var=psgrep_output.stdout_lines

结果输出:

原文地址:https://www.cnblogs.com/andriy-h/p/6346903.html