官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 蒙城县| 白朗县| 唐山市| 兴仁县| 于田县| 互助| 宁蒗| 南川市| 汝州市| 武陟县| 南城县| 林甸县| 东丰县| 龙口市| 洛扎县| 海口市| 丰县| 耒阳市| 饶河县| 南投市| 郯城县| 丽江市| 台湾省| 密山市| 谷城县| 兴宁市| 涿鹿县| 赤城县| 韩城市| 巩留县| 麦盖提县| 金山区| 敦化市| 吉安县| 栾川县| 惠来县| 万安县| 康保县| 东宁县| 合作市| 凤山市|