-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigureWebServer.yml
104 lines (96 loc) · 3.09 KB
/
ConfigureWebServer.yml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
- name: Vulnerability Package Management
hosts: web_server
become: 'yes'
tasks:
- name: Configure Hostname
ansible.builtin.hostname:
name: ApacheWebServer
- name: Install Apache2
apt:
update_cache: 'yes'
name: apache2
- name: Create purpose.com.conf
file:
path: /etc/apache2/sites-available/purpose.com.conf
state: touch
- name: Create file in /etc/apache2/sites-available/ directory
copy:
dest: /etc/apache2/sites-available/purpose.com.conf
content: |
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName purpose.com
ServerAlias www.purpose.com
Documentroot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- name: Enable purpose.com.conf site
ansible.builtin.shell: sudo a2ensite purpose.com.conf
- name: Disable default Apache2 site
ansible.builtin.shell: sudo a2dissite 000-default.conf
- name: Reload Apache2 service
ansible.builtin.shell: systemctl reload apache2
- name: Create TEST repository
file:
path: /var/www/html/test-repo
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Insert Directory Block in Apache2.conf file
blockinfile:
path: /etc/apache2/apache2.conf
block: |
<Directory /var/www/html/test-repo>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/official-repo>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
insertafter: "</Directory>"
- name: Download test packages in test-repo
ansible.builtin.shell: |
cd /var/www/html/test-repo
apt download docker
apt download nginx
apt download apache2
apt download cowsay
apt download htop
- name: Install dpkg-dev service
apt:
update_cache: 'yes'
name: dpkg-dev
- name: Create Packages.gz file in /var/www/html/test-repo
ansible.builtin.shell: |
cd /var/www/html/test-repo
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
- name: create OFFICIAL Repository
file:
path: /var/www/html/official-repo
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Download packages that passed smoke test
ansible.builtin.shell: |
cd /var/www/html/official-repo
apt download {{ item }}
loop:
- docker
- nginx
- apache2
- cowsay
- htop
- name: Install dpkg-dev service
apt:
update_cache: 'yes'
name: dpkg-dev
- name: Create Packages.gz file in /var/www/html/official-repo
ansible.builtin.shell: |
cd /var/www/html/official-repo
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz