Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Commit 6f9858e

Browse files
committed
t push origin masterMerge branch 'tiengo-master'
2 parents e499cd7 + 109f10d commit 6f9858e

File tree

7 files changed

+115
-42
lines changed

7 files changed

+115
-42
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ Session.vim
77
spec/fixtures
88
.*.sw[a-z]
99
*.un~
10+
/Gemfile.lock
11+
/.bundle

.travis.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
language: ruby
2+
bundler_args: --without development
23
rvm:
34
- 1.8.7
45
- 1.9.3
6+
- 2.0.0
7+
- 2.1.1
58
script:
6-
- "rake spec SPEC_OPTS='--format documentation'"
9+
- "bundle exec rake validate lint spec SPEC_OPTS='--format documentation'"
710
env:
8-
- PUPPET_VERSION="~> 2.6.0"
911
- PUPPET_VERSION="~> 2.7.0"
10-
- PUPPET_VERSION="~> 3.0.0"
12+
- PUPPET_VERSION="~> 3.1.0"
13+
- PUPPET_VERSION="~> 3.2.0"
14+
- PUPPET_VERSION="~> 3.3.0"
1115
- PUPPET_VERSION="~> 3.4.0"
16+
- PUPPET_VERSION="~> 3.5.0"
17+
- PUPPET_VERSION="~> 3.6.0"
18+
- PUPPET_VERSION="~> 3.7.0"
1219
matrix:
1320
exclude:
21+
# fails on can't convert String into Integer at init.pp:284
22+
# fqdn_rand patch in
1423
- rvm: 1.9.3
15-
env: PUPPET_VERSION="~> 2.6.0"
16-
gemfile: .gemfile.travis
17-
- rvm: 1.9.3
1824
env: PUPPET_VERSION="~> 2.7.0"
19-
gemfile: .gemfile.travis
20-
21-
gemfile: .gemfile
25+
# fails on "Could not autoload package: constant Puppet::Type::Package"
26+
- rvm: 2.0.0
27+
env: PUPPET_VERSION="~> 3.1.0"
28+
# fails on iconv couldn't be loaded, which is required for UTF-8/UTF-16 conversions
29+
- rvm: 2.0.0
30+
env: PUPPET_VERSION="~> 2.7.0"
31+
- rvm: 2.1.1
32+
env: PUPPET_VERSION="~> 2.7.0"
33+
# fails on "can't modify frozen Symbol"
34+
- rvm: 2.1.1
35+
env: PUPPET_VERSION="~> 3.1.0"
36+
- rvm: 2.1.1
37+
env: PUPPET_VERSION="~> 3.2.0"
38+
- rvm: 2.1.1
39+
env: PUPPET_VERSION="~> 3.3.0"
2240
notifications:
2341
email:
2442

Gemfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source 'https://rubygems.org'
2+
3+
puppetversion = ENV['PUPPET_VERSION']
4+
5+
is_ruby18 = RUBY_VERSION.start_with? '1.8'
6+
7+
if is_ruby18
8+
gem 'rspec', "~> 3.1.0", :require => false
9+
end
10+
gem 'puppet', puppetversion, :require => false
11+
gem 'puppet-lint'
12+
gem 'puppetlabs_spec_helper', '>= 0.1.0'
13+
gem 'rspec-puppet'
14+
15+
group :development do
16+
gem 'puppet-blacksmith'
17+
end

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ For detailed info about the logic and usage patterns of Example42 modules read R
3535
The simplest way to create database is the following.
3636

3737
mysql::grant { 'db1':
38-
mysql_user => 'myusername',
38+
mysql_user => 'myusername',
3939
mysql_password => 'mypassword',
4040
}
4141

@@ -45,7 +45,7 @@ This will create a MySQL database named 'db1' with a MySQL grant allowing full a
4545
If you want to customize the host the new user can connect from you have to use the 'mysql\_host'.
4646

4747
mysql::grant { 'db1':
48-
mysql_username => 'myusername',
48+
mysql_user => 'myusername',
4949
mysql_password => 'mypassword',
5050
mysql_host => '10.42.42.0/255.255.255.0',
5151
}
@@ -56,7 +56,7 @@ Here the whole 10.42.42.0/24 can connect.
5656
For privileges customization there is the 'mysql\_privileges' parameter.
5757

5858
mysql::grant { 'db1':
59-
mysql_username => 'myusername',
59+
mysql_user => 'myusername',
6060
mysql_password => 'mypassword',
6161
mysql_privileges => 'SELECT',
6262
}
@@ -68,7 +68,7 @@ Like for standard puppet resource you can use the 'ensure' parameter in order to
6868

6969
mysql::grant { 'db1':
7070
ensure => 'absent',
71-
mysql_username => 'myusername',
71+
mysql_user => 'myusername',
7272
mysql_password => 'mypassword',
7373
}
7474

@@ -79,7 +79,7 @@ The mysql\_db\_init\_query\_file is an optional parameter allowing to specify a
7979

8080
mysql::grant { 'db1':
8181
ensure => 'absent',
82-
mysql_username => 'myusername',
82+
mysql_user => 'myusername',
8383
mysql_password => 'mypassword',
8484
mysql_db_init_query_file => '/full/path/to/the/schema.sql',
8585
}
@@ -161,6 +161,26 @@ __NOTE__: The SQL file should already be uploaded on mysql server host.
161161
my_class => 'mysql::example42',
162162
}
163163

