diff options
author | Brian Coca <bcoca@ansible.com> | 2015-03-31 15:28:31 -0400 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2015-03-31 15:28:31 -0400 |
commit | c4a22478c41e170c14b7f7ea17d6836a81d71869 (patch) | |
tree | 16dbd1b4fb543a328e74e4beaaf0572309b816fd | |
parent | e6e3ade6faf56c30f1426727bbd5eca46b254caa (diff) | |
parent | 35434f9672f3121549f6a88358ed73a696e94d4f (diff) | |
download | ansible-modules-core-c4a22478c41e170c14b7f7ea17d6836a81d71869.tar.gz |
Merge pull request #830 from BlackMesh/devel
mysql_user #829: add update_password to mysql_user
-rw-r--r-- | database/mysql/mysql_user.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/database/mysql/mysql_user.py b/database/mysql/mysql_user.py index 5901771f..8378c7e6 100644 --- a/database/mysql/mysql_user.py +++ b/database/mysql/mysql_user.py @@ -93,6 +93,14 @@ options: required: false default: false version_added: "1.3" + update_password: + required: false + default: always + choices: ['always', 'on_create'] + version_added: "1.9" + description: + - C(always) will update passwords if they differ. C(on_create) will only set the password for newly created users. + notes: - Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as apt-get install python-mysqldb. @@ -446,6 +454,7 @@ def main(): priv=dict(default=None), append_privs=dict(type="bool", default="no"), check_implicit_admin=dict(default=False), + update_password=dict(default="always", choices=["always", "on_create"]), ) ) user = module.params["user"] @@ -455,6 +464,7 @@ def main(): priv = module.params["priv"] check_implicit_admin = module.params['check_implicit_admin'] append_privs = module.boolean(module.params["append_privs"]) + update_password = module.params['update_password'] if not mysqldb_found: module.fail_json(msg="the python mysqldb module is required") @@ -497,7 +507,11 @@ def main(): if state == "present": if user_exists(cursor, user, host): try: - changed = user_mod(cursor, user, host, password, priv, append_privs) + if update_password == 'always': + changed = user_mod(cursor, user, host, password, priv, append_privs) + else: + changed = user_mod(cursor, user, host, None, priv, append_privs) + except (SQLParseError, InvalidPrivsError, MySQLdb.Error), e: module.fail_json(msg=str(e)) else: |