[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]#
网友评论