-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebserver.yaml
34 lines (31 loc) · 1.04 KB
/
webserver.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
- name: Apache webserver1 deployment
hosts: all
vars:
webpkg: httpd
webfile: "/var/www/html/index.html"
websvc: httpd
webconf: "/etc/httpd/conf/httpd.conf"
tasks:
# Installation of a Package
- name: Installing Apache packages
yum: name={{webpkg}} state=present
register: webpkgout
- name: Apache Installation Package outputs
debug: var=webpkgout
# Changing Default port 80 to 81
- name: Changing Listening port to 81
lineinfile: path={{webconf}} regexp="Listen 80" line="Listen 81"
ignore_errors: true
register: webconfout
notify:
- restart httpd
- name: Displaying webconf changes
debug: var=webconfout
# Configuring default Apache file
- name: Configuring Apache configuration files
copy: dest={{webfile}} content="<h1>Welcome to the world of DevOps in Action by Specturm!</h1>"
ignore_errors: true
handlers:
# Starting or Restarting Apache services whenever there is a change {{webconf}} file
- name: restart httpd
service: name={{websvc}} enabled=yes state=restarted