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

View File

@ -9,4 +9,5 @@ Start mariadb:
Check Root password: Check Root password:
mysql.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 - atftp
- dnsmasq - dnsmasq
- nginx - nginx
- mariadb

View File

@ -89,7 +89,7 @@ function check_prerequisites(){
} }
function do_salt_call(){ 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" new_log "Running salt high state"
if asktobreak;then if asktobreak;then
return return