This commit is contained in:
Jonas Forsberg 2021-09-24 14:04:48 +02:00
parent 9ac32539c8
commit b62bb23790
4 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import salt.exceptions
def root_password(name):
def root_password(name, password):
"""
Set the mysql/mariadb root password
@ -8,18 +8,18 @@ def root_password(name):
the password to user for root
"""
ret = {
"name": "root password",
"name": name,
"changes": {},
"result": False,
"comment": ""
}
if __salt__["mysql.check_credentials"]("root", name):
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"](name)
result = __salt__["mysql.set_root_password"](password)
if not result["result"]:
ret["comment"] = result["err"]
return ret

View File

@ -9,4 +9,5 @@ Start mariadb:
Check Root password:
mysql.root_password:
- name: {{ pillar['mariadb']['root_password'] }}
- name: root
- password: {{ pillar['mariadb']['root_password'] }}

View File

@ -6,3 +6,4 @@ base:
- atftp
- dnsmasq
- nginx
- mariadb

View File

@ -89,7 +89,7 @@ function check_prerequisites(){
}
function do_salt_call(){
local salt="sudo salt-call --local --file-root $SCRIPTDIR/salt/states --pillar-root $SCRIPTDIR/salt/pillars"
local salt="sudo salt-call --local --file-root $SCRIPTDIR/salt/states --pillar-root $SCRIPTDIR/salt/pillars --module-dirs=$SCRIPTDIR/salt/modules"
new_log "Running salt high state"
if asktobreak;then
return