-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sls
125 lines (104 loc) · 2.87 KB
/
init.sls
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{% set admin_password = pillar['mysql_config']['admin_password'] %}
{% set haproxy_ip = pillar['mysql_config']['haproxy_ip'] %}
# MariaDB Repo
mariadb-repo:
pkgrepo.managed:
- comments:
- '# MariaDB 10.1 Debian repository list - managed by salt {{ grains['saltversion'] }}'
- name: deb [arch=i386,amd64] http://mirror.one.com/mariadb/repo/10.1/debian jessie main
- dist: jessie
- file: /etc/apt/sources.list.d/mariadb.list
- key_url: salt://galera-cluster/files/repo.mariadb.ubuntu.com.key
- require_in:
- pkg: mariadb-pkgs
# Favor the MariaDB repo over the Debian one
/etc/apt/preferences.d/MariaDB.pref:
file.managed:
- source: salt://galera-cluster/files/MariaDB.pref
- group: root
- mode: 644
- template: jinja
# need to get the mariadb repos version of mysql-common
mysql-common:
pkg.latest:
- only_upgrade: True
libmysqlclient18:
pkg:
- installed
rsync:
pkg.installed
python-mysqldb:
pkg.installed
apt_update:
cmd.run:
- name: apt-get update
- require:
- pkgrepo: mariadb-repo
# Pre-seed MariaDB install prompts
mariadb-debconf:
debconf.set:
- name: mariadb-galera-server
- data:
'mysql-server/root_password': {'type':'string','value':{{ admin_password }}}
'mysql-server/root_password_again': {'type':'string','value':{{ admin_password }}}
- require:
- pkg: debconf-utils
- file: /etc/apt/preferences.d/MariaDB.pref
mariadb-pkgs:
pkg.installed:
- names:
- mariadb-server-10.1
- require:
- pkgrepo: mariadb-repo
- debconf: mariadb-debconf
- cmd: apt_update
{% for cfgfile, info in pillar['cfg_files'].iteritems() %}
{{ info['path'] }}:
file.managed:
- source: {{ info['source'] }}
- group: root
- mode: 644
- template: jinja
- require:
- pkg: mariadb-pkgs
{% endfor %}
ensure_running:
service:
- name: mysql
- running
- require:
- pkg: mariadb-pkgs
mysql_update_maint:
cmd.run:
- name: mysql -u root -p{{ admin_password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ pillar['mysql_config']['maintenance_password'] }}';"
- require:
- pkg: mariadb-pkgs
- service: ensure_running
mysql_update_haproxy:
cmd.run:
- name: mysql -u root -p{{ admin_password }} mysql -e "INSERT INTO user (Host,User) values ('{{ haproxy_ip }}','haproxy');" || echo true
- require:
- pkg: mariadb-pkgs
- service: ensure_running
socat:
pkg.installed
netcat:
pkg.installed
python-software-properties:
pkg:
- installed
debconf-utils:
pkg:
- installed
debconf:
pkg:
- installed
/root/galera_status.sh:
file.managed:
- mode: 750
- source: salt://galera-cluster/files/galera_status.sh
/root/.my.cnf:
file.managed:
- mode: 700
- source: salt://galera-cluster/files/root-my.cnf
- template: jinja