-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebserver.yaml
78 lines (69 loc) · 2.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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
- name: Setup and enable webservers on all hosts
hosts: all
become: true
gather_facts: true
tasks:
- name: Install the latest version of Apache for RHEL/CentOS
ansible.builtin.yum:
name: httpd
state: latest
when:
- ansible_facts['os_family'] == "RedHat"
- name: Install the latest version of Apache for Ubuntu
ansible.builtin.apt:
name: apache2
state: latest
update_cache: yes
cache_valid_time: 3600
when:
- ansible_facts['os_family'] == "Debian"
- name: Start service httpd, if not started for RHEL/CentOS
ansible.builtin.service:
name: httpd
state: started
when:
- ansible_facts['os_family'] == "RedHat"
- name: Start service apache2, if not started for Ubuntu
ansible.builtin.service:
name: apache2
enabled: true
state: started
when:
- ansible_facts['os_family'] == "Debian"
- name: Enable service httpd for RHEL/CentOS
ansible.builtin.service:
name: httpd
enabled: true
state: started
when:
- ansible_facts['os_family'] == "RedHat"
- name: Enable service apache2 for Ubuntu
ansible.builtin.service:
name: apache2
enabled: true
state: started
when:
- ansible_facts['os_family'] == "Debian"
- name: Enable service firewalld for RHEL
ansible.builtin.service:
name: firewalld
enabled: true
state: started
when:
- ansible_facts['os_family'] == "RedHat"
- name: permit traffic in default zone for http service
ansible.posix.firewalld:
service: http
permanent: true
immediate: true
state: enabled
when:
- ansible_facts['os_family'] == "RedHat"
- name: permit traffic in default zone for https service
ansible.posix.firewalld:
service: https
permanent: true
immediate: true
state: enabled
when:
- ansible_facts['os_family'] == "RedHat"