Merge branch 'devel' of https://github.com/tomdymond/ansible into tomdymond-devel
This commit is contained in:
commit
619a80c505
2 changed files with 14 additions and 2 deletions
|
@ -48,6 +48,11 @@ options:
|
||||||
- Host running the database
|
- Host running the database
|
||||||
required: false
|
required: false
|
||||||
default: localhost
|
default: localhost
|
||||||
|
login_port:
|
||||||
|
description:
|
||||||
|
- Port of the MySQL server
|
||||||
|
required: false
|
||||||
|
default: 3306
|
||||||
login_unix_socket:
|
login_unix_socket:
|
||||||
description:
|
description:
|
||||||
- The path to a Unix domain socket for local connections
|
- The path to a Unix domain socket for local connections
|
||||||
|
@ -197,6 +202,7 @@ def main():
|
||||||
login_user=dict(default=None),
|
login_user=dict(default=None),
|
||||||
login_password=dict(default=None),
|
login_password=dict(default=None),
|
||||||
login_host=dict(default="localhost"),
|
login_host=dict(default="localhost"),
|
||||||
|
login_port=dict(default="3306"),
|
||||||
login_unix_socket=dict(default=None),
|
login_unix_socket=dict(default=None),
|
||||||
db=dict(required=True, aliases=['name']),
|
db=dict(required=True, aliases=['name']),
|
||||||
encoding=dict(default=""),
|
encoding=dict(default=""),
|
||||||
|
@ -242,7 +248,7 @@ def main():
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
db_connection = MySQLdb.connect(host=module.params["login_host"], 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()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module.fail_json(msg="unable to connect, check login_user and login_password are correct, or alternatively check ~/.my.cnf contains credentials")
|
module.fail_json(msg="unable to connect, check login_user and login_password are correct, or alternatively check ~/.my.cnf contains credentials")
|
||||||
|
|
|
@ -56,6 +56,11 @@ options:
|
||||||
- Host running the database
|
- Host running the database
|
||||||
required: false
|
required: false
|
||||||
default: localhost
|
default: localhost
|
||||||
|
login_port:
|
||||||
|
description:
|
||||||
|
- Port of the MySQL server
|
||||||
|
required: false
|
||||||
|
default: 3306
|
||||||
login_unix_socket:
|
login_unix_socket:
|
||||||
description:
|
description:
|
||||||
- The path to a Unix domain socket for local connections
|
- The path to a Unix domain socket for local connections
|
||||||
|
@ -333,7 +338,7 @@ def connect(module, login_user, login_password):
|
||||||
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="mysql")
|
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db="mysql")
|
||||||
else:
|
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=int(module.params["login_port"]), user=login_user, passwd=login_password, db="mysql")
|
||||||
return db_connection.cursor()
|
return db_connection.cursor()
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
@ -346,6 +351,7 @@ def main():
|
||||||
login_user=dict(default=None),
|
login_user=dict(default=None),
|
||||||
login_password=dict(default=None),
|
login_password=dict(default=None),
|
||||||
login_host=dict(default="localhost"),
|
login_host=dict(default="localhost"),
|
||||||
|
login_port=dict(default="3306"),
|
||||||
login_unix_socket=dict(default=None),
|
login_unix_socket=dict(default=None),
|
||||||
user=dict(required=True, aliases=['name']),
|
user=dict(required=True, aliases=['name']),
|
||||||
password=dict(default=None),
|
password=dict(default=None),
|
||||||
|
|
Loading…
Add table
Reference in a new issue