tlu/salt/modules/_states/mysql.py
Jonas Forsberg b62bb23790 .
2021-09-24 14:04:48 +02:00

30 lines
729 B
Python

import salt.exceptions
def root_password(name, password):
"""
Set the mysql/mariadb root password
password
the password to user for root
"""
ret = {
"name": name,
"changes": {},
"result": False,
"comment": ""
}
if __salt__["mysql.check_credentials"]("root", password):
ret["comment"]="Password is in correct state"
ret["result"] = True
return ret
result = __salt__["mysql.set_root_password"](password)
if not result["result"]:
ret["comment"] = result["err"]
return ret
ret["changes"].update({"root password": {"old": "######", "new": "******"}})
ret["result"]=True
return ret