无法获取用于管理在 ansible 中工作的 Windows 系统的模块

无法获取用于管理在 ansible 中工作的 Windows 系统的模块

我正在学习 ansible。我的笔记本电脑运行的是 Windows 7,并且是域的一部分。我在笔记本电脑上的虚拟机内安装了 Ubuntu Linux,并在其中安装了 Ansible 以及其他 python 和 kerberos 软件包。还配置了 kerberos,但无法使用 windows 模块甚至无法使用 win_ping ping 我的笔记本电脑。我认为 Ansible 仍在尝试使用 ssh 而不是 winrm。

已在 group_vars/windows.yml 文件中添加了用户和密码信息。域名为 lab.test.com

运行命令时收到的消息ansible laptop -m win_ping -vvvvv

Loaded callback minimal of type stdout, v2.0
<laptop.lab.test.com> ESTABLISH SSH CONNECTION FOR USER: None
<laptop.lab.test.com> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<laptop.lab.test.com> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredA
uthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<laptop.lab.test.com> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<laptop.lab.test.com> SSH: PlayContext set ssh_common_args: ()
<laptop.lab.test.com> SSH: PlayContext set ssh_extra_args: ()
<laptop.lab.test.com> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/home/vagrant/.ansible/cp/ansibl
e-ssh-%h-%p-%r)
<laptop.lab.test.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no
 -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPa
th=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r U0128159-TPL-B.ten.thomsonreuters.com '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOM
E/.ansible/tmp/ansible-tmp-1462196365.95-235238773027827 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1462196365.95-235238773027827 `"
)'"'"''

laptop.lab.test.com | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh.",
    "unreachable": true
}

我关注的网页是如何为 Windows 管理节点和自定义 Windows 模块设置 Ansible 测试实验室

我已经在 Google 上搜索过,但还是找不到我遇到的问题。请帮忙。

谢谢

答案1

要解决此错误,您必须在 all.yml 文件中指定一些参数来在 Windows 中验证用户。您还需要使用 pip 安装 pywinrm 模块。

pip install pywinrm

这是必须安装在控制器机器上的包。

ansible_user: Administrator
ansible_password: SecretPasswordGoesHere
ansible_port: 5986
ansible_connection: winrm

但是由于您使用 kerberos 进行身份验证,因此您可以删除ansible_password用户 kinit 来创建票证。

如果您的组织使用域,那么您需要将其添加到您的工作中。ansible_user:[email protected]

答案2

我必须修改很多东西。我写下了正确配置管理节点和其他节点的所有步骤,因为我没有在一个地方找到正确的步骤。记录了我为使 Windows 能够与 Ansible 正常工作而执行的所有步骤 -https://aseemkblog.wordpress.com/2016/06/01/configuring-ansible-to-manage-windows-system-over-powershell/

相关内容