blob: df1ea009bf30f7fce399fd1fecfbfb692c84f710 (
plain)
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
|
mysql-server:
pkg.installed
# On Ubuntu, the default MySQL install only listens on localhost
/etc/mysql/my.cnf:
{% if grains['os'] == 'Ubuntu' %}
file.sed:
- before: 127.0.0.1
- after: 0.0.0.0
- limit: ^bind-address\s+=
- require:
- pkg: mysql-server
{% else %}
file.exists
{% endif %}
mysql_daemon:
service:
{% if grains['os'] == 'CentOS' %}
- name: mysqld
{% elif grains['os'] == 'Ubuntu' or grains['os'] == 'Debian' %}
- name: mysql
{% endif %}
- running
- enable: True
- watch:
- file: /etc/mysql/my.cnf
- require:
- pkg: mysql-server
## FW rules don't work well with CentOS < 7
# Insert is run each time
#
# iptables.insert:
# - position: 1
# - table: filter
# - chain: INPUT
# - j: ACCEPT # Use 'j' instead of 'jump' because iptables-save outputs 'j' flag.
# - match: state
# - connstate: NEW
# - dport: 3306
# - proto: tcp
# - save: True
# Copy DB schema file
/salt/mysql/schema.sql:
file.managed:
- source: salt://mysql/schema.sql
- makedirs: true
# Copy DB setup script
/salt/mysql/setup.sql:
file.managed:
- source: salt://mysql/setup.sql
- makedirs: true
# Create DB
echo "CREATE DATABASE radius" | mysql:
cmd.run:
- creates: /var/lib/mysql/radius/db.opt
# Create FreeRADIUS schema
mysql radius < /salt/mysql/schema.sql:
cmd.run:
- unless: "echo 'desc radacct' | mysql radius"
- require:
- file: /salt/mysql/schema.sql
# Setup DB access
mysql radius < /salt/mysql/setup.sql:
cmd.run:
- unless: "echo \"show grants for 'radius';\" | mysql"
- require:
- file: /salt/mysql/setup.sql
|