-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
51 lines (44 loc) · 1.28 KB
/
playbook.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
---
- name: install Apache Web Server
hosts: test
vars_files:
- vars/vars.yml
tasks:
- block: # block for Debian
- name: install Apache webserver for Debian
apt: name=apache2 state=latest
- name: Start Apache webserver for Debian
service: name=apache2 state=started enabled=yes
tags: install
when: ansible_os_family == "Debian"
- block: # block for RedHat
- name: install Apache webserver for RedHat
yum: name=httpd state=latest
- name: Start Apache webserver for RedHat
service: name=httpd state=started enabled=yes
tags: install
when: ansible_os_family == "RedHat"
- name: Create document root
file:
path: "var/www/html"
state: "directory"
owner: "{{ app_user }}"
mode: "0755"
- name: Copy index page
template:
src: "{{ source_file }}"
dest: "var/www/html"
notify: restart Apache
- name: Allow all access to tcp port 80
ufw:
rule: allow
port: "80"
proto: tcp
tags: firewall
handlers:
- name: Restart Apache Debian
service: name=apache2 state=restarted
when: ansible_os_family == "Debian"
- name: Restart Apache RedHat
service: name=apache2 state=restarted
when: ansible_os_family == "Debian"