diff --git a/mysql/database.sls b/mysql/database.sls index 8c85bb3..f4b1d40 100644 --- a/mysql/database.sls +++ b/mysql/database.sls @@ -60,7 +60,10 @@ include: {{ state_id }}_load: cmd.run: - - name: mysql -u {{ mysql_salt_user }} -h{{ mysql_host }} {% if mysql_salt_pass %}-p{%- endif %}{{ mysql_salt_pass }} {{ database }} < /etc/mysql/{{ database }}.schema + - name: mysql -u {{ mysql_salt_user }} -h{{ mysql_host }} {% if mysql_salt_pass %}-p{%- endif %}$SALT_PASS {{ database }} < /etc/mysql/{{ database }}.schema + - env: + - SALT_PASS: "{{ mysql_salt_pass }}" + - output_loglevel: quiet - onchanges: - file: {{ state_id }}_schema - mysql_database: {{ state_id }} diff --git a/mysql/server.sls b/mysql/server.sls index 69126ef..614154c 100644 --- a/mysql/server.sls +++ b/mysql/server.sls @@ -97,8 +97,11 @@ mysql_password_debconf: {%- elif os_family in ['RedHat', 'Suse', 'FreeBSD'] %} mysql_root_password: cmd.run: - - name: mysqladmin --host "{{ mysql_host }}" --user {{ mysql_root_user }} password '{{ mysql_root_password|replace("'", "'\"'\"'") }}' - - unless: mysql --host "{{ mysql_host }}" --user {{ mysql_root_user }} --password='{{ mysql_root_password|replace("'", "'\"'\"'") }}' --execute="SELECT 1;" + - name: mysqladmin --host "{{ mysql_host }}" --user {{ mysql_root_user }} password $SALT_PASS + - unless: mysql --host "{{ mysql_host }}" --user {{ mysql_root_user }} --password=$SALT_PASS --execute="SELECT 1;" + - env: + - SALT_PASS: "{{ mysql_root_password|replace("'", "'\"'\"'") }}" + - output_loglevel: quiet - require: - service: mysqld-service-running