从 Ansible 在 Windows 上安装 IIS

Tar*_*der 2 linux windows yaml ansible

我的 ansible 已在我的主机 - Linux 16.06 LTS 上配置,并且我能够使用该ansible windows -m win_ping命令成功 ping 我的服务器。

\n\n

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

\n\n
---\n- name: Install IIS\n  hosts: windows\n  gather_facts: true\n  tasks:\n   - win_feature:\n     name: "windows"\n     state: present\n     restart: yes\n     include_sub_features: yes\n     include_management_tools: yes\n
Run Code Online (Sandbox Code Playgroud)\n\n

我通过以下方式运行 yml 文件:root@SAUPRDSVR01:/etc/ansible# ansible-playbook group_vars/installIIS.yml

\n\n

我收到的错误是

\n\n
ERROR! \'include_sub_features\' is not a valid attribute for a Task\n\nThe error appears to have been in \'/etc/ansible/group_vars/installIIS.yml\': line 6, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n   - win_feature:\n     ^ here\n
Run Code Online (Sandbox Code Playgroud)\n\n

有关于此的任何帮助。我还想安装防病毒软件、tripwire 并检查 ansible 的 Windows 更新。

\n\n
/etc/ansible# tree\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ansible.cfg\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 group_vars\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 installIIS.yml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 linux.yml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 windows.yml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hosts\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 roles\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n

小智 7

我认为问题在于您指定 的选项的缩进级别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
Run Code Online (Sandbox Code Playgroud)

win_feature文档供参考