diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 66c11930..7131a669 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -154,6 +154,9 @@ def user_add(cursor, user, host, host_all, password, encrypted, plugin, plugin_hash_string, plugin_auth_string, new_priv, attributes, tls_requires, module, reuse_existing_password, password_expire, password_expire_interval): + # If attributes are set, perform a sanity check to ensure server supports user attributes before creating user + if attributes and not get_attribute_support(cursor): + module.fail_json(msg="user attributes were specified but the server does not support user attributes") # we cannot create users without a proper hostname if host_all: return {'changed': False, 'password_changed': False, 'attributes': attributes} @@ -1086,6 +1089,9 @@ def get_attribute_support(cursor): def attributes_get(cursor, user, host): """Get attributes for a given user. + Args: + cursor (cursor): DB driver cursor object. + user (str): User name. host (str): User host name. Returns: