Make gnuviechadmin components work with Poetry

This commit is contained in:
Jan Dittberner 2023-05-07 13:15:45 +02:00
parent 18f0061ee4
commit 1932c76423
18 changed files with 41 additions and 29 deletions

View file

@ -9,7 +9,7 @@ gnuviechadmin:
amqp_user: file amqp_user: file
celery_module: fileservertasks celery_module: fileservertasks
fullname: File Server fullname: File Server
git_branch: master git_branch: main
git_url: https://git.dittberner.info/gnuviech/gvafile.git git_url: https://git.dittberner.info/gnuviech/gvafile.git
mail_directory: /home/mail mail_directory: /home/mail
sftp_authkeys_directory: /srv/sftp/authorized_keys sftp_authkeys_directory: /srv/sftp/authorized_keys

View file

@ -13,7 +13,7 @@ gnuviechadmin:
celery_module: ldaptasks celery_module: ldaptasks
django_secret_key: IyOiTDt2DMo4gBVTwZ+E2p+mI1S/rNzZVIFlSr6TpgtxtsJODOVWHaxgVW3FqGZVaFU= django_secret_key: IyOiTDt2DMo4gBVTwZ+E2p+mI1S/rNzZVIFlSr6TpgtxtsJODOVWHaxgVW3FqGZVaFU=
fullname: LDAP fullname: LDAP
git_branch: master git_branch: main
git_url: https://git.dittberner.info/gnuviech/gvaldap.git git_url: https://git.dittberner.info/gnuviech/gvaldap.git
ldap_admin_password: NnVnGoWBVw6BKb9DhTwHAz0ICrdiDy+HL1A6F2Rz ldap_admin_password: NnVnGoWBVw6BKb9DhTwHAz0ICrdiDy+HL1A6F2Rz
ldap_admin_user: ldapadmin ldap_admin_user: ldapadmin

View file

@ -9,7 +9,9 @@ gnuviechadmin:
amqp_user: mysql amqp_user: mysql
celery_module: mysqltasks celery_module: mysqltasks
fullname: MySQL Server fullname: MySQL Server
git_branch: master git_branch: main
git_url: https://git.dittberner.info/gnuviech/gvamysql.git git_url: https://git.dittberner.info/gnuviech/gvamysql.git
mysql_admin_password: jSXstgT/AbWofdI2tJWYpQvFX1mtxt4tFMlrYxSA mysql_admin_password: jSXstgT/AbWofdI2tJWYpQvFX1mtxt4tFMlrYxSA
mysql_admin_user: gvamysql mysql_admin_user: gvamysql
mysql.default_file: /etc/mysql/debian.cnf

View file

@ -9,7 +9,7 @@ gnuviechadmin:
amqp_user: pgsql amqp_user: pgsql
celery_module: pgsqltasks celery_module: pgsqltasks
fullname: PostgreSQL Server fullname: PostgreSQL Server
git_branch: master git_branch: main
git_url: https://git.dittberner.info/gnuviech/gvapgsql.git git_url: https://git.dittberner.info/gnuviech/gvapgsql.git
pgsql_admin_password: AAv6d1t9p/vtX/kVorim2MJROQfQPWJoZP3mzyMW pgsql_admin_password: AAv6d1t9p/vtX/kVorim2MJROQfQPWJoZP3mzyMW
pgsql_admin_user: gvapgsql pgsql_admin_user: gvapgsql

View file

@ -9,5 +9,5 @@ gnuviechadmin:
amqp_user: web amqp_user: web
celery_module: webtasks celery_module: webtasks
fullname: Web fullname: Web
git_branch: master git_branch: main
git_url: https://git.dittberner.info/gnuviech/gvaweb.git git_url: https://git.dittberner.info/gnuviech/gvaweb.git

View file

@ -3,7 +3,7 @@ Description={{ description }}
[Service] [Service]
EnvironmentFile=-/etc/default/{{ appname }} EnvironmentFile=-/etc/default/{{ appname }}
ExecStart={{ virtualenv }}/bin/celery worker -A {{ celery_module }} -Q {{ amqpname }} --loglevel=INFO ExecStart={{ checkout }}/.venv/bin/celery --app="{{ celery_module }}" worker --queues="{{ amqpname }}" --task-events --concurrency=1 --loglevel=INFO
Restart=on-failure Restart=on-failure
User={{ app_user }} User={{ app_user }}
WorkingDirectory={{ checkout }}/{{ appname }} WorkingDirectory={{ checkout }}/{{ appname }}

