mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Merge pull request #8079 from Jmainguy/mysql_db_8070
Makes ansible fail if login_port is defined and login_host is either not...
This commit is contained in:
commit
dc89cc5f44
1 changed files with 3 additions and 1 deletions
|
@ -50,7 +50,7 @@ options:
|
||||||
default: localhost
|
default: localhost
|
||||||
login_port:
|
login_port:
|
||||||
description:
|
description:
|
||||||
- Port of the MySQL server
|
- Port of the MySQL server. Requires login_host be defined as other then localhost if login_port is used
|
||||||
required: false
|
required: false
|
||||||
default: 3306
|
default: 3306
|
||||||
login_unix_socket:
|
login_unix_socket:
|
||||||
|
@ -308,6 +308,8 @@ def main():
|
||||||
try:
|
try:
|
||||||
if module.params["login_unix_socket"]:
|
if module.params["login_unix_socket"]:
|
||||||
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db=connect_to_db)
|
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db=connect_to_db)
|
||||||
|
elif module.params["login_port"] != "3306" and module.params["login_host"] == "localhost":
|
||||||
|
module.fail_json(msg="login_host is required when login_port is defined, login_host cannot be localhost when login_port is defined")
|
||||||
else:
|
else:
|
||||||
db_connection = MySQLdb.connect(host=module.params["login_host"], port=int(module.params["login_port"]), user=login_user, passwd=login_password, db=connect_to_db)
|
db_connection = MySQLdb.connect(host=module.params["login_host"], port=int(module.params["login_port"]), user=login_user, passwd=login_password, db=connect_to_db)
|
||||||
cursor = db_connection.cursor()
|
cursor = db_connection.cursor()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue