Commit d882b38f authored by Daniel Dehennin's avatar Daniel Dehennin

style(setup): use “discourse.setup.caterogies” as model

- make clear the difference in the path between minion and container

- the configuration files should not depends on “service.running”,
  only the execution of the “rake” command.

- the commands should run only if there are changes in their
  configuration files.
parent 2245a4cb
......@@ -11,17 +11,22 @@ include:
- {{ sls_service_running }}
{%- set settings_filename = 'global.yaml' %}
{%- set settings_contairer_path = '/shared' | path_join('settings',
settings_filename)
%}
{%- set settings_path = discourse.directory | path_join('shared',
'standalone',
'settings',
settings_filename)
{#- On the minion #}
{%- set dir = discourse.directory | path_join('shared',
'standalone',
'settings'
)
%}
{%- set import_cmd = 'cd /var/www/discourse/ '
~ '&& rake site_settings:import '
~ '< ' ~ settings_contairer_path
{%- set settings_path = dir | path_join(settings_filename) %}
{#- In the container #}
{%- set in_container_dir = '/shared' | path_join('settings') %}
{%- set in_contairer_path = in_container_dir | path_join(settings_filename) %}
{%- set rake_cmd = 'cd /var/www/discourse/ '
~ '&& rake site_settings:import '
~ '< ' ~ in_contairer_path
%}
{%- set settings = discourse | traverse('settings', {}) %}
......@@ -41,21 +46,16 @@ discourse-setup-settings-global-file-managed:
- template: jinja
- context:
settings: {{ settings | tojson }}
- require:
- sls: {{ sls_service_running }}
discourse-setup-settings-global-import-cmd-run:
discourse-setup-settings-global-rake-cmd-run:
cmd.run:
- name: {{ discourse | traverse('launcher:run_cmd')
~ " '"
~ import_cmd
~ rake_cmd
~ "'"
}}
- cwd: {{ discourse.directory }}
- require:
- sls: {{ sls_service_running }}
- retry:
attempts: 5
until: True
interval: 5
splay: 2
- onchanges:
- file: discourse-setup-settings-global-file-managed
# -*- coding: utf-8 -*-
# vim: ft=sls
......@@ -13,27 +14,33 @@ include:
- {{ sls_service_running }}
{%- set settings_filename = 'oauth2.yaml' %}
{%- set settings_contairer_path = '/shared' | path_join('settings',
settings_filename)
%}
{%- set settings_path = discourse.directory | path_join('shared',
'standalone',
'settings',
settings_filename)
%}
{%- set import_cmd = 'cd /var/www/discourse/ '
~ '&& rake site_settings:import '
~ '< ' ~ settings_contairer_path
%}
{#- On the minion #}
{%- set dir = discourse.directory | path_join('shared',
'standalone',
'settings'
)
%}
{%- set settings_path = dir | path_join(settings_filename) %}
{#- In the container #}
{%- set in_container_dir = '/shared' | path_join('settings') %}
{%- set in_contairer_path = in_container_dir | path_join(settings_filename) %}
{%- set rake_cmd = 'cd /var/www/discourse/ '
~ '&& rake site_settings:import '
~ '< ' ~ in_contairer_path
%}
{#- the configuration mix settings with formula parameters #}
{% set skip_settings = {'git-url': true} %}
{#- all oauth2 values are prefixed with `oauth2_` #}
{%- set settings = {} %}
{%- for key, value in discourse.get('oauth2', {}).items() %}
{%- if key not in skip_settings %}
{%- do settings.update({'oauth2_' ~ key: value}) %}
{%- endif %}
{%- if key not in skip_settings %}
{%- do settings.update({'oauth2_' ~ key: value}) %}
{%- endif %}
{%- endfor %}
discourse-setup-settings-oauth2-file-managed:
......@@ -51,22 +58,17 @@ discourse-setup-settings-oauth2-file-managed:
- template: jinja
- context:
settings: {{ settings }}
- require:
- sls: {{ sls_service_running }}
discourse-setup-settings-oauth2-import-cmd-run:
cmd.run:
- name: {{ discourse | traverse('launcher:run_cmd')
~ " '"
~ import_cmd
~ rake_cmd
~ "'"
}}
- cwd: {{ discourse.directory }}
- require:
- sls: {{ sls_service_running }}
- retry:
attempts: 5
until: True
interval: 5
splay: 2
- onchanges:
- file: discourse-setup-settings-oauth2-file-managed
{%- endif %}
......@@ -10,31 +10,35 @@
include:
- {{ sls_service_running }}
{#- On the minion #}
{%- set dir = discourse.directory | path_join('shared',
'standalone',
'themes'
)
%}
{#- In the container #}
{%- set in_container_dir = '/shared' | path_join('settings') %}
{%- set themes = discourse | traverse('themes', {}) %}
{%- for name, params in themes.items() %}
{%- set theme_filename = name ~ '.yaml' %}
{%- set theme_contairer_path = '/shared' | path_join('themes',
theme_filename)
%}
{%- set theme_path = discourse.directory | path_join('shared',
'standalone',
'themes',
theme_filename)
%}
{%- set install_cmd = 'cd /var/www/discourse/ '
~ '&& rake themes:install '
~ '< ' ~ theme_contairer_path
%}
{%- set theme_filename = name ~ '.yaml' %}
{%- set theme_path = dir | path_join(theme_filename) %}
{%- set in_contairer_path = in_container_dir | path_join(theme_filename) %}
{%- set rake_cmd = 'cd /var/www/discourse/ '
~ '&& rake themes:install '
~ '< ' ~ in_contairer_path
%}
{%- set theme = {'theme_name': params.get('theme_name')} %}
{%- set install_lookup = 'discourse-setup-themes-install-' ~ name ~ '-install-file-managed' %}
{%- set theme = {'theme_name': params.get('theme_name')} %}
{%- set config_file_lookup = 'discourse-setup-themes-install-' ~ name ~ '-install-file-managed' %}
discourse-setup-themes-install-{{ name }}-config-file-managed:
file.managed:
- name: {{ theme_path }}
- source: {{ files_switch(['theme.yaml.jinja'],
lookup=install_lookup,
lookup=config_file_lookup,
use_subpath=True
)
}}
......@@ -45,22 +49,17 @@ discourse-setup-themes-install-{{ name }}-config-file-managed:
- template: jinja
- context:
theme: {{ theme | tojson }}
- require:
- sls: {{ sls_service_running }}
discourse-setup-themes-install-{{ name }}-install-cmd-run:
discourse-setup-themes-install-{{ name }}-rake-cmd-run:
cmd.run:
- name: {{ discourse | traverse('launcher:run_cmd')
~ " '"
~ install_cmd
~ rake_cmd
~ "'"
}}
- cwd: {{ discourse.directory }}
- require:
- sls: {{ sls_service_running }}
- retry:
attempts: 5
until: True
interval: 5
splay: 2
- onchanges:
- file: discourse-setup-themes-install-{{ name }}-config-file-managed
{%- endfor %}
......@@ -14,19 +14,19 @@ include:
{%- set password = params.get('password', '') %}
{%- set enabled = params.get('enabled', 'True') %}
{%- set is_admin = params.get('admin', 'False') %}
{%- set create_user_cmd = 'cd /var/www/discourse/ && rake autosetup:createuser['
~ '"' ~ email ~ '"'
~ ',"' ~ password ~ '"'
~ ',"' ~ enabled ~ '"'
~ ',"' ~ is_admin ~ '"'
~ ']'
{%- set rake_cmd = 'cd /var/www/discourse/ && rake autosetup:createuser['
~ '"' ~ email ~ '"'
~ ',"' ~ password ~ '"'
~ ',"' ~ enabled ~ '"'
~ ',"' ~ is_admin ~ '"'
~ ']'
%}
discourse-setup-users-create-{{ user }}-cmd-run:
cmd.run:
- name: {{ discourse | traverse('launcher:run_cmd')
~ " '"
~ create_user_cmd
~ rake_cmd
~ "'"
}}
- cwd: {{ discourse.directory }}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment