tlu/salt/modules/_states/mysql.py

30 lines
729 B
Python
Raw Normal View History

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