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] ***************************************************************************************************
TASK [test with register] ******************************************************************************************
changed: [localhost] => {“changed”: true, “cmd”: “cat /root/input.json”, “delta”: “0:00:00.031795”, “end”: “2019-01-02 07:34:44.844675”, “rc”: 0, “start”: “2019-01-02 07:34:44.812880”, “stderr”: “”, “stderr_lines”: [], “stdout”: “{\n services {\n vsftpd\n }\n}”, “stdout_lines”: ["{", " services {", " vsftpd", " }", “}”]} #register的内容
PLAY RECAP *********************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0
[root@ansible1 ~]# ansible-playbook debug-register.yml
PLAY [localhost] ****************************************************************************************************
TASK [shell] ********************************************************************************************************
changed: [localhost]
TASK [debug] ********************************************************************************************************
ok: [localhost] => {
“say_hi”: {
“changed”: true,
“cmd”: “echo hello world”,
“delta”: “0:00:00.033823”,
“end”: “2019-01-04 10:20:43.640881”,
“failed”: false,
“rc”: 0,
“start”: “2019-01-04 10:20:43.607058”,
“stderr”: “”,
“stderr_lines”: [],
“stdout”: “hello world”,
“stdout_lines”: [
“hello world”
]
}
}
PLAY RECAP **********************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0