AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] ### include 介绍 使用 include 语句引用 tasks 是将 tasks 从其他文件拉取过来。 Playbook 同样可以使用 include 引用其他 playbook 文件中的 play。 ### 示例 ##### 定义被引用文件 先定义一个可以被引用的`task`文件`test.yml` 将这个文件保存到文件夹`task/test.yml`下面 ``` --- - name: this is test-1 command: cat /etc/hosts - name: this is test-2 command: cat /etc/fstab ``` ##### 引用文件 ``` --- - hosts: XXX tasks: -name: XXXX command: XXXX - include: task/test.yml #这里引用 ``` 当然,`include`也可以引用到`handler`中 ``` handlers: - include: handlers/handlers.yml ``` ***** ##### include 传递变量 方法一、 ``` tasks: - include: test.yml user=user-1 - include: test.yml user=user-2 ``` 方法二、 ``` tasks: - include: wordpress.yml vars: user: user-1 var_list: - var-1 - var-2 ```