我的 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
关于此的任何帮助。我还想安装防病毒软件,绊线,并从ansible检查Windows更新。
/etc/ansible# tree
.
├── ansible.cfg
├── group_vars
│ ├── installIIS.yml
│ ├── linux.yml
│ └── windows.yml
├── hosts
└── roles
对此的任何帮助或链接。提前谢谢你。
我认为问题是您在其中指定win_feature
选项的缩进级别。这些选项应在win_feature
模块下缩进,而不是在同一级别上。
例:
---
- name: Install IIS
hosts: windows
gather_facts: true
tasks:
- win_feature:
name: "web-server"
state: present
restart: yes
include_sub_features: yes
include_management_tools: yes
win_feature文档以供参考
如果您正在安装IIS,则win_feature的名称应该是正确的:
- name: Install IIS
hosts: windows
gather_facts: true
tasks:
- win_feature:
name: Web-Server
state: present
restart: yes
include_sub_features: yes
include_management_tools: yes