store settings file in ~/.config/publik (#24505)

And allow additional user config in settings.d
sub directories.
This commit is contained in:
Emmanuel Cazenave 2018-11-16 08:28:53 +01:00
parent 9b0f025786
commit 1d1e2b9dc7
10 changed files with 62 additions and 20 deletions

View File

@ -6,4 +6,3 @@
- deploy-tenants
vars:
venv_bin: "{{venv}}/bin"
venv_conf: "{{venv}}/conf"

View File

@ -2,6 +2,8 @@ compile_theme: true
django_version: 1.11.18
git_ssh: false
clone_repo: true
publik_conf: "/home/{{user}}/.config/publik"
publik_settings: "{{publik_conf}}/settings"
src_dir: "/home/{{user}}/src"
ssl_certificate: "{{venv_certs}}/dev.publik.love-fullchain.pem"
ssl_certificate_key: "{{venv_certs}}/dev.publik.love-privkey.pem"

View File

@ -19,7 +19,6 @@
themes_dir: "{{venv}}/themes"
venv_bin: "{{venv}}/bin"
venv_certs: "{{venv}}/certs"
venv_conf: "{{venv}}/conf"
venv_pip: "{{venv_bin}}/pip"
venv_python: "{{venv_bin}}/python"
venv_share: "{{venv}}/share"

View File

@ -1,6 +1,7 @@
- name: set ansible server variables
set_fact:
app_settings: "{{venv_conf}}/{{db_name}}_settings.py"
app_settings: "{{publik_settings}}/{{project_name}}/settings.py"
app_settings_dir: "{{publik_settings}}/{{project_name}}"
manage_app_bin: "{{venv_bin}}/{{project_name}}-manage"
server_app_name: "{{project_name}}-server"
@ -11,14 +12,6 @@
become: yes
become_user: postgres
- name: "{{app_name}} - conf directory"
file:
path: "{{venv_conf}}"
state: directory
owner: "{{user}}"
group: "{{user}}"
become: yes
- name: "{{app_name}} - /var/lib directory"
file:
path: "/var/lib/{{project_name}}"
@ -54,6 +47,20 @@
executable: /bin/bash
become: yes
- name: "settings directory"
file:
path: "{{app_settings_dir}}"
state: directory
owner: "{{user}}"
group: "{{user}}"
- name: "settings.d directory"
file:
path: "{{app_settings_dir}}/settings.d"
state: directory
owner: "{{user}}"
group: "{{user}}"
- name: "{{app_name}} - settings file"
template:
src: "{{app_name}}-settings.j2"

View File

@ -1,5 +1,9 @@
# This file is sourced by "execfile" from hobo.settings
# Don't modify this file, it will be overwritten if you update your
# publik installation.
# Custom settings should be declared in *.py file under the settings.d directory
import glob
import os
{% block app_custom_before %}{% endblock %}
@ -43,3 +47,6 @@ DEBUG = True
{% block app_custom_after %}{% endblock %}
for filename in sorted(
glob.glob(os.path.join('{{app_settings_dir}}', 'settings.d', '*.py'))):
execfile(filename)

View File

@ -27,7 +27,7 @@ MIDDLEWARE_CLASSES = (
# }
# }
WCS_LEGACY_CONFIG_FILE = '{{venv_conf}}/wcs.cfg'
WCS_LEGACY_CONFIG_FILE = '{{app_settings_dir}}/wcs.cfg'
WCS_EXTRA_MODULES = ['{{src_dir}}/auquotidien/auquotidien']
{% endblock %}

View File

@ -58,6 +58,16 @@
path: "{{venv_share}}"
state: directory
- name: "create conf directory"
file:
path: "{{publik_conf}}"
state: directory
- name: "create settings directory"
file:
path: "{{publik_settings}}"
state: directory
- name: create getlasso script
template:
src: getlasso.j2

View File

@ -2,7 +2,8 @@
set_fact:
agent_dash_name: "hobo-agent"
agent_dot_name: "hobo.agent"
agent_settings: "{{venv_conf}}/hobo_agent_settings.py"
agent_settings: "{{publik_settings}}/hobo-agent/settings.py"
app_settings_dir: "{{publik_settings}}/hobo-agent"
- name: create hobo agent log directory
file:
@ -12,6 +13,13 @@
group: "{{user}}"
become: yes
- name: "settings directory"
file:
path: "{{app_settings_dir}}"
state: directory
owner: "{{user}}"
group: "{{user}}"
- name: hobo agent settings file
template:
src: hobo-agent-settings.j2

View File

@ -12,7 +12,7 @@ AGENT_HOST_PATTERNS = {
{% filter upper %}{{appkey}}{% endfilter %}_MANAGE_COMMAND = "{{venv_bin}}/{{app['project_name']}}-manage"
{% filter upper %}{{appkey}}{% endfilter %}_MANAGE_TRY_COMMAND = {% filter upper %}{{appkey}}{% endfilter %}_MANAGE_COMMAND
{% else %}
WCS_MANAGE_COMMAND = "{{venv_bin}}/wcsctl.py -f {{venv_conf}}/wcs.cfg"
WCS_MANAGE_COMMAND = "{{venv_bin}}/wcsctl.py -f {{publik_settings}}/wcs/wcs.cfg"
WCS_MANAGE_TRY_COMMAND = "{{venv_bin}}/wcsctl.py"
{% endif %}
{% endfor %}
{% endfor %}

View File

@ -27,14 +27,24 @@
path: "{{venv_share}}/{{app_name}}"
state: directory
- name: "settings directory"
file:
path: "{{publik_settings}}/{{project_name}}"
state: directory
owner: "{{user}}"
group: "{{user}}"
- name: "settings.d directory"
file:
path: "{{publik_settings}}/{{project_name}}/settings.d"
state: directory
owner: "{{user}}"
group: "{{user}}"
- name: wcs.cfg
template:
src: wcs.cfg
dest: "{{venv_conf}}/wcs.cfg"
- name: wcs app setup
import_role:
name: app-setup
dest: "{{publik_settings}}/{{app_name}}/wcs.cfg"
- name: wcs app setup
import_role: