-
Notifications
You must be signed in to change notification settings - Fork 5
/
24-apache-conditional-2.yml
50 lines (43 loc) · 1.04 KB
/
24-apache-conditional-2.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
# yum and service modules with sudo access
---
- hosts: web
become: yes
vars:
username: ravi
doc_root: /var/www/html
tasks:
# This task will update apt-get repo
- name: Update apt-get repo
apt:
upgrade: yes
update_cache: yes
when: ansible_os_family == "Debian"
# This task will install apache http server
- name: Install apache2
package:
name: apache2
state: present
when: ansible_os_family == "Debian"
- name: Install httpd
package:
name: httpd
state: present
when: ansible_os_family == "RedHat"
# This task will start apache http server
- name: Start httpd
service:
name: httpd
state: started
enabled: yes
when: ansible_os_family == "RedHat"
- name: Start apache2
service:
name: apache2
state: started
enabled: yes
when: ansible_os_family == "Debian"
# This will copy site file
- name: Copy index template from templates
template:
src: 24/templates/index.j2
dest: "{{ doc_root }}/index.html"