【问题标题】:Ansible Kerberos Name or service not knownAnsible Kerberos 名称或服务未知
【发布时间】:2019-05-17 23:03:12
【问题描述】:

我已经遇到了 3 天的关于在 CentO(控制机器)上设置 Ansible 以与 Windows 主机一起使用的问题。

我从 here 运行 ConfigureRemotingForAnsible.ps1 来配置 Windows 主机。为了确保 WinRM 设置正确,我还使用另一个 Windows 来验证两件事:

  • 运行Test-NetConnection -ComputerName 'win1.domain.local' -Port 5985/5986
  • 运行Test-WsMan -ComputerName 'win1.domain.local' -Port 5985/5986

从测试基于 Windows 的控制机器来看,一切都很好。我设法创建了一个 PSSession 并远程执行了脚本。

在 CentOs 机器上,我使用 telnet 来测试正在监听的端口 5985 和 5986。

我的 group_vars/win.yml 如下:

ansible_user: user@domain.local
ansible_password: Password
ansible_connection: winrm
ansible_winrm_transport: kerberos
ansible_port: 5986
ansible_winrm_server_cert_validation: ignore

我的主机只是如下机器的 FQDN

[win]
win1.domain.local

我的测试命令

ansible-playbook -i hosts playbook.yml -vvvv

我的剧本很简单。只是检查目标 Windows 主机上的 C: 目录。到目前为止我总是遇到这个问题:

Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/setup.ps1
Pipelining is enabled.
<win1.domain.local> ESTABLISH WINRM CONNECTION FOR USER: user@domain.local on PORT 5986 TO win1.domain.local
calling kinit with subprocess for principal user@domain.local
/usr/lib/python2.7/site-packages/winrm/transport.py:299: UserWarning: Function <unbound method HTTPKerberosAuth.__init__> does not contain optional arg force_preemptive, check installed version with pip list
  % (str(function), name))
/usr/lib/python2.7/site-packages/winrm/transport.py:299: UserWarning: Function <unbound method HTTPKerberosAuth.__init__> does not contain optional arg delegate, check installed version with pip list
  % (str(function), name))
/usr/lib/python2.7/site-packages/winrm/transport.py:299: UserWarning: Function <unbound method HTTPKerberosAuth.__init__> does not contain optional arg send_cbt, check installed version with pip list
  % (str(function), name))
/usr/lib/python2.7/site-packages/winrm/transport.py:299: UserWarning: Function <unbound method HTTPKerberosAuth.__init__> does not contain optional arg principal, check installed version with pip list
  % (str(function), name))
/usr/lib/python2.7/site-packages/winrm/transport.py:299: UserWarning: Function <unbound method HTTPKerberosAuth.__init__> does not contain optional arg sanitize_mutual_error_response, check installed version with pip list
  % (str(function), name))
/usr/lib/python2.7/site-packages/winrm/transport.py:299: UserWarning: Function <unbound method HTTPKerberosAuth.__init__> does not contain optional arg hostname_override, check installed version with pip list
  % (str(function), name))
fatal: [win1.domain.local]: UNREACHABLE! => {
    "changed": false, 
    "msg": "kerberos: HTTPSConnectionPool(host='win01-wmy4anstz.daa.local', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f30681818d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))", 
    "unreachable": true
}

我不确定我错过了什么。我确实使用我的帐户 user@domain.local 测试了 kerberos 票证,但没有发现任何问题。

下面是我的包的版本

  • Ansible:2.8.0
  • Pywinrm: 0.3.0
  • pykerberos:1.2.1
  • 请求-kerberos:0.12.0

【问题讨论】:

  • 您是否遵循了错误信息的建议? pip list | grep pywinrm => 根据documentation 你应该有 "pywinrm>=0.3.0"`
  • @Zeitounator 是的 pywinrm 是 0.3.0
  • 那么下一步大概是通过troubleshouting kerberos doc,更具体的这个评论:The forward and reverse DNS lookups are working properly in the domain. To test this, ping the windows host by name and then use the ip address returned with nslookup. The same name should be returned when using nslookup on the IP address.

标签: windows ansible


【解决方案1】:

我在我们的一台 Windows 2016 服务器上遇到了同样的问题,但通过故障排除指南没有成功。

最后我发现这是服务器名称大小写的问题。在我的库存文件中,我有它-

hosts:
  server-win01.domain.local

ping server-win01.domain.local 没问题。 当我进行反向查找时,返回的值是:Server-Win01.domain.local。我们的一名员工在 Active Directory DNS 中以大写命名。当我将主机名更改为

hosts:
  Server-Win01.domain.local

ansible 可以找到主机并且 playbook 执行得很好。

【讨论】:

    猜你喜欢
    • 2016-11-10
    • 2013-08-08
    • 2016-01-06
    • 2019-07-07
    • 1970-01-01
    • 2021-08-19
    • 2018-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多