blob: 42700db659e4eca278f146d06ecfad160a995576 (
plain) (
blame)
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
|
---
- name: install nginx
apt:
name: "{{ nginx_pkg_name }}"
state: present
- name: remove nginx default config
file:
name: /etc/nginx/sites-enabled/default
state: absent
notify: restart nginx
- name: install nginx config snippets
loop:
- ssl
- hsts
copy:
src: "{{ global_files_dir }}/common/nginx-snippets/{{ item }}.conf"
dest: /etc/nginx/snippets/
notify: restart nginx
- name: generate Diffie-Hellman parameters
openssl_dhparam:
path: /etc/ssl/dhparams.pem
size: 2048
notify: restart nginx
- name: install nginx configs from template
loop: "{{ nginx_vhosts | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: "'template' in item.value"
template:
src: "{{ item.value.template }}.conf.j2"
dest: "/etc/nginx/sites-available/{{ item.key }}"
notify: restart nginx
- name: install nginx configs from config data
loop: "{{ nginx_vhosts | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: "'content' in item.value"
copy:
content: "{{ item.value.content }}"
dest: "/etc/nginx/sites-available/{{ item.key }}"
notify: restart nginx
- name: enable vhost config
loop: "{{ nginx_vhosts | dict2items }}"
loop_control:
label: "{{ item.key }}"
file:
src: "../sites-available/{{ item.key }}"
dest: "/etc/nginx/sites-enabled/{{ item.key }}"
state: link
notify: restart nginx
- name: generate acme certificate
loop: "{{ nginx_vhosts | dict2items }}"
loop_control:
label: "{{ item.key }} ({{ item.value.hostnames | default([]) | join(', ') }})"
when: "'acme' in item.value and item.value.acme"
include_tasks: acme.yml
|