Ansible标记include_role不适用于ansible 2.3版

时间:2017-09-20 07:08:35

标签: ansible

我有以下剧本

- 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)]

我用谷歌搜索它说是ansible的最低版本应该是2.2,但我使用的是2.3,但它仍然让我犯了错误。

2 个答案:

答案 0 :(得分:4)

include_role是一个在任务中使用的动作模块。

对于游戏,你应该使用role指令。

答案 1 :(得分:3)

techraf是正确的,你可以在任务中使用include_role。这是我的一个角色中的tasks / main.yml的一个工作示例:

- name: intranet is a plone3 application
  include_role:
    name: plone3
    private: yes
  vars:
    plone3_version: "{{intranet_plone3_version}}"