Skip to content

Commit 86476bf

Browse files
committed
Realigned structure to the standard skeleon 0.0.2
1 parent 1e04a06 commit 86476bf

12 files changed

+120
-204
lines changed

.fixtures.yml.erb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fixtures:
22
repositories:
33
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
4+
stdmod: "git://github.com/stdmod/stdmod.git"
45
symlinks:
56
<%= metadata.name %>: "#{source_dir}"

Modulefile.erb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name '<%= metadata.full_module_name %>'
2-
version '0.0.1'
2+
version '0.0.2'
33
source '<%= metadata.source %>'
44
author '<%= metadata.author %>'
55
license '<%= metadata.license %>'
66
summary 'This module installs and manages <%= metadata.name %>'
7-
description '<%= metadata.description %>'
7+
description '<%= metadata.description %>. Based of stdmod/puppet-skeleton-standard 0.0.2.'
88
project_page '<%= metadata.project_page %>'
99
dependency 'puppetlabs/stdlib'
10+
dependency 'example42/stdmod'

README.md

-65
This file was deleted.

README.markdown.erb renamed to README.md.erb

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This module installs and configures <%= metadata.name %>.
1818

1919
##Module Description
2020

21-
The module is based on **stdmod** naming standars.
21+
The module is based on **stdmod** naming standards version 0.9.0.
2222

2323
Refer to http://github.com/stdmod/ for complete documentation on the common parameters.
2424

@@ -30,7 +30,8 @@ Refer to http://github.com/stdmod/ for complete documentation on the common para
3030
* Can manage all the configuration files (by default no file is changed)
3131

