-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook-handler02-listen.yml
80 lines (70 loc) · 2.05 KB
/
playbook-handler02-listen.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
- name: Apache server installed
hosts: web
gather_facts: no
become: yes
tasks:
# the package module tries to select
# yum or apt or pkg5 (etc) automatically
# if any of these services need installed or
# updated, then they ALL get restarted
- name: latest Apache version installed
package:
name:
- apache2 ## <-- updated
- mariadb-server ## <-- updated
- mariadb-client ## <-- updated
state: latest
notify:
- restart_webservices ## <-- updated
- name: Apache enabled and running
service:
name: apache2
enabled: yes
state: started
# Copy index.html into the service
- name: copy index.html
copy:
src: ~/mycode/files/index.html
dest: /var/www/html/
# if dest is directory download every time
# but only replace if destination is different
# https://raw.githubusercontent.com/rzfeeser/
# alta3files/master/apache2.conf
- name: Download a copy of apache2.conf
get_url:
url: https://raw.githubusercontent.com/rzfeeser/alta3files/master/apache2.conf
dest: /etc/apache2/
notify:
- restart_apache # ONLY restart apache if this conf
# file needs updated
# ensure the MySQL service is up and running
- name: MySQL (MariaDB) is running
service:
name: mariadb
enabled: yes
state: started
# if this line needs added to my.cnf
# then ONLY the MySQL service needs restarted
- name: Modify SQL conf file to listen on all interfaces
lineinfile:
dest: /etc/mysql/my.cnf
regexp: "^bind-address"
line: "bind-address=0.0.0.0"
notify:
- restart_mysql
# This will ONLY run if the associated tasks run
# no matter how many times called these tasks
# will ONLY run once
handlers:
- name: restart_apache
service:
name: apache2
state: restarted
listen: restart_webservices
## this is new, restarts MySQL
- name: restart_mysql
service:
name: mariadb
state: restarted
listen: restart_webservices