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

  • Learning DevOps
  • Mikael Krief
  • 266字
  • 2021-06-24 12:32:12

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.

主站蜘蛛池模板: 郁南县| 吉安县| 长春市| 郧西县| 海口市| 贵州省| 贵定县| 余江县| 都安| 加查县| 利川市| 滦平县| 本溪| 施甸县| 义马市| 宣武区| 井陉县| 蕉岭县| 闸北区| 峨眉山市| 郸城县| 黔西| 衡阳市| 公安县| 石林| 伊金霍洛旗| 广灵县| 鹤庆县| 襄垣县| 金湖县| 防城港市| 清流县| 蒙阴县| 平陆县| 乌苏市| 克拉玛依市| 灵台县| 桑植县| 怀来县| 桑植县| 农安县|