-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ansible-tran test #2
Comments
Playbook Roles and Include Statements.. contents:: Topics 介绍
猜想你希望在不同 tasks 之间plays 和 playbooks 可以重复调用. include files可以达成目的. 系统通过使用 include task 来完美实现 role 定义. 记住, playbook 中的 play 最终目的是映射系统群到多 roles中. 我们来举个例子吧... 只简单包括 tasks 的 task 文件如下示例::
Include 指令类似如下,可以像普通 tasks 命令一样在 playbook 中混合使用:: tasks:
你也可以传输变量到 includes 指令, 我们称之为 'parameterized include'. 例如,如何分发多个 wordpress 实例,我可以包涵所有 wordpress 命令到一个 wordpress.yml 文件,按如下方式使用:: tasks: 如果你使用的是 Ansible 1.4以上版本(包括1.4), include 语法简化了匹配 roles, 同时允许传递参数列表和字典::
使用任意一种语法, 变量传递均可以在 included 文件中被使用. 我们将在 :doc: {{ wp_user }} (除了明确声明定义参数,所有 vars 区块定义的变量在这里同样适用.) 从1.0开始, ansible 还支持另外一种变量传参到 include files 的方式-结构化变量,方式如下::
Playbooks 也同样可以 include 引用其它 playbooks,但这部分内容将在另外章节介绍. .. note:: Includes can also be used in the 'handlers' section, for instance, if you this might be in a file like handlers/handlers.yml
And in your main playbook file, just include it like so, at the bottom handlers: You can mix in includes along with your regular non-included tasks and handlers. Includes can also be used to import one playbook file into another. This allows For example::
Note that you cannot do variable substitution when including one playbook .. note:: .. _roles: Roles
.. versionadded:: 1.3 Role default variables allow you to set default variables for included or dependent roles (see below). To create Role Dependencies
This is an advanced topic that should not be relevant for most users. If you write a custom module (see :doc: A good example for this is if you worked at a company called AcmeWidgets, and wrote an internal module that helped configure your internal software, and you wanted other Alongside the 'tasks' and 'handlers' structure of a role, add a directory named 'library'. In this 'library' directory, then include the module directly inside of it. Assuming you had this::
The module will be usable in the role itself, as well as any roles that are called after this role, as follows::
This can also be used, with some limitations, to modify modules in Ansible's core distribution, such as to use development versions of modules before they are released Ansible Galaxy
|
ansible-tran test by lisongtao
The text was updated successfully, but these errors were encountered: