|
1 | 1 | --- |
2 | 2 | # tasks file for web |
3 | 3 | - name: Install required packages |
4 | | - apt: |
| 4 | + ansible.builtin.apt: |
5 | 5 | name: |
6 | 6 | - nginx |
7 | | - - "php{{ apt_php_version }}-fpm" |
| 7 | + - "php{{ web_apt_php_version }}-fpm" |
8 | 8 | state: present |
9 | 9 | update_cache: yes |
10 | 10 |
|
11 | 11 | - name: Deploy nginx config |
12 | | - template: |
| 12 | + ansible.builtin.template: |
13 | 13 | src: nginx.conf.j2 |
14 | 14 | dest: /etc/nginx/conf.d/website.conf |
15 | 15 | owner: root |
16 | 16 | group: root |
17 | 17 | mode: 0644 |
18 | 18 | notify: |
19 | | - - restart nginx |
| 19 | + - Restart nginx |
20 | 20 |
|
21 | 21 | - name: ensures /var/www/html dir exists |
22 | | - file: |
| 22 | + ansible.builtin.file: |
23 | 23 | path: "/var/www/html" |
24 | 24 | state: directory |
25 | 25 | owner: www-data |
|
28 | 28 |
|
29 | 29 | # setting the www.conf . |
30 | 30 | - name: Set permissions on socket - owner |
31 | | - lineinfile: |
32 | | - dest: "/etc/php/{{ apt_php_version }}/fpm/pool.d/www.conf" |
| 31 | + ansible.builtin.lineinfile: |
| 32 | + dest: "/etc/php/{{ web_apt_php_version }}/fpm/pool.d/www.conf" |
33 | 33 | regexp: '^;?listen.owner' |
34 | | - line: "listen.owner = {{ php_owner }}" |
35 | | - notify: restart php-fpm |
| 34 | + line: "listen.owner = {{ web_php_owner }}" |
| 35 | + notify: Restart php-fpm |
36 | 36 |
|
37 | 37 | - name: Set permissions on socket - group |
38 | | - lineinfile: |
39 | | - dest: "/etc/php/{{ apt_php_version }}/fpm/pool.d/www.conf" |
| 38 | + ansible.builtin.lineinfile: |
| 39 | + dest: "/etc/php/{{ web_apt_php_version }}/fpm/pool.d/www.conf" |
40 | 40 | regexp: '^;?listen.group' |
41 | | - line: 'listen.group = {{ php_group }}' |
42 | | - notify: restart php-fpm |
| 41 | + line: 'listen.group = {{ web_php_group }}' |
| 42 | + notify: Restart php-fpm |
43 | 43 |
|
44 | 44 | - name: Set permissions on socket - mode |
45 | | - lineinfile: |
46 | | - dest: "/etc/php/{{ apt_php_version }}/fpm/pool.d/www.conf" |
| 45 | + ansible.builtin.lineinfile: |
| 46 | + dest: "/etc/php/{{ web_apt_php_version }}/fpm/pool.d/www.conf" |
47 | 47 | regexp: '^;?listen.mode' |
48 | 48 | line: 'listen.mode = 0660' |
49 | | - notify: restart php-fpm |
| 49 | + notify: Restart php-fpm |
50 | 50 |
|
51 | 51 | - name: Deploy index.php |
52 | | - copy: |
| 52 | + ansible.builtin.copy: |
53 | 53 | src: index.php |
54 | 54 | dest: /var/www/html/index.php |
55 | 55 | owner: www-data |
56 | 56 | group: www-data |
57 | 57 | mode: 0644 |
58 | 58 | notify: |
59 | | - - restart php-fpm |
| 59 | + - Restart php-fpm |
60 | 60 |
|
61 | 61 | - name: Ensure php-fpm service is enabled and started |
62 | | - service: |
63 | | - name: php{{ apt_php_version }}-fpm |
| 62 | + ansible.builtin.service: |
| 63 | + name: php{{ web_apt_php_version }}-fpm |
64 | 64 | state: started |
65 | 65 | enabled: yes |
66 | 66 |
|
67 | 67 | - name: Ensure nginx service is enabled and started |
68 | | - service: |
| 68 | + ansible.builtin.service: |
69 | 69 | name: nginx |
70 | 70 | state: started |
71 | 71 | enabled: yes |
72 | 72 |
|
73 | 73 | - name: Deploy logrotate config for nginx logs |
74 | | - copy: |
| 74 | + ansible.builtin.copy: |
75 | 75 | content: | |
76 | 76 | /var/log/nginx/*log { |
77 | 77 | daily |
|
91 | 91 | group: root |
92 | 92 | mode: 0644 |
93 | 93 | notify: |
94 | | - - restart nginx |
| 94 | + - Restart nginx |
0 commit comments