作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下剧本
- name: Restart Apache Server
hosts: "{{ host }}"
include_role:
name: root
tasks_from: apache-restart.yml
become: true
become_user: root
当我运行此剧本时,它抛出以下错误
ERROR! 'include_role' is not a valid attribute for a Play
The error appears to have been in '/Users/Atul/Workplace/infra-automation/deployments/LAMP/site.yml': line 18, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Restart Apache Server
^ here
以下是我的笔记本电脑中安装的 Ansible 的详细信息。
ansible 2.3.1.0
config file = /Users/Atul/Workplace/infra-automation/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.13 (default, Apr 4 2017, 08:47:57) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]
最佳答案
include_role
是一个在任务中使用的操作模块。
对于游戏,您应该使用类似于 https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#using-roles 的 role
指令。 .
关于Ansible 标签 include_role 不适用于 ansible 版本 2.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46315413/
经过大量搜索,我得出的结论是 ansible(我使用的是目前最新的稳定版 v2.5.3)很可能不支持注册来自 include_role 的变量或通知。和 import_role声明。 有一个类似的问题
include_role 和 delegate_to 在 Ansible 2.9 中是否一起工作,因为我试图通过运行角色并将其委派给主机 2(下面的代码)来执行以下剧本? Ansible 手册 - n
我有以下剧本 - name: Restart Apache Server hosts: "{{ host }}" include_role: name: root tasks_
我是一名优秀的程序员,十分优秀!