[constellation] Install constellation from Python module in production
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>certbot_on_virtu
parent
3f22b96f11
commit
3f033ad95e
|
@ -11,15 +11,11 @@ service_nginx:
|
|||
locations:
|
||||
- filter: "/static"
|
||||
params:
|
||||
- "alias /var/local/constellation/static/"
|
||||
|
||||
- filter: "/javascript"
|
||||
params:
|
||||
- "alias /usr/share/javascript/"
|
||||
- "alias {% if constellation.version == 'master' %}/var/lib/constellation/static/{% else %}/var/local/constellation/static/{% endif %}"
|
||||
|
||||
- filter: "/media"
|
||||
params:
|
||||
- "alias /var/local/constellation/media/"
|
||||
- "alias {% if constellation.version == 'master' %}/var/lib/constellation/media/{% else %}/var/local/constellation/media/{% endif %}"
|
||||
|
||||
- filter: "/"
|
||||
params:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Reload uWSGI
|
||||
- name: Restart uWSGI
|
||||
systemd:
|
||||
name: uwsgi
|
||||
state: reloaded
|
||||
state: restarted
|
||||
|
|
|
@ -18,6 +18,28 @@
|
|||
name:
|
||||
- git+https://gitlab.adm.crans.org/nounous/crispy-bootstrap5.git
|
||||
|
||||
- name: Set data directories in development mode
|
||||
when: constellation.version != "master"
|
||||
set_fact:
|
||||
project_path: "/var/local/constellation"
|
||||
module_path: "/var/local/constellation/constellation"
|
||||
static_dir: "/var/local/constellation/static"
|
||||
media_dir: "/var/local/constellation/media"
|
||||
|
||||
- name: Set data directories in production mode
|
||||
when: constellation.version == "master"
|
||||
set_fact:
|
||||
project_path: "/usr/local/lib/python3.9/dist-packages/constellation"
|
||||
module_path: "/usr/local/lib/python3.9/dist-packages/constellation"
|
||||
static_dir: "/var/lib/constellation/static"
|
||||
media_dir: "/var/lib/constellation/media"
|
||||
|
||||
- name: Check front dependencies (production)
|
||||
when: constellation.version == "master"
|
||||
pip:
|
||||
name:
|
||||
- git+https://gitlab.adm.crans.org/nounous/constellation.git[front]
|
||||
|
||||
- name: Install uWSGI
|
||||
apt:
|
||||
install_recommends: false
|
||||
|
@ -36,7 +58,7 @@
|
|||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: Reload uWSGI
|
||||
notify: Restart uWSGI
|
||||
|
||||
- name: Activate constellation uWSGI app
|
||||
file:
|
||||
|
@ -46,38 +68,41 @@
|
|||
group: root
|
||||
state: link
|
||||
ignore_errors: "{{ ansible_check_mode }}"
|
||||
notify: Reload uWSGI
|
||||
notify: Restart uWSGI
|
||||
|
||||
# In the future, migrations will be included in the repository.
|
||||
- name: Make Django migrations
|
||||
django_manage:
|
||||
command: makemigrations
|
||||
project_path: "/var/local/constellation"
|
||||
notify: Reload uWSGI
|
||||
project_path: "{{ project_path }}"
|
||||
notify: Restart uWSGI
|
||||
|
||||
- name: Migrate database
|
||||
django_manage:
|
||||
command: migrate
|
||||
project_path: "/var/local/constellation"
|
||||
notify: Reload uWSGI
|
||||
project_path: "{{ project_path }}"
|
||||
notify: Restart uWSGI
|
||||
|
||||
- name: Load initial data
|
||||
django_manage:
|
||||
command: loaddata initial
|
||||
project_path: "/var/local/constellation"
|
||||
notify: Reload uWSGI
|
||||
project_path: "{{ project_path }}"
|
||||
notify: Restart uWSGI
|
||||
|
||||
- name: Create static files directory
|
||||
file:
|
||||
path: /var/local/constellation/static
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: '2775'
|
||||
owner: "www-data"
|
||||
group: "{{ constellation.group }}"
|
||||
recurse: true
|
||||
loop:
|
||||
- "{{ static_dir }}"
|
||||
- "{{ media_dir }}"
|
||||
|
||||
- name: Collect static files
|
||||
django_manage:
|
||||
command: collectstatic
|
||||
project_path: "/var/local/constellation"
|
||||
notify: Reload uWSGI
|
||||
project_path: "{{ project_path }}"
|
||||
notify: Restart uWSGI
|
||||
|
|
|
@ -5,8 +5,8 @@ uid = www-data
|
|||
gid = www-data
|
||||
# Django-related settings
|
||||
# the base directory (full path)
|
||||
chdir = /var/local/constellation
|
||||
wsgi-file = /var/local/constellation/constellation/wsgi.py
|
||||
chdir = {{ project_path }}
|
||||
wsgi-file = {{ module_path }}/wsgi.py
|
||||
plugin = python3
|
||||
# process-related settings
|
||||
# master
|
||||
|
@ -20,4 +20,4 @@ chmod-socket = 664
|
|||
# clear environment on exit
|
||||
vacuum = true
|
||||
# Touch reload
|
||||
touch-reload = /var/local/constellation/constellation/settings.py
|
||||
touch-reload = {{ module_path }}/settings.py
|
||||
|
|
|
@ -28,9 +28,23 @@
|
|||
name:
|
||||
- git+https://gitlab.adm.crans.org/nounous/django-dnsmanager.git
|
||||
|
||||
- name: Set configuration directories in development mode
|
||||
when: constellation.version != "master"
|
||||
set_fact:
|
||||
config_file: "/var/local/constellation/constellation/settings_local.py"
|
||||
config_dir: "/var/local/constellation"
|
||||
project_path: "/var/local/constellation"
|
||||
|
||||
- name: Set configuration directories in production mode
|
||||
when: constellation.version == "master"
|
||||
set_fact:
|
||||
config_file: "/etc/constellation/settings_local.py"
|
||||
config_dir: "/etc/constellation"
|
||||
project_path: "/usr/local/lib/python3.9/dist-packages/constellation"
|
||||
|
||||
- name: Create constellation directory
|
||||
file:
|
||||
path: /var/local/constellation
|
||||
path: "{{ config_dir }}"
|
||||
state: directory
|
||||
mode: '2775'
|
||||
owner: "{{ constellation.owner }}"
|
||||
|
@ -38,7 +52,7 @@
|
|||
|
||||
- name: Set ACL for constellation directory
|
||||
acl:
|
||||
path: /var/local/constellation
|
||||
path: "{{ config_dir }}"
|
||||
default: true
|
||||
entity: nounou
|
||||
etype: group
|
||||
|
@ -46,17 +60,25 @@
|
|||
state: query
|
||||
ignore_errors: "{{ ansible_check_mode }}"
|
||||
|
||||
- name: Clone constellation repository
|
||||
- name: Clone constellation repository (development)
|
||||
when: constellation.version != "master"
|
||||
git:
|
||||
repo: 'https://gitlab.adm.crans.org/nounous/constellation.git'
|
||||
dest: /var/local/constellation
|
||||
dest: "{{ project_path }}"
|
||||
umask: '002'
|
||||
version: "{{ constellation.version }}"
|
||||
recursive: true
|
||||
|
||||
- name: Install constellation (production)
|
||||
when: constellation.version == "master"
|
||||
pip:
|
||||
name:
|
||||
- git+https://gitlab.adm.crans.org/nounous/constellation.git
|
||||
|
||||
- name: Set owner of cloned project
|
||||
when: constellation.version != "master"
|
||||
file:
|
||||
path: /var/local/constellation
|
||||
path: "{{ project_path }}"
|
||||
owner: "{{ constellation.owner }}"
|
||||
group: "{{ constellation.group }}"
|
||||
recurse: true
|
||||
|
@ -64,35 +86,42 @@
|
|||
- name: Deploy Constellation settings_local.py
|
||||
template:
|
||||
src: constellation/settings_local.py.j2
|
||||
dest: /var/local/constellation/constellation/settings_local.py
|
||||
dest: "{{ config_file }}"
|
||||
mode: 0660
|
||||
owner: "{{ constellation.settings_local_owner }}"
|
||||
group: "{{ constellation.settings_local_group }}"
|
||||
|
||||
- name: Symlink configuration file (production)
|
||||
when: constellation.version == "master"
|
||||
file:
|
||||
src: "{{ config_file }}"
|
||||
dest: "{{ project_path }}/settings_local.py"
|
||||
state: link
|
||||
|
||||
- name: Compile messages
|
||||
when: not constellation.front
|
||||
django_manage:
|
||||
command: compilemessages
|
||||
project_path: "/var/local/constellation"
|
||||
project_path: "{{ project_path }}"
|
||||
|
||||
# In the future, migrations will be included in the repository.
|
||||
- name: Make Django migrations (non-front app)
|
||||
when: not constellation.front
|
||||
django_manage:
|
||||
command: makemigrations
|
||||
project_path: "/var/local/constellation"
|
||||
project_path: "{{ project_path }}"
|
||||
|
||||
- name: Migrate database (non-front app)
|
||||
when: not constellation.front
|
||||
django_manage:
|
||||
command: migrate
|
||||
project_path: "/var/local/constellation"
|
||||
project_path: "{{ project_path }}"
|
||||
|
||||
- name: Load initial data (non-front app)
|
||||
when: not constellation.front
|
||||
django_manage:
|
||||
command: loaddata initial
|
||||
project_path: "/var/local/constellation"
|
||||
project_path: "{{ project_path }}"
|
||||
|
||||
- name: Indicate constellation in motd
|
||||
template:
|
||||
|
|
|
@ -38,6 +38,14 @@ DATABASES = {
|
|||
},
|
||||
}
|
||||
|
||||
{% if constellation.version == "master" %}
|
||||
{% if constellation.front %}
|
||||
STATIC_ROOT = "/var/lib/constellation/static/"
|
||||
|
||||
{% endif %}
|
||||
MEDIA_ROOT = "/var/lib/constellation/media/"
|
||||
{% endif %}
|
||||
|
||||
# The mail configuration for Constellation to send mails
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_USE_SSL = {{ constellation.email.ssl }}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/usr/bin/tail +14
|
||||
{{ ansible_header | comment }}
|
||||
[0m> [38;5;82mConstellation[0m a été déployé sur cette machine. Voir [38;5;6m/var/www/constellation/[0m.
|
||||
[0m> [38;5;82mConstellation[0m a été déployé sur cette machine. Voir [38;5;6m{{ project_path }}/[0m.
|
||||
|
|
Loading…
Reference in New Issue