-
Notifications
You must be signed in to change notification settings - Fork 9
/
check.yaml
65 lines (53 loc) · 1.88 KB
/
check.yaml
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
- name: Check
hosts: checkhosts
tasks:
- name: Basic rewrite syntax lint
ansible.builtin.assert:
that:
- not item.src.startswith('^')
- not item.src.endswith('/')
- item.src.startswith('/')
- item.dest.startswith('http')
- "' ' not in item.src"
- "' ' not in item.dest"
success_msg: "Rewrites pass basic syntax lint"
fail_msg: "Basic rewrite src must not start with '^' or end with '/', src must start with '/' and dest must start with 'http'"
loop: "{{ gxy_io_rewrites }}"
- name: Basic rewrite syntax lint
ansible.builtin.assert:
that:
- "' ' not in item.src"
- "' ' not in item.dest"
loop: "{{ gxy_io_raw_rewrites }}"
- name: Create nginx config tempfile
ansible.builtin.tempfile:
suffix: nginx.conf
register: __nginx_conf_tempfile
- name: Create gxy.io config tempfile
ansible.builtin.tempfile:
suffix: gxy.io
register: __gxy_io_tempfile
- name: Register gxy.io config path
ansible.builtin.set_fact:
__nginx_config_path: "{{ __nginx_conf_tempfile.path }}"
__gxy_io_config_path: "{{ __gxy_io_tempfile.path }}"
- block:
- name: Create nginx.conf
ansible.builtin.template:
src: nginx.conf.j2
dest: "{{ __nginx_config_path }}"
mode: "0644"
- name: Template gxy.io config
ansible.builtin.template:
src: gxy.io.j2
dest: "{{ __gxy_io_config_path }}"
- name: Check nginx config
ansible.builtin.command: nginx -c {{ __nginx_config_path }} -t
always:
- name: Remove tempfiles
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ __nginx_config_path }}"
- "{{ __gxy_io_config_path }}"