When to use include role statement in Ansible?

When to use include role statement in Ansible?

May be used only where Ansible tasks are allowed – inside pre_tasks, tasks, or post_tasks play objects, or as a task inside a role. Task-level keywords, loops, and conditionals apply only to the include_role statement itself.

How is task includes included processed in Ansible 2.0?

In Ansible 2.0 there were changes on how ‘task’ includes are processed. The ‘play’ includes are still ‘static’ or unchanged. In previous versions of Ansible, all includes acted as a pre-processor statement and were read during playbook parsing time.

Why do tags not show up in include in Ansible?

Tags which only exist inside a dynamic include will not show up in –list-tags output. Tasks which only exist inside a dynamic include will not show up in –list-tasks output. In Ansible 1.9.x and earlier, an error would be raised if a tag name was used with –tags or –skip-tags.

Why does play get stuck in Ansible playbook?

If I run the playbook then it will get stuck because it will first run first play and tries to run second play where it gets stuck. If you do not have a task to configure the user required in the next play, then yes, it will fail (not get stuck).

How to print multiple lines of text in Ansible?

In Ansible (1.9.4) or 2.0.0 But this is not printing the variable with new lines (for the 3rd debug action)? In YAML, how do I break a string over multiple lines? The most convenient way I found to print multi-line text with debug is: – name: Print several lines of text vars: msg: | This is the first line.

How to execute a playbook in Ansible in order?

Ansible executes your playbook in this order: 1 Any pre_tasks defined in the play. 2 Any handlers triggered by pre_tasks. 3 Each role listed in roles:, in the order listed. 4 Any tasks defined in the play. 5 Any handlers triggered by the roles or tasks. 6 Any post_tasks defined in the play. 7 Any handlers triggered by post_tasks.

How to display message with formatting in Ansible?

Thanks to jhutar. The most convenient and simple way I found to display a message with formatting (ex: new lines, tabs …) is to use the pause module instead of debug module: You can also include a variable that contains formatting (new lines, tabs…) inside the prompt and it will be displayed as expected: