-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdjango.yml
More file actions
83 lines (70 loc) · 1.89 KB
/
Copy pathdjango.yml
File metadata and controls
83 lines (70 loc) · 1.89 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
- name: Configure Ubuntu server for web hosting
hosts: ldd
become: yes
tasks:
- name: Update APT cache
apt:
update_cache: yes
- name: Upgrade all packages on servers
apt:
upgrade: dist
force_apt_get: yes
- name: Install Apache web server
apt:
name: apache2
state: present
- name: Install PostgreSQL and libpq-dev
apt:
name:
- postgresql
- python3-psycopg2
- libpq-dev
state: present
- name: Install Python 3 and pip
apt:
name: python3-pip
state: present
- name: Install Django
pip:
name: Django
executable: pip3
- name: Install psycopg2-binary
pip:
name: psycopg2-binary
executable: pip3
- name: Copy requirements.txt from local machine to target host
copy:
src: /home/ka/ansible_tutorial/requirements.txt # Local path
dest: /home/ka/requirements.txt # Target host path
become: yes
- name: Install Python requirements from requirements.txt
pip:
requirements: /home/ka/requirements.txt
executable: pip3
- name: Create a virtual host configuration file for Django
template:
src: django.conf.j2 # Template file for Apache2 virtual host
dest: /etc/apache2/sites-available/django.conf
become: yes
- name: Enable the Django virtual host
command: a2ensite django.conf
become: yes
notify:
- Restart Apache
- name: Disable the default Apache2 site
command: a2dissite 000-default
become: yes
notify:
- Restart Apache
- name: Start Apache2 service
service:
name: apache2
state: started
notify:
- Restart Apache
handlers:
- name: Restart Apache
service:
name: apache2
state: restarted