164+
## USAGE - Hiera Support
165+
* Manage MySQL configuration using Hiera
166+
167+
```yaml
168+
mysql::template: 'modules/mysql/my.cnf.erb'
169+
mysql::root_password: 'example42'
170+
mysql::options:
171+
port: '3306'
172+
bind-address: '127.0.0.1'
173+
```
174+
175+
* Defining MySQL resources using Hiera
176+
177+
```yaml
178+
mysql::grant_hash:
179+
'db1':
180+
mysql_user: 'myusername'
181+
mysql_password: 'mypassword'
182+
mysql_host: '10.42.42.0/255.255.255.0'
183+
```
164184
165185
## USAGE - Example42 extensions management
166186
* Activate puppi (recommended, but disabled by default)

manifests/init.pp

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,11 @@
266266
$log_file = params_lookup( 'log_file' ),
267267
$port = params_lookup( 'port' ),
268268
$protocol = params_lookup( 'protocol' ),
269-
$grants = params_lookup( 'grants' ),
270-
$users = params_lookup( 'users' )
269+
$augeas_hash = params_lookup( 'augeas_hash'),
270+
$grant_hash = params_lookup( 'grant_hash'),
271+
$query_hash = params_lookup( 'query_hash'),
272+
$queryfile_hash = params_lookup( 'queryfile_hash'),
273+
$user_hash = params_lookup( 'user_hash'),
271274
) inherits mysql::params {
272275

273276
$bool_source_dir_purge=any2bool($source_dir_purge)
@@ -282,6 +285,28 @@
282285
$bool_debug=any2bool($debug)
283286
$bool_audit_only=any2bool($audit_only)
284287

288+
## Integration with Hiera
289+
if $augeas_hash != {} {
290+
validate_hash($augeas_hash)
291+
create_resources('mysql::augeas', $augeas_hash)
292+
}
293+
if $grant_hash != {} {
294+
validate_hash($grant_hash)
295+
create_resources('mysql::grant', $grant_hash)
296+
}
297+
if $query_hash != {} {
298+
validate_hash($query_hash)
299+
create_resources('mysql::query', $query_hash)
300+
}
301+
if $queryfile_hash != {} {
302+
validate_hash($queryfile_hash)
303+
create_resources('mysql::queryfile', $queryfile_hash)
304+
}
305+
if $user_hash != {} {
306+
validate_hash($user_hash)
307+
create_resources('mysql::user', $user_hash)
308+
}
309+
285310
### Root password setup
286311
$random_password = $mysql::password_salt ? {
287312
'' => fqdn_rand(100000000000),
@@ -374,12 +399,12 @@
374399

375400
if $mysql::bool_absent == false {
376401
service { 'mysql':
377-
ensure => $mysql::manage_service_ensure,
378-
name => $mysql::service,
379-
enable => $mysql::manage_service_enable,
380-
hasstatus => $mysql::service_status,
381-
pattern => $mysql::process,
382-
require => [ Package['mysql'] , File['mysql.conf'] ]
402+
ensure => $mysql::manage_service_ensure,
403+
name => $mysql::service,
404+
enable => $mysql::manage_service_enable,
405+
hasstatus => $mysql::service_status,
406+
pattern => $mysql::process,
407+
require => [ Package['mysql'] , File['mysql.conf'] ]
383408
}
384409
}
385410

@@ -418,18 +443,6 @@
418443
include $mysql::my_class
419444
}
420445

421-
### Create instances for integration with Hiera
422-
if $grants != {} {
423-
validate_hash($grants)
424-
create_resources(mysql::grant, $grants)
425-
}
426-
427-
if $users != {} {
428-
validate_hash($users)
429-
create_resources(mysql::user, $users)
430-
}
431-
432-
433446
### Provide puppi data, if enabled ( puppi => true )
434447
if $mysql::bool_puppi == true {
435448
$classvars=get_class_args()

manifests/params.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@
126126
$puppi_helper = 'standard'
127127
$debug = false
128128
$audit_only = false
129-
$grants = {}
130-
$users = {}
129+
$grant_hash = {}
130+
$user_hash = {}
131+
$augeas_hash = {}
132+
$query_hash = {}
133+
$queryfile_hash = {}
131134

132135
}

manifests/password.pp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Load the variables used in this module. Check the params.pp file
99
include mysql
10-
require mysql::params
10+
include mysql::params
1111

1212
if ! defined(File['/root/.my.cnf']) {
1313
file { '/root/.my.cnf':
@@ -35,11 +35,11 @@
3535
}
3636

3737
exec { 'mysql_backup_root_my_cnf':
38-
require => Service['mysql'],
39-
path => '/bin:/sbin:/usr/bin:/usr/sbin',
40-
unless => 'diff /root/.my.cnf /root/.my.cnf.backup',
41-
command => 'cp /root/.my.cnf /root/.my.cnf.backup ; true',
42-
before => File['/root/.my.cnf'],
38+
require => Service['mysql'],
39+
path => '/bin:/sbin:/usr/bin:/usr/sbin',
40+
unless => 'diff /root/.my.cnf /root/.my.cnf.backup',
41+
command => 'cp /root/.my.cnf /root/.my.cnf.backup ; true',
42+
before => File['/root/.my.cnf'],
4343
}
4444

4545

0 commit comments

Comments
 (0)