Merge pull request #1539 from acaveroc/mysql_vars_port_definition
Mysql vars port definition
This commit is contained in:
commit
2b53b92dc2
1 changed files with 10 additions and 3 deletions
|
@ -52,6 +52,11 @@ options:
|
|||
description:
|
||||
- mysql host to connect
|
||||
required: False
|
||||
login_port:
|
||||
version_added: "1.9"
|
||||
description:
|
||||
- mysql port to connect
|
||||
required: False
|
||||
login_unix_socket:
|
||||
description:
|
||||
- unix socket to connect mysql server
|
||||
|
@ -193,7 +198,8 @@ def main():
|
|||
argument_spec = dict(
|
||||
login_user=dict(default=None),
|
||||
login_password=dict(default=None),
|
||||
login_host=dict(default="localhost"),
|
||||
login_host=dict(default="127.0.0.1"),
|
||||
login_port=dict(default="3306", type='int'),
|
||||
login_unix_socket=dict(default=None),
|
||||
variable=dict(default=None),
|
||||
value=dict(default=None)
|
||||
|
@ -203,6 +209,7 @@ def main():
|
|||
user = module.params["login_user"]
|
||||
password = module.params["login_password"]
|
||||
host = module.params["login_host"]
|
||||
port = module.params["login_port"]
|
||||
mysqlvar = module.params["variable"]
|
||||
value = module.params["value"]
|
||||
if not mysqldb_found:
|
||||
|
@ -227,9 +234,9 @@ def main():
|
|||
module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided")
|
||||
try:
|
||||
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="mysql")
|
||||
db_connection = MySQLdb.connect(host=module.params["login_host"], port=module.params["login_port"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db="mysql")
|
||||
else:
|
||||
db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db="mysql")
|
||||
db_connection = MySQLdb.connect(host=module.params["login_host"], port=module.params["login_port"], user=login_user, passwd=login_password, db="mysql")
|
||||
cursor = db_connection.cursor()
|
||||
except Exception, e:
|
||||
module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials")
|
||||
|
|
Loading…
Reference in a new issue