方式1. 在playbook 命令加入参数 -v 就可以打印出 register 的内容
playbook内容
[root@ansible1 ~]# cat test.yml
- hosts: localhost
gather_facts: no
tasks:- name: test with register
shell: cat /root/input.json
register: result
- name: test with register
playbook引用到的json文件内容
[root@ansible1 ~]# cat /root/input.json
{
services {
vsftpd
}
}
运行playbook
[root@ansible1 ~]# ansible-playbook -v test.yml
Using /etc/ansible/ansible.cfg as config file
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
PLAY [localhost] ***************************************************************************************************</