freighthop 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Puppetfile +1 -0
- data/Puppetfile.lock +3 -0
- data/Vagrantfile +1 -1
- data/bin/fh +2 -78
- data/lib/freighthop/cli/help.rb +69 -0
- data/lib/freighthop/cli/ssh.rb +46 -0
- data/lib/freighthop/cli/vagrant.rb +26 -0
- data/lib/freighthop/cli.rb +40 -0
- data/lib/freighthop/config.rb +4 -0
- data/lib/freighthop/vagrant_env.rb +24 -0
- data/lib/freighthop/version.rb +1 -1
- data/lib/freighthop.rb +7 -4
- data/local_modules/freighthop/manifests/database/mysql.pp +20 -0
- data/local_modules/freighthop/manifests/database/postgres.pp +6 -6
- data/local_modules/freighthop/manifests/database.pp +6 -8
- data/local_modules/freighthop/manifests/init.pp +1 -8
- data/local_modules/freighthop/manifests/params.pp +0 -3
- data/modules/apt/CHANGELOG +12 -2
- data/modules/apt/Gemfile +6 -5
- data/modules/apt/Gemfile.lock +40 -5
- data/modules/apt/Modulefile +1 -1
- data/modules/apt/README.md +2 -1
- data/modules/apt/Rakefile +1 -0
- data/modules/apt/manifests/init.pp +4 -1
- data/modules/apt/manifests/ppa.pp +1 -1
- data/modules/apt/manifests/update.pp +1 -0
- data/modules/apt/metadata.json +21 -13
- data/modules/apt/spec/defines/ppa_spec.rb +3 -3
- data/modules/apt/spec/defines/source_spec.rb +2 -2
- data/modules/apt/spec/spec_helper_system.rb +30 -0
- data/modules/apt/spec/system/apt_builddep_spec.rb +38 -0
- data/modules/apt/spec/system/apt_key_spec.rb +53 -0
- data/modules/apt/spec/system/apt_ppa_spec.rb +59 -0
- data/modules/apt/spec/system/apt_source_spec.rb +51 -0
- data/modules/apt/spec/system/basic_spec.rb +10 -0
- data/modules/apt/spec/system/class_spec.rb +20 -0
- data/modules/apt/templates/source.list.erb +2 -2
- data/modules/freighthop/manifests/database/mysql.pp +20 -0
- data/modules/freighthop/manifests/database/postgres.pp +6 -6
- data/modules/freighthop/manifests/database.pp +6 -8
- data/modules/freighthop/manifests/init.pp +1 -8
- data/modules/freighthop/manifests/params.pp +0 -3
- data/modules/mysql/CHANGELOG +403 -0
- data/modules/mysql/Gemfile +24 -0
- data/modules/mysql/Gemfile.lock +129 -0
- data/modules/mysql/LICENSE +201 -0
- data/modules/mysql/Modulefile +9 -0
- data/modules/mysql/README.md +492 -0
- data/modules/mysql/Rakefile +2 -0
- data/modules/mysql/TODO +8 -0
- data/modules/mysql/files/mysqltuner.pl +966 -0
- data/modules/mysql/lib/puppet/parser/functions/mysql_deepmerge.rb +52 -0
- data/modules/mysql/lib/puppet/parser/functions/mysql_password.rb +15 -0
- data/modules/mysql/lib/puppet/parser/functions/mysql_strip_hash.rb +21 -0
- data/modules/mysql/lib/puppet/provider/database/mysql.rb +52 -0
- data/modules/mysql/lib/puppet/provider/database_grant/mysql.rb +210 -0
- data/modules/mysql/lib/puppet/provider/database_user/mysql.rb +76 -0
- data/modules/mysql/lib/puppet/provider/mysql.rb +67 -0
- data/modules/mysql/lib/puppet/provider/mysql_database/mysql.rb +68 -0
- data/modules/mysql/lib/puppet/provider/mysql_grant/mysql.rb +115 -0
- data/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb +115 -0
- data/modules/mysql/lib/puppet/type/database.rb +21 -0
- data/modules/mysql/lib/puppet/type/database_grant.rb +79 -0
- data/modules/mysql/lib/puppet/type/database_user.rb +31 -0
- data/modules/mysql/lib/puppet/type/mysql_database.rb +22 -0
- data/modules/mysql/lib/puppet/type/mysql_grant.rb +72 -0
- data/modules/mysql/lib/puppet/type/mysql_user.rb +45 -0
- data/modules/mysql/manifests/backup.pp +31 -0
- data/modules/mysql/manifests/bindings/java.pp +10 -0
- data/modules/mysql/manifests/bindings/perl.pp +10 -0
- data/modules/mysql/manifests/bindings/php.pp +10 -0
- data/modules/mysql/manifests/bindings/python.pp +10 -0
- data/modules/mysql/manifests/bindings/ruby.pp +10 -0
- data/modules/mysql/manifests/bindings.pp +33 -0
- data/modules/mysql/manifests/client/install.pp +8 -0
- data/modules/mysql/manifests/client.pp +27 -0
- data/modules/mysql/manifests/db.pp +59 -0
- data/modules/mysql/manifests/init.pp +100 -0
- data/modules/mysql/manifests/params.pp +230 -0
- data/modules/mysql/manifests/server/account_security.pp +22 -0
- data/modules/mysql/manifests/server/backup.pp +56 -0
- data/modules/mysql/manifests/server/config.pp +31 -0
- data/modules/mysql/manifests/server/install.pp +9 -0
- data/modules/mysql/manifests/server/monitor.pp +24 -0
- data/modules/mysql/manifests/server/mysqltuner.pp +9 -0
- data/modules/mysql/manifests/server/providers.pp +8 -0
- data/modules/mysql/manifests/server/root_password.pp +21 -0
- data/modules/mysql/manifests/server/service.pp +19 -0
- data/modules/mysql/manifests/server.pp +69 -0
- data/modules/mysql/metadata.json +289 -0
- data/modules/mysql/spec/classes/mysql_bindings_spec.rb +58 -0
- data/modules/mysql/spec/classes/mysql_client_spec.rb +16 -0
- data/modules/mysql/spec/classes/mysql_server_account_security_spec.rb +41 -0
- data/modules/mysql/spec/classes/mysql_server_backup_spec.rb +112 -0
- data/modules/mysql/spec/classes/mysql_server_monitor_spec.rb +31 -0
- data/modules/mysql/spec/classes/mysql_server_mysqltuner_spec.rb +5 -0
- data/modules/mysql/spec/classes/mysql_server_spec.rb +162 -0
- data/modules/mysql/spec/defines/mysql_db_spec.rb +51 -0
- data/modules/mysql/spec/spec.opts +6 -0
- data/modules/mysql/spec/spec_helper.rb +5 -0
- data/modules/mysql/spec/spec_helper_system.rb +28 -0
- data/modules/mysql/spec/system/mysql_account_delete_spec.rb +35 -0
- data/modules/mysql/spec/system/mysql_backup_spec.rb +77 -0
- data/modules/mysql/spec/system/mysql_bindings_spec.rb +90 -0
- data/modules/mysql/spec/system/mysql_db_spec.rb +61 -0
- data/modules/mysql/spec/system/mysql_server_monitor_spec.rb +30 -0
- data/modules/mysql/spec/system/mysql_server_root_password_spec.rb +71 -0
- data/modules/mysql/spec/system/mysql_server_spec.rb +85 -0
- data/modules/mysql/spec/system/types/mysql_grant_spec.rb +314 -0
- data/modules/mysql/spec/system/types/mysql_user_spec.rb +35 -0
- data/modules/mysql/spec/unit/mysql_password_spec.rb +27 -0
- data/modules/mysql/spec/unit/puppet/functions/mysql_deepmerge_spec.rb +77 -0
- data/modules/mysql/spec/unit/puppet/provider/database/mysql_spec.rb +86 -0
- data/modules/mysql/spec/unit/puppet/provider/database_grant/mysql_spec.rb +95 -0
- data/modules/mysql/spec/unit/puppet/provider/database_user/mysql_spec.rb +119 -0
- data/modules/mysql/spec/unit/puppet/provider/mysql_database/mysql_spec.rb +118 -0
- data/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb +130 -0
- data/modules/mysql/spec/unit/puppet/type/mysql_database_spec.rb +29 -0
- data/modules/mysql/spec/unit/puppet/type/mysql_user_spec.rb +30 -0
- data/modules/mysql/templates/my.cnf.erb +17 -0
- data/modules/mysql/templates/my.cnf.pass.erb +7 -0
- data/modules/mysql/templates/my.conf.cnf.erb +17 -0
- data/modules/mysql/templates/mysqlbackup.sh.erb +57 -0
- data/modules/mysql/tests/backup.pp +8 -0
- data/modules/mysql/tests/bindings.pp +3 -0
- data/modules/mysql/tests/init.pp +1 -0
- data/modules/mysql/tests/java.pp +1 -0
- data/modules/mysql/tests/mysql_database.pp +12 -0
- data/modules/mysql/tests/mysql_grant.pp +5 -0
- data/modules/mysql/tests/mysql_user.pp +23 -0
- data/modules/mysql/tests/perl.pp +1 -0
- data/modules/mysql/tests/python.pp +1 -0
- data/modules/mysql/tests/ruby.pp +1 -0
- data/modules/mysql/tests/server/account_security.pp +4 -0
- data/modules/mysql/tests/server/config.pp +11 -0
- data/modules/mysql/tests/server.pp +3 -0
- data/modules/postgresql/Changelog +191 -0
- data/modules/postgresql/Gemfile +1 -0
- data/modules/postgresql/Gemfile.lock +9 -0
- data/modules/postgresql/LICENSE +198 -12
- data/modules/postgresql/Modulefile +2 -2
- data/modules/postgresql/NOTICE +14 -0
- data/modules/postgresql/README.md +435 -184
- data/modules/postgresql/files/validate_postgresql_connection.sh +31 -0
- data/modules/postgresql/lib/puppet/provider/postgresql_conf/parsed.rb +37 -0
- data/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb +4 -0
- data/modules/postgresql/lib/puppet/type/postgresql_conf.rb +31 -0
- data/modules/postgresql/lib/puppet/type/postgresql_psql.rb +4 -0
- data/modules/postgresql/manifests/client.pp +17 -16
- data/modules/postgresql/manifests/globals.pp +95 -0
- data/modules/postgresql/manifests/lib/devel.pp +15 -0
- data/modules/postgresql/manifests/lib/java.pp +15 -0
- data/modules/postgresql/manifests/lib/python.pp +13 -0
- data/modules/postgresql/manifests/params.pp +127 -222
- data/modules/postgresql/manifests/repo/apt_postgresql_org.pp +30 -0
- data/modules/postgresql/manifests/repo/yum_postgresql_org.pp +38 -0
- data/modules/postgresql/manifests/repo.pp +22 -0
- data/modules/postgresql/manifests/server/config.pp +113 -0
- data/modules/postgresql/manifests/server/config_entry.pp +43 -0
- data/modules/postgresql/manifests/server/contrib.pp +27 -0
- data/modules/postgresql/manifests/server/database.pp +75 -0
- data/modules/postgresql/manifests/server/database_grant.pp +18 -0
- data/modules/postgresql/manifests/server/db.pp +36 -0
- data/modules/postgresql/manifests/server/firewall.pp +21 -0
- data/modules/postgresql/manifests/server/grant.pp +81 -0
- data/modules/postgresql/manifests/server/initdb.pp +52 -0
- data/modules/postgresql/manifests/server/install.pp +49 -0
- data/modules/postgresql/manifests/server/passwd.pp +34 -0
- data/modules/postgresql/manifests/server/pg_hba_rule.pp +54 -0
- data/modules/postgresql/manifests/server/plperl.pp +27 -0
- data/modules/postgresql/manifests/server/reload.pp +15 -0
- data/modules/postgresql/manifests/{role.pp → server/role.pp} +19 -33
- data/modules/postgresql/manifests/server/service.pp +40 -0
- data/modules/postgresql/manifests/{table_grant.pp → server/table_grant.pp} +4 -4
- data/modules/postgresql/manifests/server/tablespace.pp +42 -0
- data/modules/postgresql/manifests/server.pp +61 -83
- data/modules/postgresql/manifests/validate_db_connection.pp +49 -50
- data/modules/postgresql/metadata.json +123 -73
- data/modules/postgresql/spec/spec_helper_system.rb +13 -1
- data/modules/postgresql/spec/system/client_spec.rb +22 -0
- data/modules/postgresql/spec/system/common_patterns_spec.rb +53 -0
- data/modules/postgresql/spec/system/contrib_spec.rb +33 -0
- data/modules/postgresql/spec/system/lib/devel_spec.rb +22 -0
- data/modules/postgresql/spec/system/lib/java_spec.rb +25 -0
- data/modules/postgresql/spec/system/lib/python_spec.rb +24 -0
- data/modules/postgresql/spec/system/postgresql_psql_spec.rb +51 -0
- data/modules/postgresql/spec/system/server/config_entry_spec.rb +32 -0
- data/modules/postgresql/spec/system/server/database_grant_spec.rb +54 -0
- data/modules/postgresql/spec/system/server/database_spec.rb +35 -0
- data/modules/postgresql/spec/system/server/db_spec.rb +143 -0
- data/modules/postgresql/spec/system/server/grant_spec.rb +55 -0
- data/modules/postgresql/spec/system/server/pg_hba_rule_spec.rb +85 -0
- data/modules/postgresql/spec/system/server/plperl_spec.rb +29 -0
- data/modules/postgresql/spec/system/server/role_spec.rb +103 -0
- data/modules/postgresql/spec/system/server/table_grant_spec.rb +72 -0
- data/modules/postgresql/spec/system/server/tablespace_spec.rb +74 -0
- data/modules/postgresql/spec/system/server_spec.rb +217 -0
- data/modules/postgresql/spec/system/validate_db_connection_spec.rb +91 -0
- data/modules/postgresql/spec/unit/classes/client_spec.rb +27 -2
- data/modules/postgresql/spec/unit/classes/globals_spec.rb +28 -0
- data/modules/postgresql/spec/unit/classes/lib/devel_spec.rb +12 -0
- data/modules/postgresql/spec/unit/classes/{postgresql_java_spec.rb → lib/java_spec.rb} +9 -19
- data/modules/postgresql/spec/unit/classes/lib/python_spec.rb +31 -0
- data/modules/postgresql/spec/unit/classes/params_spec.rb +2 -1
- data/modules/postgresql/spec/unit/classes/repo_spec.rb +17 -0
- data/modules/postgresql/spec/unit/classes/server/contrib_spec.rb +42 -0
- data/modules/postgresql/spec/unit/classes/server/initdb_spec.rb +28 -0
- data/modules/postgresql/spec/unit/classes/server/plperl_spec.rb +45 -0
- data/modules/postgresql/spec/unit/classes/server_spec.rb +83 -2
- data/modules/postgresql/spec/unit/defines/server/config_entry_spec.rb +23 -0
- data/modules/postgresql/spec/unit/defines/server/database_grant_spec.rb +26 -0
- data/modules/postgresql/spec/unit/defines/server/database_spec.rb +16 -0
- data/modules/postgresql/spec/unit/defines/server/db_spec.rb +28 -0
- data/modules/postgresql/spec/unit/defines/{database_grant_spec.rb → server/grant_spec.rb} +7 -4
- data/modules/postgresql/spec/unit/defines/{pg_hba_rule_spec.rb → server/pg_hba_rule_spec.rb} +59 -2
- data/modules/postgresql/spec/unit/defines/server/role_spec.rb +23 -0
- data/modules/postgresql/spec/unit/defines/server/table_grant_spec.rb +27 -0
- data/modules/postgresql/spec/unit/defines/server/tablespace_spec.rb +23 -0
- data/modules/postgresql/spec/unit/defines/validate_db_connection_spec.rb +22 -9
- data/modules/postgresql/spec/unit/provider/postgresql_conf/parsed_spec.rb +112 -0
- data/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +29 -0
- data/modules/postgresql/spec/unit/puppet/type/postgresql_psql_spec.rb +1 -0
- data/modules/postgresql/spec/unit/type/postgresql_conf_spec.rb +50 -0
- metadata +177 -53
- data/modules/postgresql/examples/init.pp +0 -1
- data/modules/postgresql/examples/official-postgresql-repos.pp +0 -19
- data/modules/postgresql/examples/postgresql_database.pp +0 -22
- data/modules/postgresql/examples/postgresql_db.pp +0 -30
- data/modules/postgresql/examples/postgresql_grant.pp +0 -14
- data/modules/postgresql/examples/postgresql_pg_hba_rule.pp +0 -18
- data/modules/postgresql/examples/postgresql_pgconf_extras.pp +0 -19
- data/modules/postgresql/examples/postgresql_tablespace.pp +0 -73
- data/modules/postgresql/examples/postgresql_user.pp +0 -28
- data/modules/postgresql/examples/server.pp +0 -10
- data/modules/postgresql/lib/facter/postgres_default_version.rb +0 -69
- data/modules/postgresql/manifests/config/afterservice.pp +0 -47
- data/modules/postgresql/manifests/config/beforeservice.pp +0 -171
- data/modules/postgresql/manifests/config.pp +0 -74
- data/modules/postgresql/manifests/contrib.pp +0 -29
- data/modules/postgresql/manifests/database.pp +0 -85
- data/modules/postgresql/manifests/database_grant.pp +0 -35
- data/modules/postgresql/manifests/database_user.pp +0 -60
- data/modules/postgresql/manifests/db.pp +0 -77
- data/modules/postgresql/manifests/devel.pp +0 -27
- data/modules/postgresql/manifests/grant.pp +0 -77
- data/modules/postgresql/manifests/init.pp +0 -145
- data/modules/postgresql/manifests/initdb.pp +0 -52
- data/modules/postgresql/manifests/java.pp +0 -29
- data/modules/postgresql/manifests/package_source/apt_postgresql_org.pp +0 -21
- data/modules/postgresql/manifests/package_source/yum_postgresql_org.pp +0 -30
- data/modules/postgresql/manifests/pg_hba.pp +0 -19
- data/modules/postgresql/manifests/pg_hba_rule.pp +0 -41
- data/modules/postgresql/manifests/plperl.pp +0 -24
- data/modules/postgresql/manifests/psql.pp +0 -56
- data/modules/postgresql/manifests/python.pp +0 -18
- data/modules/postgresql/manifests/tablespace.pp +0 -59
- data/modules/postgresql/spec/system/install_spec.rb +0 -707
- data/modules/postgresql/spec/system/non_defaults_spec.rb +0 -114
- data/modules/postgresql/spec/unit/classes/contrib_spec.rb +0 -11
- data/modules/postgresql/spec/unit/classes/devel_spec.rb +0 -11
- data/modules/postgresql/spec/unit/classes/init_spec.rb +0 -71
- data/modules/postgresql/spec/unit/classes/postgresql_python_spec.rb +0 -53
- data/modules/postgresql/spec/unit/defines/database_spec.rb +0 -14
- data/modules/postgresql/spec/unit/defines/database_user_spec.rb +0 -19
- data/modules/postgresql/spec/unit/defines/db_spec.rb +0 -20
- data/modules/postgresql/spec/unit/defines/pg_hba_spec.rb +0 -20
- data/modules/postgresql/spec/unit/defines/psql_spec.rb +0 -20
- data/modules/postgresql/spec/unit/defines/role_spec.rb +0 -14
- data/modules/postgresql/spec/unit/defines/tablespace_spec.rb +0 -19
- data/modules/postgresql/spec/unit/facts/postgres_default_version_spec.rb +0 -14
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe 'mysql::server' do
|
3
|
+
let(:facts) {{:osfamily => 'RedHat', :root_home => '/root'}}
|
4
|
+
|
5
|
+
context 'with defaults' do
|
6
|
+
it { should contain_class('mysql::server::install') }
|
7
|
+
it { should contain_class('mysql::server::config') }
|
8
|
+
it { should contain_class('mysql::server::service') }
|
9
|
+
it { should contain_class('mysql::server::root_password') }
|
10
|
+
it { should contain_class('mysql::server::providers') }
|
11
|
+
end
|
12
|
+
|
13
|
+
# make sure that overriding the mysqld settings keeps the defaults for everything else
|
14
|
+
context 'with overrides' do
|
15
|
+
let(:params) {{ :override_options => { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } }}
|
16
|
+
it do
|
17
|
+
should contain_file('/etc/my.cnf').with({
|
18
|
+
:mode => '0644',
|
19
|
+
}).with_content(/basedir/)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with remove_default_accounts set' do
|
24
|
+
let (:params) {{ :remove_default_accounts => true }}
|
25
|
+
it { should contain_class('mysql::server::account_security') }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'mysql::server::install' do
|
29
|
+
let(:params) {{ :package_ensure => 'present', :name => 'mysql-server' }}
|
30
|
+
it do
|
31
|
+
should contain_package('mysql-server').with({
|
32
|
+
:ensure => :present,
|
33
|
+
:name => 'mysql-server',
|
34
|
+
})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'mysql::server::config' do
|
39
|
+
it do
|
40
|
+
should contain_file('/etc/mysql').with({
|
41
|
+
:ensure => :directory,
|
42
|
+
:mode => '0755',
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
it do
|
47
|
+
should contain_file('/etc/mysql/conf.d').with({
|
48
|
+
:ensure => :directory,
|
49
|
+
:mode => '0755',
|
50
|
+
})
|
51
|
+
end
|
52
|
+
|
53
|
+
it do
|
54
|
+
should contain_file('/etc/my.cnf').with({
|
55
|
+
:mode => '0644',
|
56
|
+
})
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'mysql::server::service' do
|
61
|
+
context 'with defaults' do
|
62
|
+
it { should contain_service('mysqld') }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'service_enabled set to false' do
|
66
|
+
let(:params) {{ :service_enabled => false }}
|
67
|
+
|
68
|
+
it do
|
69
|
+
should contain_service('mysqld').with({
|
70
|
+
:ensure => :stopped
|
71
|
+
})
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'mysql::server::root_password' do
|
77
|
+
describe 'when defaults' do
|
78
|
+
it { should_not contain_mysql_user('root@localhost') }
|
79
|
+
it { should_not contain_file('/root/.my.cnf') }
|
80
|
+
end
|
81
|
+
describe 'when set' do
|
82
|
+
let(:params) {{:root_password => 'SET' }}
|
83
|
+
it { should contain_mysql_user('root@localhost') }
|
84
|
+
it { should contain_file('/root/.my.cnf') }
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'mysql::server::providers' do
|
90
|
+
describe 'with users' do
|
91
|
+
let(:params) {{:users => {
|
92
|
+
'foo@localhost' => {
|
93
|
+
'max_connections_per_hour' => '1',
|
94
|
+
'max_queries_per_hour' => '2',
|
95
|
+
'max_updates_per_hour' => '3',
|
96
|
+
'max_user_connections' => '4',
|
97
|
+
'password_hash' => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF'
|
98
|
+
},
|
99
|
+
'foo2@localhost' => {}
|
100
|
+
}}}
|
101
|
+
it { should contain_mysql_user('foo@localhost').with(
|
102
|
+
:max_connections_per_hour => '1',
|
103
|
+
:max_queries_per_hour => '2',
|
104
|
+
:max_updates_per_hour => '3',
|
105
|
+
:max_user_connections => '4',
|
106
|
+
:password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF'
|
107
|
+
)}
|
108
|
+
it { should contain_mysql_user('foo2@localhost').with(
|
109
|
+
:max_connections_per_hour => nil,
|
110
|
+
:max_queries_per_hour => nil,
|
111
|
+
:max_updates_per_hour => nil,
|
112
|
+
:max_user_connections => nil,
|
113
|
+
:password_hash => ''
|
114
|
+
)}
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'with grants' do
|
118
|
+
let(:params) {{:grants => {
|
119
|
+
'foo@localhost/somedb.*' => {
|
120
|
+
'user' => 'foo@localhost',
|
121
|
+
'table' => 'somedb.*',
|
122
|
+
'privileges' => ["SELECT", "UPDATE"],
|
123
|
+
'options' => ["GRANT"],
|
124
|
+
},
|
125
|
+
'foo2@localhost/*.*' => {
|
126
|
+
'user' => 'foo2@localhost',
|
127
|
+
'table' => '*.*',
|
128
|
+
'privileges' => ["SELECT"],
|
129
|
+
},
|
130
|
+
}}}
|
131
|
+
it { should contain_mysql_grant('foo@localhost/somedb.*').with(
|
132
|
+
:user => 'foo@localhost',
|
133
|
+
:table => 'somedb.*',
|
134
|
+
:privileges => ["SELECT", "UPDATE"],
|
135
|
+
:options => ["GRANT"]
|
136
|
+
)}
|
137
|
+
it { should contain_mysql_grant('foo2@localhost/*.*').with(
|
138
|
+
:user => 'foo2@localhost',
|
139
|
+
:table => '*.*',
|
140
|
+
:privileges => ["SELECT"],
|
141
|
+
:options => nil
|
142
|
+
)}
|
143
|
+
end
|
144
|
+
|
145
|
+
describe 'with databases' do
|
146
|
+
let(:params) {{:databases => {
|
147
|
+
'somedb' => {
|
148
|
+
'charset' => 'latin1',
|
149
|
+
'collate' => 'latin1',
|
150
|
+
},
|
151
|
+
'somedb2' => {}
|
152
|
+
}}}
|
153
|
+
it { should contain_mysql_database('somedb').with(
|
154
|
+
:charset => 'latin1',
|
155
|
+
:collate => 'latin1'
|
156
|
+
)}
|
157
|
+
it { should contain_mysql_database('somedb2')}
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'mysql::db', :type => :define do
|
4
|
+
let(:facts) {{ :osfamily => 'RedHat' }}
|
5
|
+
let(:title) { 'test_db' }
|
6
|
+
|
7
|
+
let(:params) {
|
8
|
+
{ 'user' => 'testuser',
|
9
|
+
'password' => 'testpass',
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
it 'should report an error when ensure is not present or absent' do
|
14
|
+
params.merge!({'ensure' => 'invalid_val'})
|
15
|
+
expect { subject }.to raise_error(Puppet::Error,
|
16
|
+
/invalid_val is not supported for ensure\. Allowed values are 'present' and 'absent'\./)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should not notify the import sql exec if no sql script was provided' do
|
20
|
+
should contain_mysql_database('test_db').without_notify
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should subscribe to database if sql script is given' do
|
24
|
+
params.merge!({'sql' => 'test_sql'})
|
25
|
+
should contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should only import sql script on creation if not enforcing' do
|
29
|
+
params.merge!({'sql' => 'test_sql', 'enforce_sql' => false})
|
30
|
+
should contain_exec('test_db-import').with_refreshonly(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should import sql script on creation if enforcing' do
|
34
|
+
params.merge!({'sql' => 'test_sql', 'enforce_sql' => true})
|
35
|
+
should contain_exec('test_db-import').with_refreshonly(false)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not create database and database user' do
|
39
|
+
params.merge!({'ensure' => 'absent', 'host' => 'localhost'})
|
40
|
+
should contain_mysql_database('test_db').with_ensure('absent')
|
41
|
+
should contain_mysql_user('testuser@localhost').with_ensure('absent')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should create with an appropriate collate and charset' do
|
45
|
+
params.merge!({'charset' => 'utf8', 'collate' => 'utf8_danish_ci'})
|
46
|
+
should contain_mysql_database('test_db').with({
|
47
|
+
'charset' => 'utf8',
|
48
|
+
'collate' => 'utf8_danish_ci',
|
49
|
+
})
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rspec-system/spec_helper'
|
2
|
+
require 'rspec-system-puppet/helpers'
|
3
|
+
require 'rspec-system-serverspec/helpers'
|
4
|
+
|
5
|
+
include RSpecSystemPuppet::Helpers
|
6
|
+
|
7
|
+
include Serverspec::Helper::RSpecSystem
|
8
|
+
include Serverspec::Helper::DetectOS
|
9
|
+
|
10
|
+
RSpec.configure do |c|
|
11
|
+
# Project root
|
12
|
+
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
13
|
+
|
14
|
+
# Enable colour
|
15
|
+
c.tty = true
|
16
|
+
|
17
|
+
c.include RSpecSystemPuppet::Helpers
|
18
|
+
|
19
|
+
# This is where we 'setup' the nodes before running our tests
|
20
|
+
c.before :suite do
|
21
|
+
# Install puppet
|
22
|
+
puppet_install
|
23
|
+
|
24
|
+
# Install modules and dependencies
|
25
|
+
puppet_module_install(:source => proj_root, :module_name => 'mysql')
|
26
|
+
shell('puppet module install puppetlabs-stdlib')
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'mysql::server::account_security class' do
|
4
|
+
|
5
|
+
describe 'running puppet code' do
|
6
|
+
# Using puppet_apply as a helper
|
7
|
+
it 'should work with no errors' do
|
8
|
+
pp = <<-EOS
|
9
|
+
class { 'mysql::server': remove_default_accounts => true }
|
10
|
+
EOS
|
11
|
+
|
12
|
+
# Run it twice and test for idempotency
|
13
|
+
puppet_apply(pp) do |r|
|
14
|
+
r.exit_code.should_not == 1
|
15
|
+
r.refresh
|
16
|
+
r.exit_code.should be_zero
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'accounts' do
|
21
|
+
it 'should delete accounts' do
|
22
|
+
shell("mysql -e 'show grants for root@127.0.01;'") do |s|
|
23
|
+
s.exit_code.should == 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should delete databases' do
|
28
|
+
shell("mysql -e 'show databases;' |grep test") do |s|
|
29
|
+
s.exit_code.should == 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'mysql::server::backup class' do
|
4
|
+
context 'should work with no errors' do
|
5
|
+
pp = <<-EOS
|
6
|
+
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
|
7
|
+
mysql::db { 'backup1':
|
8
|
+
user => 'backup',
|
9
|
+
password => 'secret',
|
10
|
+
}
|
11
|
+
|
12
|
+
class { 'mysql::server::backup':
|
13
|
+
backupuser => 'myuser',
|
14
|
+
backuppassword => 'mypassword',
|
15
|
+
backupdir => '/tmp/backups',
|
16
|
+
backupcompress => true,
|
17
|
+
}
|
18
|
+
EOS
|
19
|
+
|
20
|
+
context puppet_apply(pp) do
|
21
|
+
its(:stderr) { should be_empty }
|
22
|
+
its(:exit_code) { should_not == 1 }
|
23
|
+
its(:refresh) { should be_nil }
|
24
|
+
its(:stderr) { should be_empty }
|
25
|
+
its(:exit_code) { should be_zero }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'should run mysqlbackup.sh with no errors' do
|
29
|
+
context shell("/usr/local/sbin/mysqlbackup.sh") do
|
30
|
+
its(:exit_code) { should be_zero }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'should dump all databases to single file' do
|
35
|
+
describe command('ls /tmp/backups/ | grep -c "mysql_backup_[0-9][0-9]*-[0-9][0-9]*.sql.bz2"') do
|
36
|
+
it { should return_stdout /1/ }
|
37
|
+
it { should return_exit_status 0 }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
context 'should create one file per database' do
|
44
|
+
pp = <<-EOS
|
45
|
+
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
|
46
|
+
mysql::db { 'backup1':
|
47
|
+
user => 'backup',
|
48
|
+
password => 'secret',
|
49
|
+
}
|
50
|
+
|
51
|
+
class { 'mysql::server::backup':
|
52
|
+
backupuser => 'myuser',
|
53
|
+
backuppassword => 'mypassword',
|
54
|
+
backupdir => '/tmp/backups',
|
55
|
+
backupcompress => true,
|
56
|
+
file_per_database => true,
|
57
|
+
}
|
58
|
+
EOS
|
59
|
+
|
60
|
+
context puppet_apply(pp) do
|
61
|
+
its(:stderr) { should be_empty }
|
62
|
+
its(:exit_code) { should_not == 1 }
|
63
|
+
its(:refresh) { should be_nil }
|
64
|
+
its(:stderr) { should be_empty }
|
65
|
+
its(:exit_code) { should be_zero }
|
66
|
+
end
|
67
|
+
|
68
|
+
context shell("/usr/local/sbin/mysqlbackup.sh") do
|
69
|
+
its(:exit_code) { should be_zero }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe command('ls /tmp/backups/ | grep -c "mysql_backup_backup1_[0-9][0-9]*-[0-9][0-9]*.sql.bz2"') do
|
73
|
+
it { should return_stdout /1/ }
|
74
|
+
it { should return_exit_status 0 }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'mysql::bindings class' do
|
4
|
+
let(:os) {
|
5
|
+
node.facts['osfamily']
|
6
|
+
}
|
7
|
+
|
8
|
+
case node.facts['osfamily']
|
9
|
+
when 'RedHat'
|
10
|
+
java_package = 'mysql-connector-java'
|
11
|
+
perl_package = 'perl-DBD-MySQL'
|
12
|
+
python_package = 'MySQL-python'
|
13
|
+
ruby_package = 'ruby-mysql'
|
14
|
+
when 'Suse'
|
15
|
+
java_package = 'mysql-connector-java'
|
16
|
+
perl_package = 'perl-DBD-MySQL'
|
17
|
+
python_package = 'python-mysql'
|
18
|
+
case node.facts['operatingsystem']
|
19
|
+
when /OpenSuSE/
|
20
|
+
ruby_package = 'rubygem-mysql'
|
21
|
+
when /(SLES|SLED)/
|
22
|
+
ruby_package = 'ruby-mysql'
|
23
|
+
end
|
24
|
+
when 'Debian'
|
25
|
+
java_package = 'libmysql-java'
|
26
|
+
perl_package = 'libdbd-mysql-perl'
|
27
|
+
python_package = 'python-mysqldb'
|
28
|
+
ruby_package = 'libmysql-ruby'
|
29
|
+
when 'FreeBSD'
|
30
|
+
java_package = 'databases/mysql-connector-java'
|
31
|
+
perl_package = 'p5-DBD-mysql'
|
32
|
+
python_package = 'databases/py-MySQLdb'
|
33
|
+
ruby_package = 'ruby-mysql'
|
34
|
+
else
|
35
|
+
case node.facts['operatingsystem']
|
36
|
+
when 'Amazon'
|
37
|
+
java_package = 'mysql-connector-java'
|
38
|
+
perl_package = 'perl-DBD-MySQL'
|
39
|
+
python_package = 'MySQL-python'
|
40
|
+
ruby_package = 'ruby-mysql'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'running puppet code' do
|
45
|
+
# Using puppet_apply as a helper
|
46
|
+
it 'should work with no errors' do
|
47
|
+
pp = <<-EOS
|
48
|
+
class { 'mysql::bindings': }
|
49
|
+
EOS
|
50
|
+
|
51
|
+
# Run it twice and test for idempotency
|
52
|
+
puppet_apply(pp) do |r|
|
53
|
+
r.exit_code.should_not == 1
|
54
|
+
r.refresh
|
55
|
+
r.exit_code.should be_zero
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'enabling bindings' do
|
61
|
+
it 'should work with no errors' do
|
62
|
+
puppet_apply(%{
|
63
|
+
class { 'mysql::bindings':
|
64
|
+
java_enable => true,
|
65
|
+
perl_enable => true,
|
66
|
+
python_enable => true,
|
67
|
+
ruby_enable => true,
|
68
|
+
}
|
69
|
+
})
|
70
|
+
end
|
71
|
+
|
72
|
+
describe package(java_package) do
|
73
|
+
it { should be_installed }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe package(perl_package) do
|
77
|
+
it { should be_installed }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe package(python_package) do
|
81
|
+
it { should be_installed }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe package(ruby_package) do
|
85
|
+
it { should be_installed }
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'mysql::db define' do
|
4
|
+
describe 'creating a database' do
|
5
|
+
# Using puppet_apply as a helper
|
6
|
+
it 'should work with no errors' do
|
7
|
+
pp = <<-EOS
|
8
|
+
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
|
9
|
+
mysql::db { 'spec1':
|
10
|
+
user => 'root1',
|
11
|
+
password => 'password',
|
12
|
+
}
|
13
|
+
EOS
|
14
|
+
|
15
|
+
# Run it twice and test for idempotency
|
16
|
+
puppet_apply(pp) do |r|
|
17
|
+
[0,2].should include r.exit_code
|
18
|
+
r.refresh
|
19
|
+
r.exit_code.should be_zero
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the database' do
|
24
|
+
shell("mysql -e 'show databases;'|grep spec1") do |s|
|
25
|
+
s.exit_code.should be_zero
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'creating a database with post-sql' do
|
31
|
+
# Using puppet_apply as a helper
|
32
|
+
it 'should work with no errors' do
|
33
|
+
pp = <<-EOS
|
34
|
+
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
|
35
|
+
file { '/tmp/spec.sql':
|
36
|
+
ensure => file,
|
37
|
+
content => 'CREATE TABLE table1 (id int);',
|
38
|
+
before => Mysql::Db['spec2'],
|
39
|
+
}
|
40
|
+
mysql::db { 'spec2':
|
41
|
+
user => 'root1',
|
42
|
+
password => 'password',
|
43
|
+
sql => '/tmp/spec.sql',
|
44
|
+
}
|
45
|
+
EOS
|
46
|
+
|
47
|
+
# Run it twice and test for idempotency
|
48
|
+
puppet_apply(pp) do |r|
|
49
|
+
[0,2].should include r.exit_code
|
50
|
+
r.refresh
|
51
|
+
r.exit_code.should be_zero
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should have the table' do
|
56
|
+
shell("mysql -e 'show tables;' spec2|grep table1") do |s|
|
57
|
+
s.exit_code.should == 0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'mysql::server::monitor class' do
|
4
|
+
context 'should work with no errors' do
|
5
|
+
pp = <<-EOS
|
6
|
+
class { 'mysql::server': root_password => 'password' }
|
7
|
+
|
8
|
+
class { 'mysql::server::monitor':
|
9
|
+
mysql_monitor_username => 'monitoruser',
|
10
|
+
mysql_monitor_password => 'monitorpass',
|
11
|
+
mysql_monitor_hostname => 'localhost',
|
12
|
+
}
|
13
|
+
EOS
|
14
|
+
|
15
|
+
context puppet_apply(pp) do
|
16
|
+
its(:stderr) { should be_empty }
|
17
|
+
its(:exit_code) { should_not == 1 }
|
18
|
+
its(:refresh) { should be_nil }
|
19
|
+
its(:stderr) { should be_empty }
|
20
|
+
its(:exit_code) { should be_zero }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'should run mysqladmin ping with no errors' do
|
24
|
+
describe command("mysqladmin -u monitoruser -pmonitorpass -h localhost ping") do
|
25
|
+
it { should return_stdout /mysqld is alive/ }
|
26
|
+
it { should return_exit_status 0 }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'mysql::server::root_password class' do
|
4
|
+
|
5
|
+
describe 'reset' do
|
6
|
+
it 'shuts down mysql' do
|
7
|
+
pp = <<-EOS
|
8
|
+
class { 'mysql::server': service_enabled => false }
|
9
|
+
EOS
|
10
|
+
|
11
|
+
puppet_apply(pp) do |r|
|
12
|
+
r.exit_code.should_not == 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'deletes the /root/.my.cnf password' do
|
17
|
+
shell('rm -rf /root/.my.cnf')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'deletes all databases' do
|
21
|
+
case node.facts['osfamily']
|
22
|
+
when 'Redhat'
|
23
|
+
shell('rm -rf `grep datadir /etc/my.cnf | cut -d" " -f 3`/*')
|
24
|
+
when 'Debian'
|
25
|
+
shell('rm -rf `grep datadir /etc/mysql/my.cnf | cut -d" " -f 3`/*')
|
26
|
+
shell('mysql_install_db')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'starts up mysql' do
|
31
|
+
pp = <<-EOS
|
32
|
+
class { 'mysql::server': service_enabled => true }
|
33
|
+
EOS
|
34
|
+
|
35
|
+
puppet_apply(pp) do |r|
|
36
|
+
r.exit_code.should_not == 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'when unset' do
|
42
|
+
it 'should work' do
|
43
|
+
pp = <<-EOS
|
44
|
+
class { 'mysql::server': root_password => 'test' }
|
45
|
+
EOS
|
46
|
+
|
47
|
+
# Run it twice and test for idempotency
|
48
|
+
puppet_apply(pp) do |r|
|
49
|
+
r.exit_code.should_not == 1
|
50
|
+
r.refresh
|
51
|
+
r.exit_code.should be_zero
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'when set' do
|
57
|
+
it 'should work' do
|
58
|
+
pp = <<-EOS
|
59
|
+
class { 'mysql::server': root_password => 'new', old_root_password => 'test' }
|
60
|
+
EOS
|
61
|
+
|
62
|
+
# Run it twice and test for idempotency
|
63
|
+
puppet_apply(pp) do |r|
|
64
|
+
r.exit_code.should_not == 1
|
65
|
+
r.refresh
|
66
|
+
r.exit_code.should be_zero
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|