summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2022-10-11 13:58:08 +0200
committerGuilhem Moulin <guilhem@fripost.org>2022-10-11 13:58:08 +0200
commit83bd3f5e67554f6c822cd35d428ac597707b7d3d (patch)
tree71204b184da538fe77c1bed7a24a2907ed908bd2
parenta69c2e1c3c771db93d98a253192e131af40c9830 (diff)
mysql_user2: Remove load_mycnf().
We're not using this, and it makes ansible croak with An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'ConfigParser'
-rw-r--r--lib/modules/mysql_user243
1 files changed, 2 insertions, 41 deletions
diff --git a/lib/modules/mysql_user2 b/lib/modules/mysql_user2
index dc9a69e..acceeaf 100644
--- a/lib/modules/mysql_user2
+++ b/lib/modules/mysql_user2
@@ -107,7 +107,7 @@ notes:
the new root credentials. Subsequent runs of the playbook will then succeed by reading the new credentials from
the file."
-requirements: [ "ConfigParser", "MySQLdb" ]
+requirements: [ "MySQLdb" ]
author: Mark Theunissen
'''
@@ -133,7 +133,6 @@ user=root
password=n<_665{vS43y
"""
-import ConfigParser
import getpass
import tempfile
try:
@@ -368,36 +367,6 @@ def _safe_cnf_load(config, path):
os.remove(newpath)
return config
-def load_mycnf():
- config = ConfigParser.RawConfigParser()
- mycnf = os.path.expanduser('~/.my.cnf')
- if not os.path.exists(mycnf):
- return False
- try:
- config.readfp(open(mycnf))
- except (IOError):
- return False
- except:
- config = _safe_cnf_load(config, mycnf)
-
- # We support two forms of passwords in .my.cnf, both pass= and password=,
- # as these are both supported by MySQL.
- try:
- passwd = config_get(config, 'client', 'password')
- except (ConfigParser.NoOptionError):
- try:
- passwd = config_get(config, 'client', 'pass')
- except (ConfigParser.NoOptionError):
- return False
-
- # If .my.cnf doesn't specify a user, default to user login name
- try:
- user = config_get(config, 'client', 'user')
- except (ConfigParser.NoOptionError):
- user = getpass.getuser()
- creds = dict(user=user,passwd=passwd)
- return creds
-
def connect(module, login_user, login_password):
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")
@@ -452,15 +421,7 @@ def main():
# ~/.my.cnf.
login_password = module.params["login_password"]
login_user = module.params["login_user"]
- if login_user is None and login_password is None:
- mycnf_creds = load_mycnf()
- if mycnf_creds is False:
- login_user = "root"
- login_password = ""
- else:
- login_user = mycnf_creds["user"]
- login_password = mycnf_creds["passwd"]
- elif login_password is None or login_user is None:
+ if login_password is None or login_user is None:
module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided")
cursor = None