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