ansible-playbook返回命令执行结果

[root@ysw-xx ~]# cat /home/ansible/ymls/2.yml - name: Print debug infomation eg hosts: "{{host}}" gather_facts: F tasks: - name: Command run line shell: hostname register: result - name: Show debug info debug: var=result.stdout verbosity=0 [root@ysw-xx ~]# [root@ysw-xx ymls]# ansible-playbook 2.yml -e host=上地101PLAY [Print debug infomation eg] **********************************************************************************************************TASK [Command run line] ******************************************************************************************************************* changed: [上地101]TASK [Show debug info] ******************************************************************************************************************** ok: [上地101] => { "result.stdout": "SHANGDI-DPI-101" }PLAY RECAP ******************************************************************************************************************************** 上地101: ok=2changed=1unreachable=0failed=0skipped=0rescued=0ignored=0[root@ysw-xx ymls]#

    推荐阅读