summaryrefslogtreecommitdiff
path: root/docs/docsite/rst/user_guide/playbooks_reuse.rst
diff options
context:
space:
mode:
authorAlicia Cozine <879121+acozine@users.noreply.github.com>2021-12-21 10:15:48 -0600
committerGitHub <noreply@github.com>2021-12-21 11:15:48 -0500
commit67e5649a264db2696b46d9b9c80724c03c9f7527 (patch)
tree32e1c2a3d52582091a14e6c3f8ad238d8de3682e /docs/docsite/rst/user_guide/playbooks_reuse.rst
parent4c738b08b4688892acb23d58ac782a068de95f79 (diff)
downloadansible-67e5649a264db2696b46d9b9c80724c03c9f7527.tar.gz
Adds documentation about when/why to use roles (#76560)
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
Diffstat (limited to 'docs/docsite/rst/user_guide/playbooks_reuse.rst')
-rw-r--r--docs/docsite/rst/user_guide/playbooks_reuse.rst7
1 files changed, 6 insertions, 1 deletions
diff --git a/docs/docsite/rst/user_guide/playbooks_reuse.rst b/docs/docsite/rst/user_guide/playbooks_reuse.rst
index a2095ef364..f64d3ad477 100644
--- a/docs/docsite/rst/user_guide/playbooks_reuse.rst
+++ b/docs/docsite/rst/user_guide/playbooks_reuse.rst
@@ -4,7 +4,7 @@
Re-using Ansible artifacts
**************************
-You can write a simple playbook in one very large file, and most users learn the one-file approach first. However, breaking tasks up into different files is an excellent way to organize complex sets of tasks and reuse them. Smaller, more distributed artifacts let you re-use the same variables, tasks, and plays in multiple playbooks to address different use cases. You can use distributed artifacts across multiple parent playbooks or even multiple times within one playbook. For example, you might want to update your customer database as part of several different playbooks. If you put all the tasks related to updating your database in a tasks file, you can re-use them in many playbooks while only maintaining them in one place.
+You can write a simple playbook in one very large file, and most users learn the one-file approach first. However, breaking your automation work up into smaller files is an excellent way to organize complex sets of tasks and reuse them. Smaller, more distributed artifacts let you re-use the same variables, tasks, and plays in multiple playbooks to address different use cases. You can use distributed artifacts across multiple parent playbooks or even multiple times within one playbook. For example, you might want to update your customer database as part of several different playbooks. If you put all the tasks related to updating your database in a tasks file or a role, you can re-use them in many playbooks while only maintaining them in one place.
.. contents::
:local:
@@ -44,6 +44,11 @@ You can select which playbook you want to import at runtime by defining your imp
If you run this playbook with ``ansible-playbook my_playbook -e import_from_extra_var=other_playbook.yml``, Ansible imports both one_playbook.yml and other_playbook.yml.
+When to turn a playbook into a role
+===================================
+
+For some use cases, simple playbooks work well. However, starting at a certain level of complexity, roles work better than playbooks. A role lets you store your defaults, handlers, variables, and tasks in separate directories, instead of in a single long document. Roles are easy to share on Ansible Galaxy. For complex use cases, most users find roles easier to read, understand, and maintain than all-in-one playbooks.
+
Re-using files and roles
========================