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

Using the preview or dry run option

When coding an Ansible playbook, we often need to test different steps without applying them directly to infrastructure. Hence, it is very useful, especially in the automation of VM configuration with Ansible, to have a preview of its execution, to check that the syntax of the playbook is maintaining good consistency with the system configuration that already exists on the host.

With Ansible, it's possible to check the execution of a playbook on hosts by adding the --check option to the command:

ansible-playbook -i inventory playbook.yml --check

Here is an example of this dry run execution:

With this option, Ansible does not apply configuration changes on the host; it only checks and previews the changes made to the hosts.

For more information on the  --check option, refer to the following documentation:  https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html.

We have just seen that Ansible allows us to check a playbook before applying it only on a host; it is also necessary to know that there are other tools to test the good functioning of a playbook (without having to simulate its execution), such as Vagrant by HashiCorp.

Vagrant allows us to locally create a test environment composed of VMs very quickly, on which we can really run our playbooks and see the real results of their executions. For more information on the use of Ansible and Vagrant, refer to the documentation here: https://docs.ansible.com/ansible/latest/scenario_guides/guide_vagrant.html.

We have just seen how to preview the changes that will be applied by Ansible. Now, let's look at how to increase the log level output of Ansible's execution.

主站蜘蛛池模板: 桓仁| 黄陵县| 夏河县| 安塞县| 夹江县| 白沙| 庄浪县| 康乐县| 西畴县| 罗江县| 东兰县| 江陵县| 远安县| 鹤庆县| 静乐县| 盈江县| 陆丰市| 大关县| 苍梧县| 汝城县| 文登市| 彰化县| 额敏县| 潜江市| 元朗区| 县级市| 镇远县| 保德县| 罗田县| 美姑县| 宁河县| 肥西县| 阿瓦提县| 喀什市| 深州市| 北碚区| 柏乡县| 扬州市| 舟山市| 修文县| 师宗县|