gvasalt/states/gnuviechadmin/gvamysql.sls

43 lines
1.3 KiB
Text

{% set gvaappname = salt['pillar.get']('gnuviechadmin:appname') %}
{% set purpose = "for MySQL/MariaDB configuration management" %}
{% set mysql_admin_user = salt['pillar.get']('gnuviechadmin:{}:mysql_admin_user'.format(gvaappname), 'gvamysql') %}
{% set mysql_admin_password = salt['pillar.get']('gnuviechadmin:{}:mysql_admin_password'.format(gvaappname)) %}
{% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %}
include:
- python.pipenv
- python.virtualenv
- mariadb-server
{{ create_celery_worker(gvaappname, purpose) }}
{{ gvaappname }}-dependencies:
pkg.installed:
- pkgs:
- libmariadb-dev-compat
- require_in:
- cmd: {{ gvaappname }}-requirements
python3-mysqldb:
pkg.installed
# FIXME: this is broken due to https://github.com/saltstack/salt/issues/56124
# require salt-call state.sls patch.mysql to be run on the minion before usage
gvamysql-mysql-user:
mysql_user.present:
- name: {{ mysql_admin_user }}
- host: '%'
- password: {{ mysql_admin_password }}
- unix_socket: true
- require:
- pkg: python3-mysqldb
gvamysql-grants-all-dbs:
mysql_grants.present:
- grant: ALL PRIVILEGES
- database: '*.*'
- grant_option: True
- user: {{ mysql_admin_user }}
- password: {{ mysql_admin_password }}
- host: '%'
- require:
- mysql_user: gvamysql-mysql-user