-
Notifications
You must be signed in to change notification settings - Fork 98
/
exercise82.yaml
53 lines (53 loc) · 1.45 KB
/
exercise82.yaml
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
---
- name: Managing web server SELinux properties
hosts: ansible1
tasks:
- name: ensure SELinux is enabled and enforcing
selinux:
policy: targeted
state: enforcing
- name: install the webserver
yum:
name: httpd
state: latest
- name: start and enable the webserver
service:
name: httpd
state: started
enabled: yes
- name: open the firewall service
firewalld:
service: http
immediate: yes
permanent: yes
state: enabled
- name: create the /web directory
file:
name: /web
state: directory
- name: create the index.html file in /web
copy:
content: 'welcome to the exercise82 web server'
dest: /web/index.html
- name: use lineinfile to change webserver configuration
lineinfile:
path: /etc/httpd/conf/httpd.conf
regexp: '^DocumentRoot "/var/www/html"'
line: DocumentRoot "/web"
- name: use lineinfile to change webserver security
lineinfile:
path: /etc/httpd/conf/httpd.conf
regexp: '^<Directory "/var/www">'
line: '<Directory "/web">'
- name: use sefcontext to set context on new documentroot
sefcontext:
target: '/web(/.*)?'
setype: httpd_sys_content_t
state: present
- name: run the restorecon command
command: restorecon -Rv /web
- name: allow the web server to run user content
seboolean:
name: httpd_read_user_content
state: yes
persistent: yes