上QQ阅读APP看书,第一时间看更新
Ansible verbosity
One of the first options that anyone picks up is the debug option. To understand what is happening when you run the playbook, you can run it with the verbose (-v) option. Every extra v will provide the end user with more debug output.
Let's see an example of using those options to debug a simple ping command (ansible all -i test01.fale.io, -m ping):
- The -v option provides the default output:
Using /etc/ansible/ansible.cfg as config file
test01.fale.io | SUCCESS => {
"changed": false,
"ping": "pong"
}
- The -vv option adds a little more information about the Ansible environment and the handlers:
ansible 2.7.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/fale/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.15 (default, Oct 15 2018, 15:24:06) [GCC 8.1.1 20180712 (Red Hat 8.1.1-5)]
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
test01.fale.io | SUCCESS => {
"changed": false,
"ping": "pong"
}
META: ran handlers
META: ran handlers
- The -vvv option adds a lot more information. For instance, it shows the ssh command that Ansible uses to create a temporary file on the remote host and run the script remotely. Full script is available on GitHub.
ansible 2.7.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/fale/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.15 (default, Oct 15 2018, 15:24:06) [GCC 8.1.1 20180712 (Red Hat 8.1.1-5)]
Using /etc/ansible/ansible.cfg as config file
Parsed test01.fale.io, inventory source with host_list plugin
META: ran handlers
<test01.fale.io> ESTABLISH SSH CONNECTION FOR USER: None
<test01.fale.io> SSH: EXEC ssh -C -o ControlMaster=auto -o
...
Now we understood what is happening when you run the playbook, with the verbose -vvv option.