mysql-formula/mysql/config.sls
Sarah Rose 6f429a89e2 fixed /etc/mysql/my.cnf creation failure in debian
the config file update depends on the parent directory /etc/mysql being present, which is created as part of the mysql-server package installation. therefore, the mysqld state is split up for debian environments into the package installation and the mysqld configuration. this allows to set the pkg installation as a requirement for the config file management and to set the config file management as a requirement for the mysqld service management
2016-04-12 17:43:54 +02:00

72 lines
1.9 KiB
Text

{% from "mysql/defaults.yaml" import rawmap with context %}
{%- set mysql = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:lookup')) %}
{% set os_family = salt['grains.get']('os_family', None) %}
{% if "config_directory" in mysql %}
mysql_config_directory:
file.directory:
- name: {{ mysql.config_directory }}
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 755
{% endif %}
- makedirs: True
{% if "server_config" in mysql %}
mysql_server_config:
file.managed:
- name: {{ mysql.config_directory + mysql.server_config.file }}
- template: jinja
- source: salt://mysql/files/server.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 644
{% endif %}
{% endif %}
{% if "library_config" in mysql %}
mysql_library_config:
file.managed:
- name: {{ mysql.config_directory + mysql.library_config.file }}
- template: jinja
- source: salt://mysql/files/client.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 644
{% endif %}
{% endif %}
{% if "clients_config" in mysql %}
mysql_clients_config:
file.managed:
- name: {{ mysql.config_directory + mysql.clients_config.file }}
- template: jinja
- source: salt://mysql/files/mysql-clients.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 644
{% endif %}
{% endif %}
{% endif %}
mysql_config:
file.managed:
- name: {{ mysql.config.file }}
- require:
- pkg: {{ mysql.server }}
- template: jinja
{% if "config_directory" in mysql %}
- source: salt://mysql/files/my-include.cnf
{% else %}
- source: salt://mysql/files/my.cnf
{% endif %}
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 644
{% endif %}