cubicweb/uwsgi/init.sls
author Arthur Lutz <arthur.lutz@logilab.fr>
Wed, 14 Dec 2016 15:12:19 +0100
changeset 102 6a34a4eb10ad
parent 99 5020bcb8838c
child 103 4ea00d8c15d1
permissions -rw-r--r--
[cubicweb/uwsgi] optionnal deploy of wsgi file (for looping tasks)

include:
  - cubicweb.instances
  - cubicweb.pyramid

uwsgi install:
  pkg.installed:
    - pkgs:
      - uwsgi
      - uwsgi-plugin-python

service uwsgi running:
  service.running:
    - name: uwsgi


{% for vhostname, vhost in pillar['cubicweb_apps'].iteritems() %}
 {% for name, config in vhost.iteritems() %}
/etc/uwsgi/apps-available/{{ name }}.ini:
  file.managed:
    - source: salt://cubicweb/uwsgi/uwsgi.ini
    - template: jinja
    - context:
       config: {{ config }}
       name: {{ name }}
    - require:
      - pkg: uwsgi install

/etc/uwsgi/apps-enabled/{{ name }}.ini:
  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

{% if 'file' in  config.cwapp_uwsgi_options.keys() %}
deploy wsgiapp.py for {{ name }}:
  file.managed:
    - name: {{ config.cwapp_uwsgi_options.file }}
    - source: salt://cubicweb/uwsgi/wsgiapp.py
    - template: jinja
    - group: www-data
{% endif %}

/etc/cubicweb.d/{{ name }}/sources:
  file.managed:
    - group: www-data
    - mode: "0750"

/var/lib/cubicweb/instances/{{ name }}:
  file.directory:
    - user: www-data
    - group: www-data
    - recurse:
      - user
      - group
  {% endfor %}
{% endfor %}