Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tls parameter to redis module #4207

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/4207-add-redis-tls-support.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- redis - add tls support to module
13 changes: 10 additions & 3 deletions plugins/modules/database/misc/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
- The port to connect to
default: 6379
type: int
tls:
description:
- Specify whether or not to use TLS for the connection.
type: bool
default: false
master_host:
description:
- The host of the master instance [replica command]
Expand Down Expand Up @@ -181,6 +186,7 @@ def main():
login_password=dict(type='str', no_log=True),
login_host=dict(type='str', default='localhost'),
login_port=dict(type='int', default=6379),
tls=dict(type='bool', default=False),
master_host=dict(type='str'),
master_port=dict(type='int'),
replica_mode=dict(type='str', default='replica', choices=['master', 'replica', 'slave'], aliases=["slave_mode"]),
Expand All @@ -198,6 +204,7 @@ def main():
login_password = module.params['login_password']
login_host = module.params['login_host']
login_port = module.params['login_port']
ssl = module.params['tls']
command = module.params['command']
if command == "slave":
command = "replica"
Expand All @@ -219,7 +226,7 @@ def main():
module.fail_json(msg='In replica mode master port must be provided')

# Connect and check
r = redis.StrictRedis(host=login_host, port=login_port, password=login_password)
r = redis.StrictRedis(host=login_host, port=login_port, password=login_password, ssl=ssl)
try:
r.ping()
except Exception as e:
Expand Down Expand Up @@ -270,7 +277,7 @@ def main():
module.fail_json(msg="In db mode the db number must be provided")

# Connect and check
r = redis.StrictRedis(host=login_host, port=login_port, password=login_password, db=db)
r = redis.StrictRedis(host=login_host, port=login_port, password=login_password, ssl=ssl, db=db)
try:
r.ping()
except Exception as e:
Expand Down Expand Up @@ -301,7 +308,7 @@ def main():
except ValueError:
value = module.params['value']

r = redis.StrictRedis(host=login_host, port=login_port, password=login_password)
r = redis.StrictRedis(host=login_host, port=login_port, password=login_password, ssl=ssl)

try:
r.ping()
Expand Down