View file

@ -1,3 +1,4 @@
---
{% macro gvaapp_base(gvaappname, servicename) -%} {% macro gvaapp_base(gvaappname, servicename) -%}
{% set app_home = salt['grains.get']('gnuviechadmin:home', '/home/{}'.format(gvaappname)) %} {% set app_home = salt['grains.get']('gnuviechadmin:home', '/home/{}'.format(gvaappname)) %}
{% set app_user = salt['grains.get']('gnuviechadmin:user', gvaappname) %} {% set app_user = salt['grains.get']('gnuviechadmin:user', gvaappname) %}
@ -7,7 +8,6 @@
{% set update_git = salt['grains.get']('gnuviechadmin:update_git', True) %} {% set update_git = salt['grains.get']('gnuviechadmin:update_git', True) %}
{% set gitrepo = salt['pillar.get']('gnuviechadmin:{}:git_url'.format(gvaappname), 'git:gnuviech/{}.git'.format(gvaappname)) -%} {% set gitrepo = salt['pillar.get']('gnuviechadmin:{}:git_url'.format(gvaappname), 'git:gnuviech/{}.git'.format(gvaappname)) -%}
{% set checkout = salt['grains.get']('gnuviechadmin:checkout', '/srv/{}'.format(gvaappname)) -%} {% set checkout = salt['grains.get']('gnuviechadmin:checkout', '/srv/{}'.format(gvaappname)) -%}
{% set venv = "{}/.venv".format(checkout) -%}
{% set deployment_key = '{}/.ssh/id_deployment'.format(app_home) -%} {% set deployment_key = '{}/.ssh/id_deployment'.format(app_home) -%}
{% for host in salt['pillar.get']('gnuviechadmin:machines', {}) %} {% for host in salt['pillar.get']('gnuviechadmin:machines', {}) %}
@ -77,7 +77,7 @@ gvabase-dependencies:
{% endif %} {% endif %}
{{ gvaappname }}-requirements: {{ gvaappname }}-requirements:
cmd.wait: cmd.run:
- name: /usr/local/poetry/bin/poetry install - name: /usr/local/poetry/bin/poetry install
- runas: {{ app_user }} - runas: {{ app_user }}
- cwd: {{ checkout }} - cwd: {{ checkout }}
@ -93,7 +93,7 @@ gvabase-dependencies:
- file: {{ checkout }} - file: {{ checkout }}
{%- endif %} {%- endif %}
- pkg: gvabase-dependencies - pkg: gvabase-dependencies
- unless: test $(find {{ venv }} -type f -cnewer Pipfile.lock \! -name '*.pyc'|wc -l) -gt 0 - unless: test $(find {{ checkout }}/.venv -type f -cnewer poetry.lock \! -name '*.pyc'|wc -l) -gt 0
- watch_in: - watch_in:
- service: {{ servicename }} - service: {{ servicename }}
{% endmacro %} {% endmacro %}
@ -103,7 +103,6 @@ gvabase-dependencies:
{% set app_user = salt['grains.get']('gnuviechadmin:user', gvaappname) %} {% set app_user = salt['grains.get']('gnuviechadmin:user', gvaappname) %}
{% set app_group = salt['grains.get']('gnuviechadmin:group', gvaappname) %} {% set app_group = salt['grains.get']('gnuviechadmin:group', gvaappname) %}
{% set venv = "{}/{}-venv".format(app_home, gvaappname) -%}
{% set checkout = salt['grains.get']('gnuviechadmin:checkout', '/srv/{}'.format(gvaappname)) -%} {% set checkout = salt['grains.get']('gnuviechadmin:checkout', '/srv/{}'.format(gvaappname)) -%}
{% set gitrepo = salt['pillar.get']('gnuviechadmin:{}:git_url'.format(gvaappname), 'git:gnuviech/{}.git'.format(gvaappname)) -%} {% set gitrepo = salt['pillar.get']('gnuviechadmin:{}:git_url'.format(gvaappname), 'git:gnuviech/{}.git'.format(gvaappname)) -%}
{% set update_git = salt['grains.get']('gnuviechadmin:update_git', True) %} {% set update_git = salt['grains.get']('gnuviechadmin:update_git', True) %}
@ -119,7 +118,6 @@ gvabase-dependencies:
- source: salt://gnuviechadmin/{{ gvaappname }}/celery-worker.env - source: salt://gnuviechadmin/{{ gvaappname }}/celery-worker.env
- template: jinja - template: jinja
- context: - context:
virtualenv: {{ venv }}
checkout: {{ checkout }} checkout: {{ checkout }}
broker_url: amqp://{{ amqp_user }}:{{ salt['pillar.get']('gnuviechadmin:queues:users:{}:password'.format(amqp_user)) }}@{{ salt['pillar.get']('gnuviechadmin:amqp_host', 'mq') }}/{{ salt['pillar.get']('gnuviechadmin:queues:vhost') }} broker_url: amqp://{{ amqp_user }}:{{ salt['pillar.get']('gnuviechadmin:queues:users:{}:password'.format(amqp_user)) }}@{{ salt['pillar.get']('gnuviechadmin:amqp_host', 'mq') }}/{{ salt['pillar.get']('gnuviechadmin:queues:vhost') }}
result_url: redis://:{{ salt['pillar.get']('gnuviechadmin:redis_password') }}@{{ salt['pillar.get']('gnuviechadmin:redis_host') }}/0 result_url: redis://:{{ salt['pillar.get']('gnuviechadmin:redis_password') }}@{{ salt['pillar.get']('gnuviechadmin:redis_host') }}/0
@ -134,7 +132,6 @@ gvabase-dependencies:
- source: salt://gnuviechadmin/celery-worker.service - source: salt://gnuviechadmin/celery-worker.service
- template: jinja - template: jinja
- context: - context:
virtualenv: {{ venv }}
checkout: {{ checkout }} checkout: {{ checkout }}
app_user: {{ app_user }} app_user: {{ app_user }}
appname: {{ gvaappname }} appname: {{ gvaappname }}
@ -148,7 +145,6 @@ gvabase-dependencies:
service.running: service.running:
- enable: True - enable: True
- require: - require:
- file: {{ venv }}
{%- if update_git %} {%- if update_git %}
- git: {{ gitrepo }} - git: {{ gitrepo }}
{%- else %} {%- else %}

