From 3b48b4a455ac7f885f9087ba8b8a92ddef3725be Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Wed, 4 Mar 2020 17:47:24 +0100 Subject: [PATCH] Setup gvapgsql using new mechanisms --- pillar/gnuviechadmin/gvapgsql.sls | 12 +++++--- states/gnuviechadmin/gvapgsql.sls | 30 ++++++++++++------- .../gnuviechadmin/gvapgsql/celery-worker.env | 6 ++++ states/gnuviechadmin/gvapgsql/run_celery.sh | 12 -------- states/gnuviechadmin/gvapgsql/settings.sh | 8 ----- 5 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 states/gnuviechadmin/gvapgsql/celery-worker.env delete mode 100644 states/gnuviechadmin/gvapgsql/run_celery.sh delete mode 100644 states/gnuviechadmin/gvapgsql/settings.sh diff --git a/pillar/gnuviechadmin/gvapgsql.sls b/pillar/gnuviechadmin/gvapgsql.sls index 71171cf..5fa8d13 100644 --- a/pillar/gnuviechadmin/gvapgsql.sls +++ b/pillar/gnuviechadmin/gvapgsql.sls @@ -4,8 +4,12 @@ include: - gnuviechadmin.queues.gvapgsql gnuviechadmin: - component: - name: gvapgsql + appname: gvapgsql + gvapgsql: amqp_user: pgsql - pgsql_admin_user: gvapgsql - pgsql_admin_password: AAv6d1t9p/vtX/kVorim2MJROQfQPWJoZP3mzyMW + fullname: PostgreSQL Server + pgsql_admin_user: gvapgsql + pgsql_admin_password: AAv6d1t9p/vtX/kVorim2MJROQfQPWJoZP3mzyMW + git_url: https://git.dittberner.info/gnuviech/gvapgsql.git + git_branch: master + celery_module: pgsqltasks diff --git a/states/gnuviechadmin/gvapgsql.sls b/states/gnuviechadmin/gvapgsql.sls index 3e83898..10d752d 100644 --- a/states/gnuviechadmin/gvapgsql.sls +++ b/states/gnuviechadmin/gvapgsql.sls @@ -1,18 +1,26 @@ +{% set gvaappname = salt['pillar.get']('gnuviechadmin:appname') %} +{% set purpose = "for PostgreSQL configuration management" %} +{% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %} include: - - gnuviechadmin.base - - gnuviechadmin.celery +- python.pipenv +- python.virtualenv +- postgresql-server -gvapgsql-pgsql-user: - postgres_user.present: - - name: {{ salt['pillar.get']('gnuviechadmin:pgsql_admin_user', 'gvapgsql') }} - - password: {{ salt['pillar.get']('gnuviechadmin:pgsql_admin_password') }} - - user: postgres - - superuser: True - - login: True +{{ create_celery_worker(gvaappname, purpose) }} -gvapgsql-packages: +{{ gvaappname }}-dependencies: pkg.installed: - pkgs: - libpq-dev - require_in: - - pkg: gnuviechadmin-packages + - cmd: {{ gvaappname }}-requirements + +gvapgsql-pgsql-user: + postgres_user.present: + - name: {{ salt['pillar.get']('gnuviechadmin:{}:pgsql_admin_user'.format(gvaappname), 'gvapgsql') }} + - password: {{ salt['pillar.get']('gnuviechadmin:{}:pgsql_admin_password'.format(gvaappname)) }} + - user: postgres + - superuser: True + - login: True + - require: + - pkg: postgresql diff --git a/states/gnuviechadmin/gvapgsql/celery-worker.env b/states/gnuviechadmin/gvapgsql/celery-worker.env new file mode 100644 index 0000000..21bc468 --- /dev/null +++ b/states/gnuviechadmin/gvapgsql/celery-worker.env @@ -0,0 +1,6 @@ +GVAPGSQL_BROKER_URL='{{ broker_url }}' +GVAPGSQL_RESULTS_REDIS_URL="{{ result_url }}" +GVAPGSQL_DBADMIN_HOST="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_host', 'localhost') }}" +GVAPGSQL_DBADMIN_PORT="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_port', 5432) }}" +GVAPGSQL_DBADMIN_USER="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_user', 'gvapgsql') }}" +GVAPGSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_password') }}" diff --git a/states/gnuviechadmin/gvapgsql/run_celery.sh b/states/gnuviechadmin/gvapgsql/run_celery.sh deleted file mode 100644 index a30185f..0000000 --- a/states/gnuviechadmin/gvapgsql/run_celery.sh +++ /dev/null @@ -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 gvapgsql -Q pgsql --loglevel=INFO diff --git a/states/gnuviechadmin/gvapgsql/settings.sh b/states/gnuviechadmin/gvapgsql/settings.sh deleted file mode 100644 index b97a85f..0000000 --- a/states/gnuviechadmin/gvapgsql/settings.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -export GVAPGSQL_BROKER_URL='{{ broker_url }}' -export GVAPGSQL_RESULTS_REDIS_URL="redis://:{{ salt['pillar.get']('gnuviechadmin:redis_password') }}@{{ salt['pillar.get']('gnuviechadmin:redis_host') }}/0" -export GVAPGSQL_DBADMIN_HOST="{{ salt['pillar.get']('gnuviechadmin:pgsql_admin_host', 'localhost') }}" -export GVAPGSQL_DBADMIN_PORT="{{ salt['pillar.get']('gnuviechadmin:pgsql_admin_port', 5432) }}" -export GVAPGSQL_DBADMIN_USER="{{ salt['pillar.get']('gnuviechadmin:pgsql_admin_user', 'gvapgsql') }}" -export GVAPGSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:pgsql_admin_password') }}"