RHEL & Suse condition is correctly evaluated

This commit is contained in:
Tomáš Fejfar 2016-06-09 16:39:27 +02:00
parent 7e94d486a6
commit d3ec899409
2 changed files with 14 additions and 2 deletions

View file

@ -28,8 +28,10 @@ mysql_salt_user_with_salt_user:
- onlyif:
- mysql --user {{ mysql_salt_user }} --password='{{ mysql_salt_pass|replace("'", "'\"'\"'") }}' -h {{ mysql_host }} --execute="SELECT 1;"
- VALUE=$(mysql --user {{ mysql_salt_user }} --password='{{ mysql_salt_pass|replace("'", "'\"'\"'") }}' -ss -e "SELECT Grant_priv FROM mysql.user WHERE user = '{{ mysql_salt_user }}' AND host = '{{ host }}';"); if [ "$VALUE" = 'Y' ]; then /bin/true; else /bin/false; fi
{% if os_family in ['RedHat', 'Suse'] %}
- require_in:
- mysql_user: mysql_root_password
{% endif %}
{%- if mysql_salt_grants != [] %}
mysql_salt_user_with_salt_user_grants:
@ -49,9 +51,11 @@ mysql_salt_user_with_salt_user_grants:
- VALUE=$(mysql --user {{ mysql_salt_user }} --password='{{ mysql_salt_pass|replace("'", "'\"'\"'") }}' -ss -e "SELECT Grant_priv FROM mysql.user WHERE user = '{{ mysql_salt_user }}' AND host = '{{ host }}';"); if [ "$VALUE" = 'Y' ]; then /bin/true; else /bin/false; fi
- require:
- mysql_user: mysql_salt_user_with_salt_user
{% if os_family in ['RedHat', 'Suse'] %}
- require_in:
- mysql_user: mysql_root_password
{% endif %}
{% endif %}
mysql_salt_user_with_root_user:
mysql_user.present:
@ -65,8 +69,10 @@ mysql_salt_user_with_root_user:
- onlyif:
- mysql --user {{ mysql_root_user }} --password='{{ mysql_root_pass|replace("'", "'\"'\"'") }}' -h {{ mysql_host }} --execute="SELECT 1;"
- VALUE=$(mysql --user {{ mysql_root_user }} --password='{{ mysql_root_pass|replace("'", "'\"'\"'") }}' -ss -e "SELECT Grant_priv FROM mysql.user WHERE user = '{{ mysql_salt_user }}' AND host = '{{ host }}';"); if [ "$VALUE" = 'N' -o -z "$VALUE" ]; then /bin/true; else /bin/false; fi
{% if os_family in ['RedHat', 'Suse'] %}
- require_in:
- mysql_user: mysql_root_password
{% endif %}
{%- if mysql_salt_grants != [] %}
mysql_salt_user_with_root_user_grants:
@ -86,9 +92,11 @@ mysql_salt_user_with_root_user_grants:
- VALUE=$(mysql --user {{ mysql_root_user }} --password='{{ mysql_root_pass|replace("'", "'\"'\"'") }}' -ss -e "SELECT Grant_priv FROM mysql.user WHERE user = '{{ mysql_salt_user }}' AND host = '{{ host }}';"); if [ "$VALUE" = 'N' -o -z "$VALUE" ]; then /bin/true; else /bin/false; fi
- require:
- mysql_user: mysql_salt_user_with_root_user
{% if os_family in ['RedHat', 'Suse'] %}
- require_in:
- mysql_user: mysql_root_password
{% endif %}
{% endif %}
mysql_salt_user_with_passwordless_root_user:
mysql_user.present:
@ -101,8 +109,10 @@ mysql_salt_user_with_passwordless_root_user:
- onlyif:
- mysql --user {{ mysql_root_user }} -h {{ mysql_host }} --execute="SELECT 1;"
- VALUE=$(mysql --user {{ mysql_root_user }} -ss -e "SELECT Grant_priv FROM mysql.user WHERE user = '{{ mysql_salt_user }}' AND host = '{{ host }}';"); if [ "$VALUE" = 'N' -o -z "$VALUE" ]; then /bin/true; else /bin/false; fi
{% if os_family in ['RedHat', 'Suse'] %}
- require_in:
- mysql_user: mysql_root_password
{% endif %}
{%- if mysql_salt_grants != [] %}
mysql_salt_user_with_passwordless_root_user_grants:
@ -121,11 +131,13 @@ mysql_salt_user_with_passwordless_root_user_grants:
- VALUE=$(mysql --user {{ mysql_root_user }} -ss -e "SELECT Grant_priv FROM mysql.user WHERE user = '{{ mysql_salt_user }}' AND host = '{{ host }}';"); if [ "$VALUE" = 'N' -o -z "$VALUE" ]; then /bin/true; else /bin/false; fi
- require:
- mysql_user: mysql_salt_user_with_passwordless_root_user
{% if os_family in ['RedHat', 'Suse'] %}
- require_in:
- mysql_user: mysql_root_password
{% endif %}
{% endif %}
{% if os_family == 'RedHat' or 'Suse' %}
{% if os_family in ['RedHat', 'Suse'] %}
extend:
mysql_root_password:
cmd.run:

View file

@ -30,7 +30,7 @@ mysql_debconf:
- pkg: {{ mysql.server }}
- require:
- pkg: mysql_debconf_utils
{% elif os_family == 'RedHat' or 'Suse' %}
{% if os_family in ['RedHat', 'Suse'] %}
mysql_root_password:
cmd.run:
- name: mysqladmin --user {{ mysql_root_user }} password '{{ mysql_root_password|replace("'", "'\"'\"'") }}'