View file

@ -7,8 +7,7 @@
{% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %} {% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %}
include: include:
- base - base
- python.pipenv - python.poetry
- python.virtualenv
- nfsserver - nfsserver
{{ mail_directory }}: {{ mail_directory }}:

View file

@ -3,3 +3,6 @@ GVAFILE_MAIL_DIRECTORY="{{ salt['pillar.get']('gnuviechadmin:gvafile:mail_direct
GVAFILE_RESULTS_REDIS_URL="{{ result_url }}" GVAFILE_RESULTS_REDIS_URL="{{ result_url }}"
GVAFILE_SFTP_AUTHKEYS_DIRECTORY="{{ salt['pillar.get']('gnuviechadmin:gvafile:sftp_authkeys_directory') }}" GVAFILE_SFTP_AUTHKEYS_DIRECTORY="{{ salt['pillar.get']('gnuviechadmin:gvafile:sftp_authkeys_directory') }}"
GVAFILE_SFTP_DIRECTORY="{{ salt['pillar.get']('gnuviechadmin:gvafile:web_directory') }}" GVAFILE_SFTP_DIRECTORY="{{ salt['pillar.get']('gnuviechadmin:gvafile:web_directory') }}"
LANG=C.UTF-8
LC_ALL=C.UTF-8
TZ=Europe/Berlin

View file

@ -1,15 +1,16 @@
---
{% set gvaappname = salt['pillar.get']('gnuviechadmin:appname') %} {% set gvaappname = salt['pillar.get']('gnuviechadmin:appname') %}
{% set purpose = "for LDAP data management" %} {% set purpose = "for LDAP data management" %}
{% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %} {% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %}
include: include:
- python.pipenv - python.poetry
- python.virtualenv
{{ create_celery_worker(gvaappname, purpose) }} {{ create_celery_worker(gvaappname, purpose) }}
{{ gvaappname }}-dependencies: {{ gvaappname }}-dependencies:
pkg.installed: pkg.installed:
- pkgs: - pkgs:
- python3-dev
- libldap2-dev - libldap2-dev
- libsasl2-dev - libsasl2-dev
- require_in: - require_in:

