Dry Run Option
Before applying any changes on your managed nodes, you might want to simulate the playbook run to understand what changes would be made. The--check option performs this dry run, allowing you to preview the operations without making any modifications.
Consider the following playbook example that installs the httpd package:
Using
--check is a valuable way to verify your playbook changes in a safe environment before enforcing them on production systems.Start at a Specific Task
Sometimes it is beneficial to run a playbook starting from a particular task, bypassing all previous tasks. The--start-at-task option lets you specify the task name from which the execution should begin.
For instance, given the following playbook:
Using Tags to Select or Skip Tasks
Tagging is an effective method to organize your playbook by grouping plays or individual tasks, enabling you to selectively run or skip parts of the playbook. You can tag tasks and plays with specific labels so that when you execute the playbook, only the tagged tasks are considered. Below is a sample playbook that applies tags to both the play and the individual tasks:Using tags effectively organizes your playbook, which helps in isolating specific parts of your automation workflow and simplifies debugging.
That concludes an overview of the additional options available for running your Ansible playbook. These options enhance your control over execution, enabling safer and more efficient automation. Stay tuned as we explore even more advanced features in our next lesson. For a deeper dive into Ansible, visit the Ansible Documentation.