-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.sls
100 lines (85 loc) · 2.41 KB
/
index.sls
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{% set POD = pillar.pod -%}
{% set DOCROOT = pillar.wordpress.docroot -%}
{% set GIT = "/var/www/git" -%}
{% set WP_CONTENT = "{}/wp-content".format(DOCROOT) -%}
{% set PLUGINS = "{}/plugins".format(WP_CONTENT) -%}
{% set THEMES = "{}/themes".format(WP_CONTENT) -%}
{% set STAGE_USER = salt.pillar.get("apache2:stage_username", false) -%}
{% set STAGE_PASS = salt.pillar.get("apache2:stage_password", false) -%}
{% if POD.startswith("stage") -%}
{{ sls }} disallow robots:
file.managed:
- name: {{ DOCROOT }}/robots.txt
- contents:
- 'User-agent: *'
- 'Disallow: /'
- mode: '0400'
- require:
- file: wordpress docroot
- require_in:
- cmd: wordpress WordPress install
{%- endif %}
{% if STAGE_USER and STAGE_PASS -%}
{{ sls }} installed packages:
pkg.installed:
- pkgs:
- apache2-utils
- require:
- pkg: apache2 installed packages
{{ sls }} basic authentication user file:
file.managed:
- name: /var/www/htpasswd
- source: ~
- group: www-data
- mode: '0440'
- replace: False
- require:
- pkg: {{ sls }} installed packages
{{ sls }} basic authentication user exists:
webutil.user_exists:
- name: {{ STAGE_USER }}
- password: {{ STAGE_PASS }}
- htpasswd_file: /var/www/htpasswd
- options: s
- update: True
- require:
- file: {{ sls }} basic authentication user file
- require_in:
- cmd: wordpress WordPress install
{%- endif %}
{{ sls }} {{ GIT }} directory:
file.directory:
- name: {{ GIT }}
- mode: '2775'
- group: webdev
- require:
- file: wordpress docroot
{%- if STAGE_USER and STAGE_PASS %}
- pkg: {{ sls }} installed packages
{%- endif %}
{%- for repo in ("cc-legal-tools-data", "faq", "mp") %}
{{ sls }} {{ repo }} repo:
git.latest:
- name: 'https://github.com/creativecommons/{{ repo }}.git'
- target: {{ GIT }}/{{ repo }}
- rev: {{ pillar.index.branch }}
- branch: {{ pillar.index.branch }}
- user: composer
- fetch_tags: False
- require:
- file: {{ sls }} {{ GIT }} directory
{#- commented as it changes all file permissions leading to issue while
# updating the repo
{{ sls }} {{ repo }} permissions:
file.directory:
- name: {{ GIT }}/{{ repo }}
- dir_mode: '2775'
- file_mode: '0664'
- group: webdev
- recurse:
- mode
- group
- require:
- git: {{ sls }} {{ repo }} repo
#}
{%- endfor %}