View file

@ -5,9 +5,12 @@ GVALDAP_ALLOWED_HOSTS="{{ salt['pillar.get']('gnuviechadmin:gvaldap:allowed_host
GVALDAP_BASEDN_GROUP="{{ salt['pillar.get']('gnuviechadmin:ldap_base_dn_groups') }}" GVALDAP_BASEDN_GROUP="{{ salt['pillar.get']('gnuviechadmin:ldap_base_dn_groups') }}"
GVALDAP_BASEDN_USER="{{ salt['pillar.get']('gnuviechadmin:ldap_base_dn_users') }}" GVALDAP_BASEDN_USER="{{ salt['pillar.get']('gnuviechadmin:ldap_base_dn_users') }}"
GVALDAP_BROKER_URL="{{ broker_url }}" GVALDAP_BROKER_URL="{{ broker_url }}"
GVALDAP_RESULTS_REDIS_URL="{{ result_url }}"
GVALDAP_LDAP_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvaldap:ldap_admin_password' ) }}" GVALDAP_LDAP_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvaldap:ldap_admin_password' ) }}"
GVALDAP_LDAP_URL="{{ salt['pillar.get']('gnuviechadmin:ldap_url') }}" GVALDAP_LDAP_URL="{{ salt['pillar.get']('gnuviechadmin:ldap_url') }}"
GVALDAP_LDAP_USER="cn={{ salt['pillar.get']('gnuviechadmin:gvaldap:ldap_admin_user') }},{{ salt['pillar.get']('gnuviechadmin:ldap_base_dn') }}" GVALDAP_LDAP_USER="cn={{ salt['pillar.get']('gnuviechadmin:gvaldap:ldap_admin_user') }},{{ salt['pillar.get']('gnuviechadmin:ldap_base_dn') }}"
GVALDAP_RESULTS_REDIS_URL="{{ result_url }}"
GVALDAP_SECRETKEY="{{ salt['pillar.get']('gnuviechadmin:gvaldap:django_secret_key') }}" GVALDAP_SECRETKEY="{{ salt['pillar.get']('gnuviechadmin:gvaldap:django_secret_key') }}"
GVALDAP_SERVER_EMAIL="{{ salt['pillar.get']('gnuviechadmin:server_email') }}" GVALDAP_SERVER_EMAIL="{{ salt['pillar.get']('gnuviechadmin:server_email') }}"
LANG=C.UTF-8
LC_ALL=C.UTF-8
TZ=Europe/Berlin

View file

@ -6,9 +6,7 @@
# FIXME: this is broken due to https://github.com/saltstack/salt/issues/56124 # FIXME: this is broken due to https://github.com/saltstack/salt/issues/56124
# patches.mysql is needed to be run on the minion before usage with Salt 3000 # patches.mysql is needed to be run on the minion before usage with Salt 3000
include: include:
- python.pipenv - python.poetry
- python.virtualenv
- patches.mysql
- mariadb-server - mariadb-server
{{ create_celery_worker(gvaappname, purpose) }} {{ create_celery_worker(gvaappname, purpose) }}
@ -16,21 +14,22 @@ include:
{{ gvaappname }}-dependencies: {{ gvaappname }}-dependencies:
pkg.installed: pkg.installed:
- pkgs: - pkgs:
- python3-dev
- libmariadb-dev-compat - libmariadb-dev-compat
- require_in: - require_in:
- cmd: {{ gvaappname }}-requirements - cmd: {{ gvaappname }}-requirements
python3-mysqldb: python3-mysqldb:
pkg.installed pip.installed:
- name: mysqlclient
gvamysql-mysql-user: gvamysql-mysql-user:
mysql_user.present: mysql_user.present:
- name: {{ mysql_admin_user }} - name: {{ mysql_admin_user }}
- host: '%' - host: '%'
- password: {{ mysql_admin_password }} - password: {{ mysql_admin_password }}
- unix_socket: true
- require: - require:
- pkg: python3-mysqldb - pip: python3-mysqldb
gvamysql-grants-all-dbs: gvamysql-grants-all-dbs:
mysql_grants.present: mysql_grants.present:
@ -41,4 +40,5 @@ gvamysql-grants-all-dbs:
- password: {{ mysql_admin_password }} - password: {{ mysql_admin_password }}
- host: '%' - host: '%'
- require: - require:
- pip: python3-mysqldb
- mysql_user: gvamysql-mysql-user - mysql_user: gvamysql-mysql-user

