|
3 | 3 | hosts: all
|
4 | 4 | tasks:
|
5 | 5 | - name: Check if NGINX is installed
|
6 |
| - package: |
| 6 | + ansible.builtin.package: |
7 | 7 | name: nginx
|
8 | 8 | state: present
|
9 | 9 | check_mode: true
|
10 | 10 | register: install
|
11 | 11 | failed_when: (install is changed) or (install is failed)
|
12 | 12 |
|
13 | 13 | - name: Check if NGINX service is running
|
14 |
| - service: |
| 14 | + ansible.builtin.service: |
15 | 15 | name: nginx
|
16 | 16 | state: started
|
17 | 17 | enabled: true
|
|
20 | 20 | failed_when: (service is changed) or (service is failed)
|
21 | 21 |
|
22 | 22 | - name: Check that a page returns a status 200 and fail if the words Hello World are not in the page contents
|
23 |
| - uri: |
| 23 | + ansible.builtin.uri: |
24 | 24 | url: http://localhost
|
25 | 25 | return_content: true
|
26 | 26 | register: this
|
27 | 27 | failed_when: "'Hello World' not in this.content"
|
28 | 28 |
|
29 | 29 | - name: Check client body cache directory exists
|
30 |
| - stat: |
| 30 | + ansible.builtin.stat: |
31 | 31 | path: /var/cache/nginx/client
|
32 | 32 | check_mode: true
|
33 | 33 | register: stat_result
|
34 | 34 | failed_when: not stat_result.stat.exists
|
35 | 35 |
|
36 | 36 | - name: Check proxy cache directory exists
|
37 |
| - stat: |
| 37 | + ansible.builtin.stat: |
38 | 38 | path: /var/cache/nginx/proxy
|
39 | 39 | check_mode: true
|
40 | 40 | register: stat_result
|
41 | 41 | failed_when: not stat_result.stat.exists
|
42 | 42 |
|
43 | 43 | - name: Check default.conf exists
|
44 |
| - stat: |
| 44 | + ansible.builtin.stat: |
45 | 45 | path: /etc/nginx/conf.d/default.conf
|
46 | 46 | check_mode: true
|
47 | 47 | register: stat_result
|
48 | 48 | failed_when: not stat_result.stat.exists
|
49 | 49 |
|
50 | 50 | - name: Check frontend_default.conf exists
|
51 |
| - stat: |
| 51 | + ansible.builtin.stat: |
52 | 52 | path: /etc/nginx/conf.d/frontend_default.conf
|
53 | 53 | check_mode: true
|
54 | 54 | register: stat_result
|
55 | 55 | failed_when: not stat_result.stat.exists
|
56 | 56 |
|
57 | 57 | - name: Check backend_default.conf exists
|
58 |
| - stat: |
| 58 | + ansible.builtin.stat: |
59 | 59 | path: /etc/nginx/conf.d/backend/backend_default.conf
|
60 | 60 | check_mode: true
|
61 | 61 | register: stat_result
|
62 | 62 | failed_when: not stat_result.stat.exists
|
63 | 63 |
|
64 | 64 | - name: Ensure default.conf contains 'location /'
|
65 |
| - lineinfile: |
| 65 | + ansible.builtin.lineinfile: |
66 | 66 | path: /etc/nginx/conf.d/default.conf
|
67 | 67 | line: " location / {"
|
68 | 68 | state: present
|
|
71 | 71 | failed_when: (conf is changed) or (conf is failed)
|
72 | 72 |
|
73 | 73 | - name: Ensure frontend_default.conf contains 'alias directive'
|
74 |
| - lineinfile: |
| 74 | + ansible.builtin.lineinfile: |
75 | 75 | path: /etc/nginx/conf.d/frontend_default.conf
|
76 | 76 | line: " alias /usr/share/nginx/html;"
|
77 | 77 | state: present
|
|
80 | 80 | failed_when: (conf is changed) or (conf is failed)
|
81 | 81 |
|
82 | 82 | - name: Ensure default.conf contains 'location /backend'
|
83 |
| - lineinfile: |
| 83 | + ansible.builtin.lineinfile: |
84 | 84 | path: /etc/nginx/conf.d/default.conf
|
85 | 85 | line: " location /backend {"
|
86 | 86 | state: present
|
|
89 | 89 | failed_when: (conf is changed) or (conf is failed)
|
90 | 90 |
|
91 | 91 | - name: Ensure default.conf contains 'client_max_body_size 1m;'
|
92 |
| - lineinfile: |
| 92 | + ansible.builtin.lineinfile: |
93 | 93 | path: /etc/nginx/conf.d/default.conf
|
94 | 94 | line: "client_max_body_size 1m;"
|
95 | 95 | state: present
|
|
98 | 98 | failed_when: (conf is changed) or (conf is failed)
|
99 | 99 |
|
100 | 100 | - name: Ensure default.conf contains 'rewrite (.*).html(.*) $1$2 last;'
|
101 |
| - lineinfile: |
| 101 | + ansible.builtin.lineinfile: |
102 | 102 | path: /etc/nginx/conf.d/default.conf
|
103 | 103 | line: " rewrite (.*).html(.*) $1$2 last;"
|
104 | 104 | state: present
|
|
0 commit comments