我试图从Fedora虚拟盒子中安装的Ansible连接Windows 2016计算机。我已经在我的fedora机器上安装了python-pip和Pywinrm。
当我尝试使用以下命令进行连接
ansible all -i hosts -m win_ping -vvv
我犯了以下错误
ansible 2.8.0
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.7.3 (default, May 11 2019, 00:45:16) [GCC 8.3.1 20190223
(Red Hat 8.3.1-2)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /home/ansible/hosts as it did not pass it's
verify_file() method
script declined parsing /home/ansible/hosts as it did not pass it's
verify_file() method
auto declined parsing /home/ansible/hosts as it did not pass it's
verify_file() method
Parsed /home/ansible/hosts inventory source with ini plugin
META: ran handlers
Using module file /usr/lib/python3.7/site-
packages/ansible/modules/windows/win_ping.ps1
Pipelining is enabled.
xx.xxx.xx.xxx | FAILED! => {
"msg": "winrm or requests is not installed: No module named 'winrm'"
}
下面是我使用的主机文件
[win]
xx.xxx.xx.xxx
[win:vars]
ansible_user=UserName.admin@test.com
ansibe_password=Password
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
答案 0 :(得分:1)
尝试通过所需的python二进制文件作为模块-m pip
运行pip:
python3 -m pip install --user --ignore-installed pywinrm
然后对其进行测试:
测试python是否可以找到winrm
模块:
import winrm
s = winrm.Session('windows:5985', auth=('user', 'password'))
r = s.run_cmd('ipconfig', ['/all'])
print(r.status_code)
print(r.std_out.splitlines(True))
测试Ansible是否有权访问winrm
模块和您的目标:
ansible windows -i inventory.ini -m win_ping
答案 1 :(得分:0)
我也搜索了很长时间,终于为我找到了
请勿在虚拟环境中运行此命令,而应在基本环境中运行
pip install pywinrm
我的python版本:3.7.3
我的点子版本:pip 19.3.1 from /Users/darcy/code/miniconda3/lib/python3.7/site-packages/pip (python 3.7)
pywinrm版本:0.4.1