View file

@ -4,3 +4,6 @@ GVAMYSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_a
GVAMYSQL_DBADMIN_PORT="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_admin_port', 3306) }}" 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_USER="{{ salt['pillar.get']('gnuviechadmin:gvamysql:mysql_admin_user', 'gvamysql') }}"
GVAMYSQL_RESULTS_REDIS_URL="{{ result_url }}" GVAMYSQL_RESULTS_REDIS_URL="{{ result_url }}"
LANG=C.UTF-8
LC_ALL=C.UTF-8
TZ=Europe/Berlin

View file

@ -2,8 +2,7 @@
{% set purpose = "for PostgreSQL configuration management" %} {% set purpose = "for PostgreSQL configuration management" %}
{% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %} {% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %}
include: include:
- python.pipenv - python.poetry
- python.virtualenv
- postgresql-server - postgresql-server
{{ create_celery_worker(gvaappname, purpose) }} {{ create_celery_worker(gvaappname, purpose) }}
@ -11,6 +10,7 @@ include:
{{ gvaappname }}-dependencies: {{ gvaappname }}-dependencies:
pkg.installed: pkg.installed:
- pkgs: - pkgs:
- python3-dev
- libpq-dev - libpq-dev
- require_in: - require_in:
- cmd: {{ gvaappname }}-requirements - cmd: {{ gvaappname }}-requirements

View file

@ -4,3 +4,6 @@ GVAPGSQL_DBADMIN_HOST="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin
GVAPGSQL_DBADMIN_PORT="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_port', 5432) }}" 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_USER="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_user', 'gvapgsql') }}"
GVAPGSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_password') }}" GVAPGSQL_DBADMIN_PASSWORD="{{ salt['pillar.get']('gnuviechadmin:gvapgsql:pgsql_admin_password') }}"
LANG=C.UTF-8
LC_ALL=C.UTF-8
TZ=Europe/Berlin

View file

@ -3,8 +3,7 @@
{% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %} {% from 'gnuviechadmin/gvaapp_macros.sls' import create_celery_worker with context %}
include: include:
- base - base
- python.pipenv - python.poetry
- python.virtualenv
{{ create_celery_worker(gvaappname, purpose) }} {{ create_celery_worker(gvaappname, purpose) }}

View file

@ -3,3 +3,6 @@ GVAWEB_NGINX_SITES_AVAILABLE="{{ salt['pillar.get']('gnuviechadmin:gvaweb:nginx_
GVAWEB_NGINX_SITES_ENABLED="{{ salt['pillar.get']('gnuviechadmin:gvaweb:nginx_sites_enabled', '/etc/nginx/sites-enabled') }}" GVAWEB_NGINX_SITES_ENABLED="{{ salt['pillar.get']('gnuviechadmin:gvaweb:nginx_sites_enabled', '/etc/nginx/sites-enabled') }}"
GVAWEB_RESULTS_REDIS_URL="{{ result_url }}" GVAWEB_RESULTS_REDIS_URL="{{ result_url }}"
GVAWEB_WWWUSER_MOUNT="{{ salt['pillar.get']('gnuviechadmin:gvaweb:wwwuser_mount', '/srv/wwwfiles') }}" GVAWEB_WWWUSER_MOUNT="{{ salt['pillar.get']('gnuviechadmin:gvaweb:wwwuser_mount', '/srv/wwwfiles') }}"
LANG=C.UTF-8
LC_ALL=C.UTF-8
TZ=Europe/Berlin

View file

@ -9,7 +9,7 @@ mysql:
/etc/mysql/my.cnf: /etc/mysql/my.cnf:
file.managed: file.managed:
- owner: root - user: root
- group: root - group: root
- mode: 0644 - mode: 0644
- source: salt://mariadb-server/my.cnf - source: salt://mariadb-server/my.cnf