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=上地101

PLAY [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=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[root@ysw-xx ymls]# 

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容