forked from ravi2krishna/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
24-apache-when-or.yml
64 lines (56 loc) · 1.69 KB
/
24-apache-when-or.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
- hosts: all
become: yes
vars:
username: ravi
category: webservers
doc_root: /var/www/html
tasks:
# Update Apt Manager
- name: Update Package Manager
apt:
update_cache: yes
when: ansible_os_family == "Debian" and ansible_distribution_version == "18.04"
# Only run this task on Rehdat Family
- name: Install Apache Package
package:
name: httpd
state: present
when: ansible_os_family == "RedHat"
# Only run this task on Rehdat Family
- name: Start Apache Service
service:
name: httpd
state: started
enabled: yes
when: ansible_os_family == "RedHat"
# Only run this task on Debian Family
- name: Install Apache Package
package:
name: apache2
state: present
when: ansible_os_family == "Debian"
# Only run this task on Debian Family
- name: Start Apache Service
service:
name: apache2
state: started
enabled: yes
when: ansible_os_family == "Debian"
# Should Execute Only on Ubuntu 16
- name: With Template Module
template:
src: /home/centos/ansible/old.j2
dest: "{{ doc_root }}/old.html"
when: ansible_os_family == "Debian" and ansible_distribution_version == "16.04"
# Should Execute Only on Ubuntu 18
- name: With Template Module
template:
src: /home/centos/ansible/new.j2
dest: "{{ doc_root }}/new.html"
when: ansible_os_family == "Debian" and ansible_distribution_version == "18.04"
# Should Execute Either On CentOS or Ubuntu
- name: With Template Module
template:
src: /home/centos/ansible/info.j2
dest: "{{ doc_root }}/info.html"
when: ansible_os_family == "Debian" or ansible_os_family == "RedHat"