-
Notifications
You must be signed in to change notification settings - Fork 17
/
mysql.yml
81 lines (74 loc) · 2.16 KB
/
mysql.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
80
81
#!/usr/bin/env ansible-playbook
##############################################################
# Author: Gholamreza Sabery Tabrizy
# Email: reza_sabery_89@yahoo.com
# Project Repository: https://github.com/ghrst/Kamailio-HA
##############################################################
- name: This play installs and configures MySQL Server for Kamailio.
hosts: mysql
become: False
vars_files:
- settings.yml
tasks:
- name: Installing mysql-server
apt:
update_cache: yes
name:
- mysql-server
- python-mysqldb
- name: Update mysql root password
mysql_user:
name: root
host: "{{ item }}"
password: "{{mySqlRootPass}}"
login_user: root
login_password: "{{mySqlRootPass}}"
check_implicit_admin: yes
priv: "*.*:ALL,GRANT"
with_items:
- "{{ ansible_hostname }}"
- 127.0.0.1
- ::1
- "{{kam1IP}}"
- "{{kam2IP}}"
- "{{mySqlHost}}"
- localhost
- name: Adding Kamailio's database user
mysql_user:
name: "{{mySqlKamailioUser}}"
host: "{{item}}"
priv: "kamailio.*:ALL,GRANT"
password: "{{mySqlKamailioPass}}"
login_user: root
login_password: "{{mySqlRootPass}}"
with_items:
- 127.0.0.1
- "{{kamailioPublicIP}}"
- "{{kam1IP}}"
- "{{kam2IP}}"
- localhost
- name: Adding RTPProxy database user
mysql_user:
name: "{{rtpProxyMySQLUser}}"
host: "{{item}}"
priv: "rtpproxy.*:ALL,GRANT"
password: "{{rtpProxyMySQLPass}}"
login_user: root
login_password: "{{mySqlRootPass}}"
with_items:
- 127.0.0.1
- "{{kamailioPublicIP}}"
- "{{kam1IP}}"
- "{{kam2IP}}"
- localhost
- name: Ensure MySQL will listen to mySqlBindIP
lineinfile:
dest: /etc/mysql/my.cnf
regexp: 'bind-address\s*=\s*127\.0\.0\.1\s*'
line: 'bind-address = {{mySqlBindIP}}'
state: present
backrefs: yes
- name: Restarting MySQL
service:
name: mysql
state: restarted