Ansible netscaler module got error "msg": "'NoneType' object has no attribute 'read'"

时间:2016-04-15 14:57:33

标签: ansible netscaler

Had any tried to use Ansible (ansible 1.9.4) Netscaler module ? I tried to use it but failed with error:

ansible localhost  -m netscaler -a  "nsc_host=nsc.example.com  user=nscuser password=nscpassword  name=node1.example.com type=service action=disable validate_certs=False"


localhost | FAILED >> {
    "failed": true,
    "msg": "'NoneType' object has no attribute 'read'"
}

with -vvvv output:

<localhost> REMOTE_MODULE netscaler nsc_host=nsc.example.com    user= nscuser     password=VALUE_HIDDEN name=node1.example.com type=service action=disable validate_certs=False
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1460868653.22-66856743808206 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1460868653.22-66856743808206 && echo $HOME/.ansible/tmp/ansible-tmp-1460868653.22-66856743808206']
<localhost> PUT /tmp/tmpAfQPY2 TO /home/supp/.ansible/tmp/ansible-tmp-1460868653.22-66856743808206/netscaler
<localhost> EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8    /usr/local/bin/python2.7 /home/supp/.ansible/tmp/ansible-tmp-1460868653.22- 66856743808206/netscaler; rm -rf /home/supp/.ansible/tmp/ansible-tmp- 1460868653.22-66856743808206/ >/dev/null 2>&1']
localhost | FAILED >> {
    "failed": true,
    "msg": "'NoneType' object has no attribute 'read'"
}

with unusable 1.9.5:

/usr/bin/ansible --version
ansible 1.9.5
  configured module search path = None


/usr/bin/ansible localhost -m netscaler -a  "nsc_host=nsc.example.com    user= nscuser     password=VALUE_HIDDEN name=node1.example.com type=service action=disable  validate_certs=False" -vvvv

<localhost> REMOTE_MODULE netscaler nsc_host=nsc.example.com    user= nscuser     password=VALUE_HIDDEN name=node1.example.com type=service action=disable validate_certs=False
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1460873442.75-215681661318620 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1460873442.75-215681661318620 && echo $HOME/.ansible/tmp/ansible-tmp-1460873442.75-215681661318620']
<localhost> PUT /tmp/tmpiN_wRf TO /home/supp/.ansible/tmp/ansible-tmp-1460873442.75-215681661318620/netscaler
<localhost> EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8    /usr/bin/python26 /home/supp/.ansible/tmp/ansible-tmp-1460873442.75-215681661318620/netscaler; rm -rf /home/supp/.ansible/tmp/ansible-tmp-1460873442.75-215681661318620/ >/dev/null 2>&1']
localhost | FAILED >> {
    "failed": true,
    "msg": "'NoneType' object has no attribute 'read'"
}

note: localhost is not NETSCALER, it is a manage host.

I also tried to use the module in playbook but still failed.

Hope to hear suggestion from you .

Thanks.

1 个答案:

答案 0 :(得分:0)

虽然错误信息量不大,但问题是连接问题。 该模块无法连接到netscaler。 检查您的网络连接&amp;确保没有防火墙。

根本原因来自

response, info = fetch_url(self.module, request_url, data=data_json, headers=headers)
return json.load(response)

&#34;响应&#34;什么都没有回来所以如果&#34;没有&#34;类型,所以json.load无法读取无。

有一个更有帮助的错误处理的拉取请求位于https://github.com/ansible/ansible-modules-extras/pull/2327