Use os_family grain wherever possible, so the sls files work on a

broader number of Linux distributions.
This commit is contained in:
Christian Hudon 2014-08-22 15:00:36 -04:00
parent 8bff5e8aea
commit 78fddee402

View file

@ -4,7 +4,7 @@
{% set os_family = salt['grains.get']('os_family', None) %} {% set os_family = salt['grains.get']('os_family', None) %}
{% set mysql_root_password = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %} {% set mysql_root_password = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
{% if os in ['Ubuntu', 'Debian'] %} {% if os_family == 'Debian' %}
mysql_debconf: mysql_debconf:
debconf.set: debconf.set:
- name: mysql-server - name: mysql-server
@ -14,7 +14,7 @@ mysql_debconf:
'mysql-server/start_on_boot': {'type': 'boolean', 'value': 'true'} 'mysql-server/start_on_boot': {'type': 'boolean', 'value': 'true'}
- require_in: - require_in:
- pkg: mysqld - pkg: mysqld
{% elif os == 'CentOS' %} {% elif os_family == 'RedHat' %}
mysql_root_password: mysql_root_password:
cmd.run: cmd.run:
- name: mysqladmin --user root password '{{ mysql_root_password|replace("'", "'\"'\"'") }}' - name: mysqladmin --user root password '{{ mysql_root_password|replace("'", "'\"'\"'") }}'
@ -44,7 +44,7 @@ mysql_delete_anonymous_user_{{ host }}:
mysqld: mysqld:
pkg.installed: pkg.installed:
- name: {{ mysql.server }} - name: {{ mysql.server }}
{% if os in ['Ubuntu', 'Debian'] %} {% if os_family == 'Debian' %}
- require: - require:
- debconf: mysql_debconf - debconf: mysql_debconf
{% endif %} {% endif %}
@ -60,7 +60,7 @@ mysql_config:
- template: jinja - template: jinja
- watch_in: - watch_in:
- service: mysqld - service: mysqld
{% if os in ['Ubuntu', 'Debian', 'Gentoo', 'CentOS'] %} {% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- source: salt://mysql/files/{{ os }}-my.cnf - source: salt://mysql/files/{{ os }}-my.cnf
- user: root - user: root
- group: root - group: root