8000 mqtt: make tls_version configurable · Issue #22034 · ansible/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
mqtt: make tls_version configurable #22034
Closed
@lemoer

Description

@lemoer
ISSUE TYPE
  • Bug Report
  • Feature Idea
COMPONENT NAME

mqtt

ANSIBLE VERSION
2.3.0
CONFIGURATION
OS / ENVIRONMENT

ArchLinux

SUMMARY

I think this is both: a feature request and a bug report. I suggest the following:

--- mqtt.py	2017-02-28 03:44:10.781759356 +0100
+++ modules/notification/mqtt.py	2017-02-28 04:02:55.077279631 +0100
@@ -192,21 +192,16 @@
     tls=None
     if ca_certs is not None:
         tls = {'ca_certs': ca_certs, 'certfile': certfile,
-               'keyfile': keyfile}
+               'keyfile': keyfile, "tls_version": tls_version}

with tls_version as configurable option from inside the role.

STEPS TO REPRODUCE

Here seems nothing really special. Nearly the suggested config in ansible-doc:

- hosts: foo03
  tasks:
  - name: foobar
    mqtt:
      topic: '/node/s/bar/blub'
      payload: '{{ ansible_fqdn }}'
      qos: 1
      client_id: me001
      ca_certs: ssl/ca.crt
      certfile: ssl/client.crt
      keyfile: ssl/client.key
      server: server
      port: "1883"
    delegate_to: localhost

paho.mqtt.__version__ = 1.2

EXPECTED RESULTS

A running playbook

ACTUAL RESULTS

Without setting a tls_version I get this exception:

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_8ufk80/ansible_module_mqtt.py", line 218, in <module>
    main()
  File "/tmp/ansible_8ufk80/ansible_module_mqtt.py", line 208, in main
    raise e
TypeError: an integer is required

fatal: [sn03 -> localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_8ufk80/ansible_module_mqtt.py\", line 218, in <module>\n    main()\n  File \"/tmp/ansible_8ufk80/ansible_module_mqtt.py\", line 208, in main\n    raise e\nTypeError: an integer is required\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

After removing the catch-all statement, I get the following stacktrace:

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_Nn0dqs/ansible_module_mqtt.py", line 213, in <module>
    main()
  File "/tmp/ansible_Nn0dqs/ansible_module_mqtt.py", line 204, in main
    tls=tls)
  File "/usr/lib/python2.7/site-packages/paho/mqtt/publish.py", line 223, in single
    multiple([msg], hostname, port, client_id, keepalive, will, auth, tls, protocol, transport)
  File "/usr/lib/python2.7/site-packages/paho/mqtt/publish.py", line 174, in multiple
    client.connect(hostname, port, keepalive)
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 686, in connect
    return self.reconnect()
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 821, in reconnect
    ciphers=self._tls_ciphers)
  File "/usr/lib/python2.7/ssl.py", line 943, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 549, in __init__
    self._context = SSLContext(ssl_version)
  File "/usr/lib/python2.7/ssl.py", line 347, in __new__
    self = _SSLContext.__new__(cls, protocol)
TypeError: an integer is required

fatal: [sn03 -> localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_Nn0dqs/ansible_module_mqtt.py\", line 213, in <module>\n    main()\n  File \"/tmp/ansible_Nn0dqs/ansible_module_mqtt.py\", line 204, in main\n    tls=tls)\n  File \"/usr/lib/python2.7/site-packages/paho/mqtt/publish.py\", line 223, in single\n    multiple([msg], hostname, port, client_id, keepalive, will, auth, tls, protocol, transport)\n  File \"/usr/lib/python2.7/site-packages/paho/mqtt/publish.py\", line 174, in multiple\n    client.connect(hostname, port, keepalive)\n  File \"/usr/lib/python2.7/site-packages/paho/mqtt/client.py\", line 686, in connect\n    return self.reconnect()\n  File \"/usr/lib/python2.7/site-packages/paho/mqtt/client.py\", line 821, in reconnect\n    ciphers=self._tls_ciphers)\n  File \"/usr/lib/python2.7/ssl.py\", line 943, in wrap_socket\n    ciphers=ciphers)\n  File \"/usr/lib/python2.7/ssl.py\", line 549, in __init__\n    self._context = SSLContext(ssl_version)\n  File \"/usr/lib/python2.7/ssl.py\", line 347, in __new__\n    self = _SSLContext.__new__(cls, protocol)\nTypeError: an integer is required\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

Metadata

Metadata

Assignees

Labels

affects_2.3This issue/PR affects Ansible v2.3bugThis issue/PR relates to a bug.moduleThis issue/PR relates to a module.notificationNotification categorysupport:communityThis issue/PR relates to code supported by the Ansible community.tracebackThis issue/PR includes a traceback.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0