-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmain.yml
44 lines (38 loc) · 970 Bytes
/
main.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
---
- name: Install Apache.
hosts: all
become: true
vars:
apache_package: apache2
apache_service: apache2
handlers:
- name: restart apache
service:
name: "{{ apache_service }}"
state: restarted
pre_tasks:
- name: Override Apache vars for Red Hat.
set_fact:
apache_package: httpd
apache_service: httpd
when: ansible_os_family == 'RedHat'
tasks:
- name: Ensure Apache is installed.
package:
name: "{{ apache_package }}"
state: present
- name: Copy a web page.
copy:
content: |
<html>
<head><title>Hello world!</title></head>
<body>Hello world!</body>
</html>
dest: "/var/www/html/index.html"
mode: '0644'
notify: restart apache
- name: Ensure Apache is running and starts at boot.
service:
name: "{{ apache_service }}"
state: started
enabled: true