我有一组Windows主机
[WindowsHostsProduction]
WinServer2016_a ansible_host=x.x.x.36
WinServer2016_g ansible_host=x.x.x.44
WinServer2016_p ansible_host=x.x.x.44
WinServer2016_z ansible_host=x.x.x.44
WinServer2016_e ansible_host=x.x.x.44
[WindowsHostsProduction:vars]
ansible_user =xxx
ansible_password =xxx
ansible_port = 5986
ansible_connection = winrm
ansible_winrm_server_cert_validation = ignore
ansible_winrm_transport=basic
然后我使用类似这样的剧本:
---
- name: Install Cygwin on win hosts
hosts: WindowsHostsProduction
gather_facts: false
tasks:
- name: Check installation of cygwin
win_stat:
path: C:\cygwin
register: stat_file
- name: create infrastructure
win_shell: mkdir C:\cygwinx64
when: stat_file.stat.exists == False
- name: copy exe files
win_copy: src=/etc/ansible/psscenario/InCggWin.ps1 dest=C:\cygwinx64\InCggWin.ps1
when: stat_file.stat.exists == False
- name: install cygwin
win_shell: C:\cygwinx64\InCggWin.ps1
when: stat_file.stat.exists == False
我的脚本仅在5台服务器上运行2台,但是如果我启用了收集事实,那么我对5台服务器都进行了测试连接。
我认为这是一个字符串。Ansible尝试仅在两个第一台服务器上进行连接
TASK [create infrastructure] ******************************************************************************************************************************************************************
task path: /etc/ansible/scripts/AnCygInst.yml:14
skipping: [WinServer2016_a] => {
"changed": false,
"skip_reason": "Conditional result was False"
}
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_shell.ps1
<x.x.x.44> ESTABLISH WINRM CONNECTION FOR USER: AnsibleManager on PORT 5986 TO x.x.x.44
checking if winrm_host x.x.x.44 is an IPv6 address
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_shell.ps1
<x.x.x.44> ESTABLISH WINRM CONNECTION FOR USER: AnsibleManager on PORT 5986 TO x.x.x.44
checking if winrm_host x.x.x.44 is an IPv6 address
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_shell.ps1
<x.x.x.44> ESTABLISH WINRM CONNECTION FOR USER: xxx on PORT 5986 TO x.x.x.44
checking if winrm_host x.x.x.44 is an IPv6 address
EXEC (via pipeline wrapper)
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_shell.ps1
<x.x.x.44> ESTABLISH WINRM CONNECTION FOR USER: xxx on PORT 5986 TO x.x.x.44
但是:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ansible WindowsHostsProduction -i hosts -m win_ping
WinServer2016_z | SUCCESS => {
"changed": false,
"ping": "pong"
}
WinServer2016_g | SUCCESS => {
"changed": false,
"ping": "pong"
}
WinServer2016_p | SUCCESS => {
"changed": false,
"ping": "pong"
}
WinServer2016_e | SUCCESS => {
"changed": false,
"ping": "pong"
}
WinServer2016_a | SUCCESS => {
"changed": false,
"ping": "pong"
}
提供帮助,但我认为所有人都说Ansible不适用于Windows:)