Setup gvamysql using new mechanisms
This commit is contained in:
parent
3b48b4a455
commit
bcb92e483d
7 changed files with 75 additions and 38 deletions
|
@ -4,8 +4,12 @@ include:
|
|||
- gnuviechadmin.queues.gvamysql
|
||||
|
||||
gnuviechadmin:
|
||||
component:
|
||||
name: gvamysql
|
||||
appname: gvamysql
|
||||
gvamysql:
|
||||
amqp_user: mysql
|
||||
mysql_admin_user: gvamysql
|
||||
mysql_admin_password: jSXstgT/AbWofdI2tJWYpQvFX1mtxt4tFMlrYxSA
|
||||
fullname: MySQL Server
|
||||
mysql_admin_user: gvamysql
|
||||
mysql_admin_password: jSXstgT/AbWofdI2tJWYpQvFX1mtxt4tFMlrYxSA
|
||||
git_url: https://git.dittberner.info/gnuviech/gvamysql.git
|
||||
git_branch: master
|
||||
celery_module: mysqltasks
|
||||
|
|
|
@ -1,28 +1,43 @@
|
|||
{% 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:
|
||||
- gnuviechadmin.base
|
||||
- gnuviechadmin.celery
|
||||
- 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: {{ salt['pillar.get']('gnuviechadmin:mysql_admin_user', 'gvamysql') }}
|
||||
- name: {{ mysql_admin_user }}
|
||||
- host: '%'
|
||||
- password: {{ salt['pillar.get']('gnuviechadmin:mysql_admin_password') }}
|
||||
- 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: {{ salt['pillar.get']('gnuviechadmin:mysql_admin_user', 'gvamysql') }}
|
||||
- password: {{ salt['pillar.get']('gnuviechadmin:mysql_admin_password') }}
|
||||
- user: {{ mysql_admin_user }}
|
||||
- password: {{ mysql_admin_password }}
|
||||
- host: '%'
|
||||
- require:
|
||||
- mysql_user: gvamysql-mysql-user
|
||||
|
||||
gvamysql-packages:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- libmariadbd-dev
|
||||
- libmysqlclient-dev
|
||||
- require_in:
|
||||
- pkg: gnuviechadmin-packages
|
||||
|
|
6
states/gnuviechadmin/gvamysql/celery-worker.env
Normal file
6
states/gnuviechadmin/gvamysql/celery-worker.env
Normal file
|
@ -0,0 +1,6 @@
|
|||
GVAMYSQL_BROKER_URL='{{ broker_url }}'
|
||||
GVAMYSQL_RESULTS_REDIS_URL="{{ result_url }}"
|
||||
GVAMYSQL_DBADMIN_HOST="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_admin_host', 'localhost') }}"
|
||||
GVAMYSQL_DBADMIN_PORT="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_admin_port', 3306) }}"
|
||||
GVAMYSQL_DBADMIN_USER="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_admin_user', 'gvamysql') }}"
|
||||
GVAMYSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_admin_password') }}"
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
. {{ home }}/gvasettings.sh
|
||||
|
||||
unset LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
|
||||
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
|
||||
LC_IDENTIFICATION LC_ALL
|
||||
|
||||
cd {{ appdir }}
|
||||
{{ virtualenv }}/bin/celery worker -A gvamysql -Q mysql --loglevel=INFO
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
export GVAMYSQL_BROKER_URL='{{ broker_url }}'
|
||||
export GVAMYSQL_RESULTS_REDIS_URL="redis://:{{ salt['pillar.get']('gnuviechadmin:redis_password') }}@{{ salt['pillar.get']('gnuviechadmin:redis_host') }}/0"
|
||||
export GVAMYSQL_DBADMIN_HOST="{{ salt['pillar.get']('gnuviechadmin:mysql_admin_host', 'localhost') }}"
|
||||
export GVAMYSQL_DBADMIN_PORT="{{ salt['pillar.get']('gnuviechadmin:mysql_admin_port', 3306) }}"
|
||||
export GVAMYSQL_DBADMIN_USER="{{ salt['pillar.get']('gnuviechadmin:mysql_admin_user', 'gvamysql') }}"
|
||||
export GVAMYSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:mysql_admin_password') }}"
|
13
states/patches/files/3000-mysql.diff
Normal file
13
states/patches/files/3000-mysql.diff
Normal file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py
|
||||
index 87e2361e28..37436206d4 100644
|
||||
--- a/salt/modules/mysql.py
|
||||
+++ b/salt/modules/mysql.py
|
||||
@@ -355,7 +355,7 @@ def _connect(**kwargs):
|
||||
except IndexError:
|
||||
return
|
||||
val = __salt__['config.option']('mysql.{0}'.format(name), None)
|
||||
- if val is not None:
|
||||
+ if val != '':
|
||||
connargs[key] = val
|
||||
|
||||
# If a default file is explicitly passed to kwargs, don't grab the
|
19
states/patches/mysql.sls
Normal file
19
states/patches/mysql.sls
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% if grains.saltversion == "3000" %}
|
||||
patch:
|
||||
pkg.installed
|
||||
|
||||
mysql_module_patch:
|
||||
file.patch:
|
||||
- name: '{{ grains.saltpath }}'
|
||||
- source: salt://patches/files/3000-mysql.diff
|
||||
- strip: 2
|
||||
- require:
|
||||
- pkg: patch
|
||||
|
||||
restart_salt_minion:
|
||||
cmd.run:
|
||||
- name: 'salt-call service.restart salt-minion'
|
||||
- bg: true
|
||||
- onchanges:
|
||||
- file: mysql_module_patch
|
||||
{%- endif %}
|
Loading…
Reference in a new issue