From 87d2af1a8aeed51420776bd7d79ee89640609fa2 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 20 Aug 2017 12:55:04 +0200 Subject: [PATCH] Add salt states for gvapgsql --- pillar/gnuviechadmin/gvapgsql.sls | 10 ++++++++++ states/gnuviechadmin/gvapgsql.sls | 18 ++++++++++++++++++ states/gnuviechadmin/gvapgsql/run_celery.sh | 12 ++++++++++++ states/gnuviechadmin/gvapgsql/settings.sh | 8 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 pillar/gnuviechadmin/gvapgsql.sls create mode 100644 states/gnuviechadmin/gvapgsql.sls create mode 100644 states/gnuviechadmin/gvapgsql/run_celery.sh create mode 100644 states/gnuviechadmin/gvapgsql/settings.sh diff --git a/pillar/gnuviechadmin/gvapgsql.sls b/pillar/gnuviechadmin/gvapgsql.sls new file mode 100644 index 0000000..0be2eae --- /dev/null +++ b/pillar/gnuviechadmin/gvapgsql.sls @@ -0,0 +1,10 @@ +include: + - gnuviechadmin + - gnuviechadmin.queues.common + - gnuviechadmin.queues.gvapgsql + +gnuviechadmin: + component: + name: gvapgsql + amqp_user: pgsql + postgresql_admin_user: gvapgsql diff --git a/states/gnuviechadmin/gvapgsql.sls b/states/gnuviechadmin/gvapgsql.sls new file mode 100644 index 0000000..3d6cb44 --- /dev/null +++ b/states/gnuviechadmin/gvapgsql.sls @@ -0,0 +1,18 @@ +include: + - gnuviechadmin.base + - gnuviechadmin.celery + +gvapgsql-pgsql-user: + postgres_user.present: + - name: {{ salt['pillar.get']('gnuviechadmin:pgsql_admin_user', 'gvapgsql') }} + - password: {{ salt['grains.get_or_set_hash']('gnuviechadmin.db_admin_password', 16) }} + - user: postgres + - superuser: True + - login: True + +gvapgsql-packages: + pkg.installed: + - pkgs: + - libpq-dev + - require_in: + - pkg: gnuviechadmin-packages diff --git a/states/gnuviechadmin/gvapgsql/run_celery.sh b/states/gnuviechadmin/gvapgsql/run_celery.sh new file mode 100644 index 0000000..a30185f --- /dev/null +++ b/states/gnuviechadmin/gvapgsql/run_celery.sh @@ -0,0 +1,12 @@ +#!/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 new file mode 100644 index 0000000..6699d03 --- /dev/null +++ b/states/gnuviechadmin/gvapgsql/settings.sh @@ -0,0 +1,8 @@ +#!/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['grains.get_or_set_hash']('gnuviechadmin.db_admin_password', 16) }}"