Skip to content

Commit 3ff14c7

Browse files
committed
changed ansible
1 parent 78e259a commit 3ff14c7

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

ansible/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
roles_path = ./roles
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
---
22
# defaults file for web
33
app_env: "dev"
4-
apt_php_version: "7.4"
5-
# ubuntu run nginx user
6-
php_owner: "nginx"
7-
php_group: "nginx"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
# handlers file for web
3-
- name: restart nginx
4-
service:
3+
- name: Restart nginx
4+
ansible.builtin.service:
55
name: nginx
66
state: restarted
77

8-
- name: restart php-fpm
9-
service:
10-
name: "php{{ apt_php_version }}-fpm"
8+
- name: Restart php-fpm
9+
ansible.builtin.service:
10+
name: "php{{ web_apt_php_version }}-fpm"
1111
state: restarted

ansible/roles/web/tasks/main.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
---
22
# tasks file for web
33
- name: Install required packages
4-
apt:
4+
ansible.builtin.apt:
55
name:
66
- nginx
7-
- "php{{ apt_php_version }}-fpm"
7+
- "php{{ web_apt_php_version }}-fpm"
88
state: present
99
update_cache: yes
1010

1111
- name: Deploy nginx config
12-
template:
12+
ansible.builtin.template:
1313
src: nginx.conf.j2
1414
dest: /etc/nginx/conf.d/website.conf
1515
owner: root
1616
group: root
1717
mode: 0644
1818
notify:
19-
- restart nginx
19+
- Restart nginx
2020

2121
- name: ensures /var/www/html dir exists
22-
file:
22+
ansible.builtin.file:
2323
path: "/var/www/html"
2424
state: directory
2525
owner: www-data
@@ -28,50 +28,50 @@
2828

2929
# setting the www.conf .
3030
- 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"
3333
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
3636

3737
- 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"
4040
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
4343

4444
- 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"
4747
regexp: '^;?listen.mode'
4848
line: 'listen.mode = 0660'
49-
notify: restart php-fpm
49+
notify: Restart php-fpm
5050

5151
- name: Deploy index.php
52-
copy:
52+
ansible.builtin.copy:
5353
src: index.php
5454
dest: /var/www/html/index.php
5555
owner: www-data
5656
group: www-data
5757
mode: 0644
5858
notify:
59-
- restart php-fpm
59+
- Restart php-fpm
6060

6161
- 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
6464
state: started
6565
enabled: yes
6666

6767
- name: Ensure nginx service is enabled and started
68-
service:
68+
ansible.builtin.service:
6969
name: nginx
7070
state: started
7171
enabled: yes
7272

7373
- name: Deploy logrotate config for nginx logs
74-
copy:
74+
ansible.builtin.copy:
7575
content: |
7676
/var/log/nginx/*log {
7777
daily
@@ -91,4 +91,4 @@
9191
group: root
9292
mode: 0644
9393
notify:
94-
- restart nginx
94+
- Restart nginx

ansible/roles/web/vars/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
---
22
# vars file for web
3+
web_apt_php_version: "7.4"
4+
# ubuntu run nginx user
5+
web_php_owner: "nginx"
6+
web_php_group: "nginx"

0 commit comments

Comments
 (0)