[cubicweb] start using top-down type includes instead of massive loops
authorArthur Lutz <arthur.lutz@logilab.fr>
Tue, 29 Nov 2016 16:05:52 +0100
changeset 94 17fea6c77efe
parent 93 c864a52ea401
child 95 a2dec3ea5641
[cubicweb] start using top-down type includes instead of massive loops
README.rst
cubicweb/instances.sls
cubicweb/monitor.sls
cubicweb/pyramid/init.sls
cubicweb/uwsgi/init.sls
--- a/README.rst	Tue Nov 29 15:27:01 2016 +0100
+++ b/README.rst	Tue Nov 29 16:05:52 2016 +0100
@@ -25,6 +25,19 @@
 
 Installs cubicweb and configures an application
 
+``cubicweb.pyramid``
+----------------------
+
+Installs cubicweb and configures an application with pyramid (includes
+instances)
+
+``cubicweb.uwsgi``
+----------------------
+
+Installs cubicweb and configures an application with uwsgi (includes
+pyramid & instances)
+
+
 ``cubicweb.apache``
 -------------------
 
@@ -40,6 +53,11 @@
 
 Installs cubicweb with twisted (deprecated)
 
+``cubicweb.monit``
+------------------
+
+Requires monit and nagios formulas (see below)
+
 
 Quick start
 ===========
@@ -64,6 +82,10 @@
 
 * `postgres-formula <https://github.com/saltstack-formulas/postgres-formula>`_
 
+* `monit-formula <https://github.com/saltstack-formulas/monit-formula>`_
+
+* `nagios-formula <https://github.com/saltstack-formulas/nagios-formula>`_
+
 `saem-formula <https://github.com/logilab/saemref-formula>`_ can also
 serve as inspiration for deploying an application
 
--- a/cubicweb/instances.sls	Tue Nov 29 15:27:01 2016 +0100
+++ b/cubicweb/instances.sls	Tue Nov 29 16:05:52 2016 +0100
@@ -1,16 +1,5 @@
 include:
   - cubicweb
-{% for vhostname, vhost in pillar['cubicweb_apps'].iteritems() %}
- {% for name, config in vhost.iteritems() %}
-   {% if 'pyramid' in config %}
-  - cubicweb.pyramid
-   {% endif %}
-   {% if 'cwapp_uwsgi_options' in config %}
-  - cubicweb.uwsgi
-   {% endif %}
- {% endfor %}
-{% endfor %}
-
 
 {% for extrasrc in salt['pillar.get']('extra_sources', ()) %}
   {% if 'https' in  extrasrc %}
@@ -67,6 +56,8 @@
     - name: /etc/cubicweb.d/{{name}}/all-in-one.conf
     - sections:
         {{ config.get('cwapp_config_options', {}) }}
+    - require:
+      - cubicweb_instance: cw-{{vhostname}}-{{name}}
 {% if config.cwapp.get('running', True) %}
     - watch_in:
       - cubicweb_instance: cw-{{vhostname}}-{{name}}-running
--- a/cubicweb/monitor.sls	Tue Nov 29 15:27:01 2016 +0100
+++ b/cubicweb/monitor.sls	Tue Nov 29 16:05:52 2016 +0100
@@ -1,7 +1,8 @@
 # TODO - avoid having this dependency
-include: 
+include:
     - monit
     - nagios
+#    - nagios.nerp.server # formula
 
 # TODO replace by debian package installation
 # cf https://intranet.logilab.fr/jpl/ticket/199142
@@ -14,7 +15,7 @@
         - target: /usr/share/munin/plugins/cubicweb_stats
 
 /etc/munin/plugin-conf.d/cubicweb-stats:
-    file.managed:  
+    file.managed:
         - source: salt://munin/plugin-conf.d/cubicweb-stats
 
 
--- a/cubicweb/pyramid/init.sls	Tue Nov 29 15:27:01 2016 +0100
+++ b/cubicweb/pyramid/init.sls	Tue Nov 29 16:05:52 2016 +0100
@@ -1,3 +1,7 @@
+include:
+  - cubicweb.instances
+  - cubicweb.uwsgi
+
 {% for vhostname, vhost in pillar['cubicweb_apps'].iteritems() %}
  {% for name, config in vhost.iteritems() %}
 /etc/cubicweb.d/{{ name }}/pyramid.ini:
@@ -10,9 +14,6 @@
     {% if 'cwapp_uwsgi_options' in config %}
     - watch:
         - service: uwsgi
-
-include:
-  - cubicweb.uwsgi
     {% endif %}
   {% endfor %}
 {% endfor %}
--- a/cubicweb/uwsgi/init.sls	Tue Nov 29 15:27:01 2016 +0100
+++ b/cubicweb/uwsgi/init.sls	Tue Nov 29 16:05:52 2016 +0100
@@ -1,3 +1,6 @@
+include:
+  - cubicweb.instances
+  - cubicweb.pyramid
 
 uwsgi install:
   pkg.installed:
@@ -26,6 +29,7 @@
   file.symlink:
     - target: /etc/uwsgi/apps-available/{{ name }}.ini
     - require:
+      - cubicweb_instance: cw-{{vhostname}}-{{name}}
       - file: /etc/uwsgi/apps-available/{{ name }}.ini
     - watch:
       - service: uwsgi