Repository: ansible/ansible-modules-extras

Issue:
Consul module for 2.1 fails with wrong parameter name for python-consul constructor (
<!--- Verify first that your issue/request is not already reported in GitHub -->
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

clustering/consul.py
##### ANSIBLE VERSION

```
ansible 2.1.0.0
  config file = /Users/wouter/data/src/..../ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

```
[defaults]
gathering = smart
fact_caching = jsonfile
fact_caching_connection = plays/cache
fact_caching_timeout = 86400
nocows = 1

[ssh_connection]
ssh_args = -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
```
##### OS / ENVIRONMENT

<!---
N/A
-->
##### SUMMARY

Consul tasks fail with a message `__init__() got an unexpected keyword argument 'validate_certs`
This is because the boolean value has a different name ('verify') in the constructor for the Consul class. 

The code involved looks like this (in `clustering/consul.py`):

```
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'),
                         validate_certs=module.params.get('validate_certs'),
                         token=module.params.get('token'))
```

Simply changing the call to use:

```
                         verify=module.params.get('validate_certs'),
```

Seems to work to fix this. I'm not making a pull request, as I have no idea of any broader impact/versioning/etc.
##### STEPS TO REPRODUCE

Any simple playbook for consul should have this issue.

```
- hosts: localhost
  become: no
  tasks:
    - name: Register {service} with consul.
      consul:
        host: 192.168.56.11
        service_name: "test"
        service_address: "192.168.56.51"
        service_port: 9090
        interval: 60s
        http: /
```
##### EXPECTED RESULTS

It to try and contact a consul host.
##### ACTUAL RESULTS

The full error message:

```
fatal: [dev-swarm-manager]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"check_host": null, "check_id": null, "check_name": null, "check_node": null, "host": "localhost", "http": "/", "interval": "60s", "notes": null, "port": 8500, "scheme": "http", "script": null, "service_address": "192.168.56.101", "service_id": null, "service_name": "identity", "service_port": 9090, "state": "present", "tags": ["latest"], "timeout": null, "token": null, "ttl": null, "validate_certs": true}, "module_name": "consul"}, "msg": "__init__() got an unexpected keyword argument 'validate_certs'"}
```



Discussion:
@sgargan do you have time to take a look at this?


Resolving patch:
diff --git a/clustering/consul.py b/clustering/consul.py
--- a/clustering/consul.py
+++ b/clustering/consul.py
@@ -332,7 +332,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'),
-                         validate_certs=module.params.get('validate_certs'),
+                         verify=module.params.get('validate_certs'),
                          token=module.params.get('token'))
 
 
diff --git a/clustering/consul_acl.py b/clustering/consul_acl.py
--- a/clustering/consul_acl.py
+++ b/clustering/consul_acl.py
@@ -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'),
-                         validate_certs=module.params.get('validate_certs'),
+                         verify=module.params.get('validate_certs'),
                          token=token)
 
 def test_dependencies(module):
diff --git a/clustering/consul_kv.py b/clustering/consul_kv.py
--- a/clustering/consul_kv.py
+++ b/clustering/consul_kv.py
@@ -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'),
-                         validate_certs=module.params.get('validate_certs'),
+                         verify=module.params.get('validate_certs'),
                          token=module.params.get('token'))
 
 def test_dependencies(module):


Test patch: