From b5390824c25912f8909345710ef6aa5ce7b7081f Mon Sep 17 00:00:00 2001 From: Chris Tooley Date: Sat, 5 Mar 2016 00:37:41 +0000 Subject: [PATCH 1/3] Add https support for consul clustering modules --- clustering/consul.py | 14 ++++++++++++++ clustering/consul_acl.py | 14 ++++++++++++++ clustering/consul_kv.py | 14 ++++++++++++++ clustering/consul_session.py | 12 ++++++++++++ 4 files changed, 54 insertions(+) diff --git a/clustering/consul.py b/clustering/consul.py index 627f7fb66af..8929a0e78b0 100644 --- a/clustering/consul.py +++ b/clustering/consul.py @@ -71,6 +71,16 @@ options: - the port on which the consul agent is running required: false default: 8500 + scheme: + description: + - the protocol scheme on which the consul agent is running + required: false + default: http + verify: + description: + - whether to verify the tls certificate of the consul agent + required: false + default: True notes: description: - Notes to attach to check when registering it. @@ -308,6 +318,8 @@ def remove_service(module, service_id): def get_consul_api(module, token=None): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), + scheme=module.params.get('scheme'), + verify=module.params.get('verify'), token=module.params.get('token')) @@ -503,6 +515,8 @@ def main(): argument_spec=dict( host=dict(default='localhost'), port=dict(default=8500, type='int'), + scheme=dict(required=False, default='http'), + verify=dict(required=False, default=True, type='bool'), check_id=dict(required=False), check_name=dict(required=False), check_node=dict(required=False), diff --git a/clustering/consul_acl.py b/clustering/consul_acl.py index 17d59ea62a8..2e8149a2c92 100644 --- a/clustering/consul_acl.py +++ b/clustering/consul_acl.py @@ -69,6 +69,16 @@ options: - the port on which the consul agent is running required: false default: 8500 + scheme: + description: + - the protocol scheme on which the consul agent is running + required: false + default: http + verify: + description: + - whether to verify the tls certificate of the consul agent + required: false + default: True """ EXAMPLES = ''' @@ -300,6 +310,8 @@ def get_consul_api(module, token=None): token = module.params.get('token') return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), + scheme=module.params.get('scheme'), + verify=module.params.get('verify'), token=token) def test_dependencies(module): @@ -315,6 +327,8 @@ def main(): argument_spec = dict( mgmt_token=dict(required=True, no_log=True), host=dict(default='localhost'), + scheme=dict(required=False, default='http'), + verify=dict(required=False, default=True), name=dict(required=False), port=dict(default=8500, type='int'), rules=dict(default=None, required=False, type='list'), diff --git a/clustering/consul_kv.py b/clustering/consul_kv.py index b61c0ee1841..deab7a57a1f 100644 --- a/clustering/consul_kv.py +++ b/clustering/consul_kv.py @@ -99,6 +99,16 @@ options: - the port on which the consul agent is running required: false default: 8500 + scheme: + description: + - the protocol scheme on which the consul agent is running + required: false + default: http + verify: + description: + - whether to verify the tls certificate of the consul agent + required: false + default: True """ @@ -218,6 +228,8 @@ def remove_value(module): def get_consul_api(module, token=None): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), + scheme=module.params.get('scheme'), + verify=module.params.get('verify'), token=module.params.get('token')) def test_dependencies(module): @@ -232,6 +244,8 @@ def main(): flags=dict(required=False), key=dict(required=True), host=dict(default='localhost'), + scheme=dict(required=False, default='http'), + verify=dict(required=False, default=True), port=dict(default=8500, type='int'), recurse=dict(required=False, type='bool'), retrieve=dict(required=False, default=True), diff --git a/clustering/consul_session.py b/clustering/consul_session.py index c298ea7fa57..23d683e8ab5 100644 --- a/clustering/consul_session.py +++ b/clustering/consul_session.py @@ -88,6 +88,16 @@ options: - the port on which the consul agent is running required: false default: 8500 + scheme: + description: + - the protocol scheme on which the consul agent is running + required: false + default: http + verify: + description: + - whether to verify the tls certificate of the consul agent + required: false + default: True """ EXAMPLES = ''' @@ -244,6 +254,8 @@ def main(): delay=dict(required=False,type='str', default='15s'), host=dict(default='localhost'), port=dict(default=8500, type='int'), + scheme=dict(required=False, default='http'), + verify=dict(required=False, default=True), id=dict(required=False), name=dict(required=False), node=dict(required=False), From 516f7d98e755e1cbec7daf2e3370d0e6f1354f04 Mon Sep 17 00:00:00 2001 From: Chris Tooley Date: Sat, 5 Mar 2016 00:55:08 +0000 Subject: [PATCH 2/3] Add version_added to documentation --- clustering/consul.py | 2 ++ clustering/consul_acl.py | 2 ++ clustering/consul_kv.py | 2 ++ clustering/consul_session.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/clustering/consul.py b/clustering/consul.py index 8929a0e78b0..e24279586e6 100644 --- a/clustering/consul.py +++ b/clustering/consul.py @@ -76,11 +76,13 @@ options: - the protocol scheme on which the consul agent is running required: false default: http + version_added: "2.1" verify: description: - whether to verify the tls certificate of the consul agent required: false default: True + version_added: "2.1" notes: description: - Notes to attach to check when registering it. diff --git a/clustering/consul_acl.py b/clustering/consul_acl.py index 2e8149a2c92..e07db83232d 100644 --- a/clustering/consul_acl.py +++ b/clustering/consul_acl.py @@ -74,11 +74,13 @@ options: - the protocol scheme on which the consul agent is running required: false default: http + version_added: "2.1" verify: description: - whether to verify the tls certificate of the consul agent required: false default: True + version_added: "2.1" """ EXAMPLES = ''' diff --git a/clustering/consul_kv.py b/clustering/consul_kv.py index deab7a57a1f..45c93d672a0 100644 --- a/clustering/consul_kv.py +++ b/clustering/consul_kv.py @@ -104,11 +104,13 @@ options: - the protocol scheme on which the consul agent is running required: false default: http + version_added: "2.1" verify: description: - whether to verify the tls certificate of the consul agent required: false default: True + version_added: "2.1" """ diff --git a/clustering/consul_session.py b/clustering/consul_session.py index 23d683e8ab5..625c31c7979 100644 --- a/clustering/consul_session.py +++ b/clustering/consul_session.py @@ -93,11 +93,13 @@ options: - the protocol scheme on which the consul agent is running required: false default: http + version_added: "2.1" verify: description: - whether to verify the tls certificate of the consul agent required: false default: True + version_added: "2.1" """ EXAMPLES = ''' From 04982da9b8bea61c84a1a0b43f12bed85a720919 Mon Sep 17 00:00:00 2001 From: Chris Tooley Date: Wed, 23 Mar 2016 13:23:30 +0000 Subject: [PATCH 3/3] Modify consul certificate validation bypass keyword from 'verify' to 'validate_certs' --- clustering/consul.py | 6 +++--- clustering/consul_acl.py | 6 +++--- clustering/consul_kv.py | 6 +++--- clustering/consul_session.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clustering/consul.py b/clustering/consul.py index e24279586e6..f0df2368b51 100644 --- a/clustering/consul.py +++ b/clustering/consul.py @@ -77,7 +77,7 @@ options: required: false default: http version_added: "2.1" - verify: + validate_certs: description: - whether to verify the tls certificate of the consul agent required: false @@ -321,7 +321,7 @@ def get_consul_api(module, token=None): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), scheme=module.params.get('scheme'), - verify=module.params.get('verify'), + validate_certs=module.params.get('validate_certs'), token=module.params.get('token')) @@ -518,7 +518,7 @@ def main(): host=dict(default='localhost'), port=dict(default=8500, type='int'), scheme=dict(required=False, default='http'), - verify=dict(required=False, default=True, type='bool'), + validate_certs=dict(required=False, default=True, type='bool'), check_id=dict(required=False), check_name=dict(required=False), check_node=dict(required=False), diff --git a/clustering/consul_acl.py b/clustering/consul_acl.py index e07db83232d..b1c7763a550 100644 --- a/clustering/consul_acl.py +++ b/clustering/consul_acl.py @@ -75,7 +75,7 @@ options: required: false default: http version_added: "2.1" - verify: + validate_certs: description: - whether to verify the tls certificate of the consul agent required: false @@ -313,7 +313,7 @@ def get_consul_api(module, token=None): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), scheme=module.params.get('scheme'), - verify=module.params.get('verify'), + validate_certs=module.params.get('validate_certs'), token=token) def test_dependencies(module): @@ -330,7 +330,7 @@ def main(): mgmt_token=dict(required=True, no_log=True), host=dict(default='localhost'), scheme=dict(required=False, default='http'), - verify=dict(required=False, default=True), + validate_certs=dict(required=False, default=True), name=dict(required=False), port=dict(default=8500, type='int'), rules=dict(default=None, required=False, type='list'), diff --git a/clustering/consul_kv.py b/clustering/consul_kv.py index 45c93d672a0..9358b79749a 100644 --- a/clustering/consul_kv.py +++ b/clustering/consul_kv.py @@ -105,7 +105,7 @@ options: required: false default: http version_added: "2.1" - verify: + validate_certs: description: - whether to verify the tls certificate of the consul agent required: false @@ -231,7 +231,7 @@ def get_consul_api(module, token=None): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), scheme=module.params.get('scheme'), - verify=module.params.get('verify'), + validate_certs=module.params.get('validate_certs'), token=module.params.get('token')) def test_dependencies(module): @@ -247,7 +247,7 @@ def main(): key=dict(required=True), host=dict(default='localhost'), scheme=dict(required=False, default='http'), - verify=dict(required=False, default=True), + validate_certs=dict(required=False, default=True), port=dict(default=8500, type='int'), recurse=dict(required=False, type='bool'), retrieve=dict(required=False, default=True), diff --git a/clustering/consul_session.py b/clustering/consul_session.py index 625c31c7979..3ba3b6f1619 100644 --- a/clustering/consul_session.py +++ b/clustering/consul_session.py @@ -94,7 +94,7 @@ options: required: false default: http version_added: "2.1" - verify: + validate_certs: description: - whether to verify the tls certificate of the consul agent required: false @@ -257,7 +257,7 @@ def main(): host=dict(default='localhost'), port=dict(default=8500, type='int'), scheme=dict(required=False, default='http'), - verify=dict(required=False, default=True), + validate_certs=dict(required=False, default=True), id=dict(required=False), name=dict(required=False), node=dict(required=False),