Newer
Older

Riccardo Bucchi
committed
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
class iaas::profile::database-configure (
$mysql_cluster_servers,
$keystone_pwd,
$glance_pwd,
$nova_pwd,
$cinder_pwd,
$neutron_pwd,
$heat_pwd,
){
exec { 'drop anonymous users on specific host':
command => "mysql --defaults-extra-file=/root/.my.cnf -u root -e \"GRANT USAGE ON *.* TO \'\'@\'$::hostname\'; DROP USER \'\'@\'$::hostname\';\"",
path => [ '/bin', '/usr/bin' ],
} ->
exec { 'drop anonymous users on localhost':
command => "mysql --defaults-extra-file=/root/.my.cnf -u root -e \"GRANT USAGE ON *.* TO \'\'@\'localhost\'; DROP USER \'\'@\'localhost\';\"",
path => [ '/bin', '/usr/bin' ],
}
# DB CREATION
$databases = ['keystone', 'glance', 'nova', 'cinder', 'neutron', 'heat' ]
mysql_database { $databases:
ensure => 'present',
charset => 'utf8',
collate => 'utf8_general_ci',
}
# DB USER
$user_keystone = regsubst($mysql_cluster_servers, '^', 'keystone@')
$user_glance = regsubst($mysql_cluster_servers, '^', 'glance@')
$user_nova = regsubst($mysql_cluster_servers, '^', 'nova@')
$user_cinder = regsubst($mysql_cluster_servers, '^', 'cinder@')
$user_neutron = regsubst($mysql_cluster_servers, '^', 'neutron@')
$user_heat = regsubst($mysql_cluster_servers, '^', 'heat@')
mysql_user { $user_keystone:
ensure => 'present',
password_hash => mysql_password($keystone_pwd),
}
mysql_user { $user_glance:
ensure => 'present',
password_hash => mysql_password($glance_pwd),
}
mysql_user { $user_nova:
ensure => 'present',
password_hash => mysql_password($nova_pwd),
}
mysql_user { $user_cinder:
ensure => 'present',
password_hash => mysql_password($cinder_pwd),
}
mysql_user { $user_neutron:
ensure => 'present',
password_hash => mysql_password($neutron_pwd),
}
mysql_user { $user_heat:
ensure => 'present',
password_hash => mysql_password($heat_pwd),
}
# USER GRANT
# defining a new resource due to old puppet and mysql versions
# https://tickets.puppetlabs.com/browse/PUP-1263
define composableMySqlGrant() {
mysql_grant {$name:
ensure => 'present',
user => regsubst($name, '\/(.)*', ''),
table => regsubst($name, '(.)*\/', ''),
options => ['GRANT'],
privileges => ['ALL'],
}
}
$grant_keystone = regsubst($user_keystone, '$', '/keystone.*')
$grant_glance = regsubst($user_glance, '$', '/glance.*')
$grant_nova = regsubst($user_nova, '$', '/nova.*')
$grant_cinder = regsubst($user_cinder, '$', '/cinder.*')
$grant_neutron = regsubst($user_neutron, '$', '/neutron.*')
$grant_heat = regsubst($user_heat, '$', '/heat.*')
composableMySqlGrant{$grant_keystone: }
composableMySqlGrant{$grant_glance: }
composableMySqlGrant{$grant_nova: }
composableMySqlGrant{$grant_cinder: }
composableMySqlGrant{$grant_neutron: }
composableMySqlGrant{$grant_heat: }
}