summaryrefslogtreecommitdiffstats
path: root/salt/profile/lighttpd/init.sls
blob: 662f8f18a0ba3e9cd50f9b60b99e6f92f500698d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{%- set mypillar = 'profile:lighttpd' -%}
{%- set vhosts = salt['pillar.get'](mypillar ~ ':vhosts') or [] -%}

lighttpd_packages:
  pkg.installed:
    - pkgs:
      - lighttpd

{%- if vhosts | length > 0 %}
lighttpd_directories:
  file.directory:
    - user: root
    - group: lighttpd
    - mode: '0750'
    - clean: True
    - require:
      - pkg: lighttpd_packages
      - file: lighttpd_files
    - names:
      - /etc/lighttpd/vhosts.d

lighttpd_files:
  file.managed:
    - user: root
    - group: lighttpd
    - mode: '0640'
    - template: jinja
    - watch_in:
      - service: lighttpd_service
    - names:
      - /etc/lighttpd/lighttpd.conf:
        - source: salt:///{{ slspath }}/files/etc/lighttpd/lighttpd.conf.j2
{%- for vhost, config in vhosts.items() %}
      - /etc/lighttpd/vhosts.d/{{ vhost }}.conf:
        - source: salt:///{{ slspath }}/files/etc/lighttpd/vhosts.conf.j2
        - context:
            vhostconfig: {{ config }}
{%- endfor %}
{%- endif %}

lighttpd_service:
  service.running:
    - name: lighttpd.service
    - enable: True
    - reload: True
    - require:
      - pkg: lighttpd_packages