Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Kerberos的Ansible到Windows不工作_Python_Windows_Kerberos_Ansible_Ansible Playbook - Fatal编程技术网

Python 使用Kerberos的Ansible到Windows不工作

Python 使用Kerberos的Ansible到Windows不工作,python,windows,kerberos,ansible,ansible-playbook,Python,Windows,Kerberos,Ansible,Ansible Playbook,我正在尝试使用Ansible 1.9.0.1配置使用域用户名的Windows服务器。我已经成功地安装了Linux Ansible控制盒,并且能够使用basic auth运行Ansible/Ansible playbook播放。但是,与域用户一起运行失败。已在Windows节点上启用Kerberos: winrm获取winrm/config/client/auth 认证 基本=真 摘要=真 Kerberos=true 协商=正确 证书=真 CredSSP=true 我尝试运行的剧本仅引用ansib

我正在尝试使用Ansible 1.9.0.1配置使用域用户名的Windows服务器。我已经成功地安装了Linux Ansible控制盒,并且能够使用basic auth运行Ansible/Ansible playbook播放。但是,与域用户一起运行失败。已在Windows节点上启用Kerberos:

winrm获取winrm/config/client/auth
认证
基本=真
摘要=真
Kerberos=true
协商=正确
证书=真
CredSSP=true

我尝试运行的剧本仅引用ansible的win_ping模块,以下是输出:

PLAY [Manage SMI] *************************************************************

TASK: [Ping] ******************************************************************
<host1> ESTABLISH WINRM CONNECTION FOR USER:  on PORT 5985 TO >host1
<host1> ESTABLISH WINRM CONNECTION FOR USER:  on PORT 5985 TO >host2
<host1> REMOTE_MODULE win_ping
<host1> EXEC (New-Item -Type Directory -Path $env:temp -Name >"ansible-tmp-1429639247.03-231225138744234").FullName | Write-Host -Separator >'';
<host2> REMOTE_MODULE win_ping
<host2> EXEC (New-Item -Type Directory -Path $env:temp -Name >"ansible-tmp-1429639247.03-8060403929807").FullName | Write-Host -Separator '';

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/home/deck/test.retry

host1            : ok=0    changed=0    unreachable=1    failed=0
host2            : ok=0    changed=0    unreachable=1    failed=0
PLAY[管理SMI]*************************************************************
任务:[Ping]******************************************************************
在端口5985上为用户建立到>主机1的WINRM连接
在端口5985上为用户建立到>主机2的WINRM连接
远程模块win\u ping
EXEC(新项目-类型目录-路径$env:temp-Name>“ansible-tmp-1429639247.03-231225138744234”)。全名|写入主机-分隔符>“”;
远程模块win\u ping
EXEC(新项目-类型目录-路径$env:temp-名称>“ansible-tmp-1429639247.03-8060403929807”)。全名|写入主机-分隔符“”;
致命:所有主机都已失败--正在中止
重演********************************************************************
要重试,请使用:--limit@/home/deck/test.retry
主机1:正常=0更改=0无法访问=1失败=0
主机2:正常=0更改=0无法访问=1失败=0
根据系统事件日志,用户正在正确地进行身份验证,因此看起来到tmp目录的文件传输失败


非常感谢您的帮助

一位同事找到了解决此问题的方法。在使用kerberos时,pywinrm中似乎存在一个问题,该问题导致在尝试调用Transport.py中的KerbosTicket时模块死亡。如果使用以下内容修补transport.py:

class KerberosTicket:
"""
Implementation based on http://ncoghlan_devs-python-notes.readthedocs.org/en/latest/python_kerberos.html
"""
def __init__(self, service):
    # added line below
    self.test=1
    ignored_code, krb_context = kerberos.authGSSClientInit(service)
    kerberos.authGSSClientStep(krb_context, '')
    # TODO authGSSClientStep may raise following error:
    #GSSError: (('Unspecified GSS failure.  Minor code may provide more information', 851968),
    # ("Credentials cache file '/tmp/krb5cc_1000' not found", -1765328189))
    self._krb_context = krb_context
    gss_response = kerberos.authGSSClientResponse(krb_context)
    self.auth_header = 'Negotiate {0}'.format(gss_response)

我们无法100%确定为什么会这样,但目前这是我们的解决办法。

将FQDN记录添加到/etc/hosts。这对我有用