2020-07-10 00:58:55 +02:00
|
|
|
---
|
|
|
|
{%- from "nginx/map.jinja" import nginx with context -%}
|
|
|
|
{%- for configfile in nginx.config.files %}
|
|
|
|
nginx-config-{{ configfile }}:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ nginx.config.dir }}/{{ configfile }}
|
|
|
|
- source: salt://nginx/templates/{{ configfile }}.j2
|
|
|
|
- template: jinja
|
|
|
|
- user: {{ nginx.config.user }}
|
|
|
|
- group: {{ nginx.config.group }}
|
|
|
|
- watch_in:
|
|
|
|
- service: nginx-service
|
2022-10-10 10:19:42 +02:00
|
|
|
#- watch:
|
|
|
|
# - pki: pki-fetched
|
|
|
|
#- require:
|
|
|
|
# - sls: acme.*
|
2020-07-10 00:58:55 +02:00
|
|
|
{%- endfor %}
|
|
|
|
|
2023-01-04 23:33:04 +01:00
|
|
|
nginx-default-index-file:
|
|
|
|
file.managed:
|
|
|
|
- name: /var/www/html/index.html
|
|
|
|
- user: root
|
|
|
|
- group: root
|
|
|
|
- contents: "<html><head></head><body></body></html>"
|
|
|
|
|
2020-07-10 00:58:55 +02:00
|
|
|
nginx-config-wipe-default:
|
|
|
|
file.absent:
|
|
|
|
- name: /etc/nginx/sites-enabled/default
|
|
|
|
|
|
|
|
{%- for subdir in nginx.config.subdirs %}
|
|
|
|
nginx-config-dir-{{ subdir }}:
|
|
|
|
file.directory:
|
|
|
|
- name: {{ nginx.config.dir }}/{{ subdir }}
|
|
|
|
- user: {{ nginx.config.user }}
|
|
|
|
- group: {{ nginx.config.group }}
|
|
|
|
- watch_in:
|
|
|
|
- service: nginx-service
|
|
|
|
{%- endfor %}
|
|
|
|
|
2023-01-04 23:33:04 +01:00
|
|
|
{%- for name, vhost in nginx.vhosts.items() %}
|
|
|
|
nginx-sites-available-{{ name }}:
|
2020-07-10 00:58:55 +02:00
|
|
|
file.managed:
|
2023-01-04 23:33:04 +01:00
|
|
|
- name: {{ nginx.config.dir }}/sites-available/{{ name }}
|
2020-07-19 23:41:13 +02:00
|
|
|
- source: salt://nginx/templates/types/{{ vhost.type }}.j2
|
2020-07-10 00:58:55 +02:00
|
|
|
- template: jinja
|
|
|
|
- user: {{ nginx.config.user }}
|
|
|
|
- group: {{ nginx.config.group }}
|
|
|
|
- require:
|
|
|
|
- file: nginx-config-dir-sites-available
|
|
|
|
- file: nginx-config-dir-sites-enabled
|
2020-07-30 14:07:42 +02:00
|
|
|
- watch_in:
|
|
|
|
- service: nginx-service
|
2020-07-10 00:58:55 +02:00
|
|
|
- context:
|
2023-01-04 23:33:04 +01:00
|
|
|
vhost_name: {{ name }}
|
|
|
|
sub: {{ vhost.sub|default([]) }}
|
2022-04-18 21:24:56 +02:00
|
|
|
config_dir: {{ nginx.config.dir }}
|
2020-07-10 00:58:55 +02:00
|
|
|
https: {{ vhost.https|default(true) }}
|
|
|
|
proxy: {{ vhost.proxy|default(false) }}
|
|
|
|
proxy_pass: {{ vhost.proxy_pass|default("") }}
|
|
|
|
cache: {{ vhost.cache|default(true) }}
|
|
|
|
autoindex: {{ vhost.autoindex|default(false) }}
|
2021-08-19 09:55:49 +02:00
|
|
|
root_dir: {{ vhost.root_dir|default(none) }}
|
2020-07-10 00:58:55 +02:00
|
|
|
internal_access: {{ vhost.internal_access|default(false) }}
|
2022-04-18 21:24:56 +02:00
|
|
|
auth: {{ vhost.auth|default(false) }}
|
2020-07-10 00:58:55 +02:00
|
|
|
dirs: {{ vhost.dirs|default([]) }}
|
2022-07-16 00:48:12 +02:00
|
|
|
headers: {{ vhost.headers|default({}) }}
|
2020-09-02 21:31:18 +02:00
|
|
|
php_socket_file: {{ nginx.config.php_socket_file }}
|
2022-10-10 10:19:42 +02:00
|
|
|
geoip: {{ nginx.config.geoip }}
|
2020-07-10 00:58:55 +02:00
|
|
|
|
2023-01-04 23:33:04 +01:00
|
|
|
nginx-site-enabled-{{ name }}:
|
2020-07-10 00:58:55 +02:00
|
|
|
file.symlink:
|
2023-01-04 23:33:04 +01:00
|
|
|
- name: {{ nginx.config.dir }}/sites-enabled/{{ name }}
|
|
|
|
- target: {{ nginx.config.dir }}/sites-available/{{ name }}
|
2020-07-10 00:58:55 +02:00
|
|
|
- template: jinja
|
|
|
|
- user: {{ nginx.config.user }}
|
|
|
|
- group: {{ nginx.config.group }}
|
|
|
|
- require:
|
|
|
|
- file: nginx-config-dir-sites-available
|
|
|
|
- file: nginx-config-dir-sites-enabled
|
2023-01-04 23:33:04 +01:00
|
|
|
- nginx-sites-available-{{ name }}
|
2020-07-10 00:58:55 +02:00
|
|
|
- watch_in:
|
|
|
|
- service: nginx-service
|
2020-07-30 14:07:42 +02:00
|
|
|
{%- endfor %}
|