从Ansible在Windows上安装IIS

时间:2017-07-27 08:47:21

标签: linux windows ansible yaml

我的主机上配置了我的ansible - Linux 16.06 LTS,我成功地使用ansible windows -m win_ping命令ping我的服务器。

现在我尝试在我的服务器上安装IIS。我在group_vars文件夹中创建了一个名为installIIS.yml。

的YAML文件
---
- name: Install IIS
  hosts: windows
  gather_facts: true
  tasks:
   - win_feature:
     name: "windows"
     state: present
     restart: yes
     include_sub_features: yes
     include_management_tools: yes

并运行yml文件:root@SAUPRDSVR01:/etc/ansible# ansible-playbook group_vars/installIIS.yml

我收到的错误是

ERROR! 'include_sub_features' is not a valid attribute for a Task

The error appears to have been in '/etc/ansible/group_vars/installIIS.yml': line 6, column 6, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
   - win_feature:
     ^ here

对此有任何帮助。我还想安装防病毒软件,tripwire并检查来自ansible的Windows更新。

/etc/ansible# tree
.
├── ansible.cfg
├── group_vars
│   ├── installIIS.yml
│   ├── linux.yml
│   └── windows.yml
├── hosts
└── roles

任何帮助或链接。先感谢您。

2 个答案:

答案 0 :(得分:2)

我认为问题是您为win_feature指定选项的缩进级别。选项应在win_feature模块下缩进,而不是在同一级别。

示例:

---
- name: Install IIS
  hosts: windows
  gather_facts: true
  tasks:
   - win_feature:
       name: "windows"
       state: present
       restart: yes
       include_sub_features: yes
       include_management_tools: yes

答案 1 :(得分:0)

如果要安装IIS,则win_feature的名称应正确:

  • 名称:安装IIS 主持人:windows collect_facts:是 任务:
    • win_feature: 名称:Web服务器 状态:存在 重新启动:是 include_sub_features:是 include_management_tools:是