3232
###Setup Requirements
33-
* PuppetLabs stdlib module
33+
* PuppetLabs [stdlib module](https://github.com/puppetlabs/puppetlabs-stdlib)
34+
* StdMod [stdmod module](https://github.com/stdmod/stdmod)
3435
* Puppet version >= 2.7.x
3536
* Facter version >= 1.6.2
3637

data/common.yaml.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
package_name: '<%= metadata.name %>'
3+
service_name: '<%= metadata.name %>'
4+
config_file_path: '/etc/<%= metadata.name %>/<%= metadata.name %>.conf'
5+
config_file_mode: '0644'
6+
config_file_owner: 'root'
7+
config_file_group: 'root'
8+
config_dir_path: '/etc/<%= metadata.name %>'

data/osfamily/.gitkeep

Whitespace-only changes.

hiera.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
version: 2
3+
hierarchy:
4+
[ ['osfamily', '${osfamily}', 'data/osfamily/${osfamily}' ],
5+
['common', 'true', 'data/common' ]
6+
]
7+
backends:
8+
- yaml
9+
- json

manifests/conf.pp.erb

+14-41
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
# name like the the name of the title a custom template to use as content of configfile
3737
# If defined, configfile file has: content => content("$template")
3838
#
39-
# [*mode*] [*owner*] [*group*] [*notify*] [*require*] [*replace*]
39+
# [*mode*]
40+
# [*owner*]
41+
# [*group*]
42+
# [*config_file_require*]
43+
# [*replace*]
4044
# String. Optional. Default: undef
4145
# All these parameters map directly to the created file attributes.
4246
# If not defined the module's defaults are used.
@@ -57,10 +61,10 @@ define <%= metadata.name %>::conf (
5761
$mode = undef,
5862
$owner = undef,
5963
$group = undef,
60-
$notify = undef,
61-
$require = undef,
6264
$replace = undef,
6365

66+
$config_file_require = undef,
67+
6468
$options_hash = undef,
6569

6670
$ensure = present ) {
@@ -69,43 +73,13 @@ define <%= metadata.name %>::conf (
6973

7074
include <%= metadata.name %>
7175

72-
$manage_path = $path ? {
73-
undef => "${<%= metadata.name %>::config_dir_path}/${name}",
74-
default => $path,
75-
}
76-
77-
$manage_content = $content ? {
78-
undef => $template ? {
79-
undef => undef,
80-
default => template($template),
81-
},
82-
default => $content,
83-
}
84-
85-
$manage_mode = $mode ? {
86-
undef => $<%= metadata.name %>::config_file_mode,
87-
default => $mode,
88-
}
89-
90-
$manage_owner = $owner ? {
91-
undef => $<%= metadata.name %>::config_file_owner,
92-
default => $owner,
93-
}
94-
95-
$manage_group = $group ? {
96-
undef => $<%= metadata.name %>::config_file_group,
97-
default => $group,
98-
}
99-
100-
$manage_require = $require ? {
101-
undef => $<%= metadata.name %>::config_file_require,
102-
default => $require,
103-
}
104-
105-
$manage_replace = $replace ? {
106-
undef => $<%= metadata.name %>::config_file_replace,
107-
default => $replace,
108-
}
76+
$manage_path = pickx($path, "${<%= metadata.name %>::config_dir_path}/${name}")
77+
$manage_content = default_content($content, $template)
78+
$manage_mode = pickx($mode, $<%= metadata.name %>::config_file_mode)
79+
$manage_owner = pickx($owner, $<%= metadata.name %>::config_file_owner)
80+
$manage_group = pickx($group, $<%= metadata.name %>::config_file_group)
81+
$manage_require = pickx($config_file_require, $<%= metadata.name %>::config_file_require)
82+
$manage_replace = pickx($replace, $<%= metadata.name %>::config_file_replace)
10983

11084
file { "<%= metadata.name %>_conf_${name}":
11185
ensure => $ensure,
@@ -116,7 +90,6 @@ define <%= metadata.name %>::conf (
11690
owner => $manage_owner,
11791
group => $manage_group,
11892
require => $manage_require,
119-
notify => $notify,
12093
replace => $manage_replace,
12194
}
12295

manifests/init.pp.erb

+21-36
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,30 @@
1111
#
1212
class <%= metadata.name %> (
1313

14-
$ensure = 'present',
15-
$version = undef,
16-
1714
$package_name = $<%= metadata.name %>::params::package_name,
15+
$package_ensure = 'present',
1816

1917
$config_file_path = $<%= metadata.name %>::params::config_file_path,
20-
$config_file_replace = $<%= metadata.name %>::params::config_file_replace,
2118
$config_file_require = 'Package[<%= metadata.name %>]',
19+
$config_file_replace = undef,
2220
$config_file_source = undef,
2321
$config_file_template = undef,
2422
$config_file_content = undef,
25-
$config_file_options_hash = undef,
23+
$config_file_options_hash = { } ,
2624

2725
$config_dir_path = $<%= metadata.name %>::params::config_dir_path,
2826
$config_dir_source = undef,
2927
$config_dir_purge = false,
3028
$config_dir_recurse = true,
3129

3230
$dependency_class = undef,
33-
34-
$scope_hash_filter = '(uptime.*|timestamp)',
31+
$my_class = undef,
3532

3633
) inherits <%= metadata.name %>::params {
3734

3835

39-
# Input parameters validation
40-
validate_re($ensure, ['present','absent'], 'Valid values: present, absent.')
36+
# Class variables validation and management
37+
4138
validate_bool($config_dir_recurse)
4239
validate_bool($config_dir_purge)
4340
if $config_file_options_hash { validate_hash($config_file_options_hash) }
@@ -46,29 +43,9 @@ class <%= metadata.name %> (
4643
$config_file_group = $<%= metadata.name %>::params::config_file_group
4744
$config_file_mode = $<%= metadata.name %>::params::config_file_mode
4845

49-
if $config_file_content {
50-
$manage_config_file_content = $config_file_content
51-
} else {
52-
if $config_file_template {
53-
$manage_config_file_content = template($config_file_template)
54-
} else {
55-
$manage_config_file_content = undef
56-
}
57-
}
58-
59-
if $config_file_notify {
60-
$manage_config_file_notify = $config_file_notify
61-
} else {
62-
$manage_config_file_notify = undef
63-
}
64-
65-
if $version {
66-
$manage_package_ensure = $version
67-
} else {
68-
$manage_package_ensure = $ensure
69-
}
46+
$manage_config_file_content = default_content($config_file_content, $config_file_template)
7047

71-
if $ensure == 'absent' {
48+
if $package_ensure == 'absent' {
7249
$config_dir_ensure = absent
7350
$config_file_ensure = absent
7451
} else {
@@ -77,11 +54,19 @@ class <%= metadata.name %> (
7754
}
7855

7956

57+
# Dependency class
58+
59+
if $<%= metadata.name %>::dependency_class {
60+
include $<%= metadata.name %>::dependency_class
61+
}
62+
63+
8064
# Resources managed
8165

8266
if $<%= metadata.name %>::package_name {
83-
package { $<%= metadata.name %>::package_name:
84-
ensure => $<%= metadata.name %>::manage_package_ensure,
67+
package { '<%= metadata.name %>':
68+
ensure => $<%= metadata.name %>::package_ensure,
69+
name => $<%= metadata.name %>::package_name,
8570
}
8671
}
8772

@@ -111,11 +96,11 @@ class <%= metadata.name %> (
11196
}
11297

11398

99+
114100
# Extra classes
115101

116-
if $<%= metadata.name %>::dependency_class {
117-
include $<%= metadata.name %>::dependency_class
102+
if $<%= metadata.name %>::my_class {
103+
include $<%= metadata.name %>::my_class
118104
}
119105

120106
}
121-

0 commit comments

Comments
 (0)