Skip to content

Commit 1334a30

Browse files
author
Alkivi SAS
committed
Merge pull request #1 from malaikah/development
Extending and streamlining
2 parents 4019d79 + 68dc932 commit 1334a30

File tree

3 files changed

+78
-47
lines changed

3 files changed

+78
-47
lines changed

Modulefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name 'alkivi-motd'
2-
version '0.0.3'
3-
source 'https://github.com/alkivi-sas/puppet-motd'
4-
author 'alkivi'
5-
license 'LGPLv3'
6-
summary 'Controls motd file on unix system'
7-
description 'Setup motd and give hability to register module'
8-
project_page 'https://github.com/alkivi-sas/puppet-motd'
9-
dependency 'puppetlabs/concat', '1.0.0'
1+
name 'alkivi-motd'
2+
version '0.0.3'
3+
source 'https://github.com/alkivi-sas/puppet-motd'
4+
author 'alkivi'
5+
license 'LGPLv3'
6+
summary 'Controls motd file on unix system'
7+
description 'Setup motd and give hability to register module'
8+
project_page 'https://github.com/alkivi-sas/puppet-motd'
9+
dependency 'puppetlabs/concat', '1.0.0'

manifests/init.pp

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1-
class motd (
2-
$motd = '/etc/motd',
3-
$headers = false,
4-
) {
5-
6-
concat { $motd:
7-
owner => root,
8-
group => root,
9-
mode => '0644',
10-
}
11-
12-
# Add base info if necessary
13-
if($headers)
14-
{
15-
concat::fragment{'motd_header':
16-
target => $motd,
17-
content => template('motd/header.erb'),
18-
order => 01,
19-
}
20-
}
21-
22-
}
23-
1+
# == Class: motd
2+
#
3+
# configures concat target file with, optionally, a header.
4+
#
5+
# == parameters
6+
#
7+
# [*motd*]
8+
# The path to our motd file
9+
#
10+
# [*headers*]
11+
# If true, create a header file at the top of the concatted motd file.
12+
# Defaults to false
13+
#
14+
# [*template*]
15+
# Template to use to create headers.
16+
# Defaults to a rather fetching graphic.
17+
#
18+
class motd (
19+
$motd = '/etc/motd',
20+
$headers = false,
21+
$template = 'motd/header.erb',
22+
) {
23+
24+
concat { $motd:
25+
owner => root,
26+
group => root,
27+
mode => '0644',
28+
}
29+
30+
# Add base info if necessary
31+
if($headers)
32+
{
33+
concat::fragment{'motd_header':
34+
target => $motd,
35+
content => template($template),
36+
order => 01,
37+
}
38+
}
39+
40+
}
41+

manifests/register.pp

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
define motd::register($content='', $order=10) {
2-
if($content == '')
3-
{
4-
$body = " -- ${name}\n"
5-
}
6-
else
7-
{
8-
$body = $content
9-
}
10-
11-
concat::fragment{"motd_fragment_${name}":
12-
target => $motd::motd,
13-
content => $body,
14-
}
15-
}
1+
# == Define: motd::register
2+
#
3+
# Can be used to add snippets to our motd file.
4+
#
5+
# == Parameters
6+
#
7+
# [*content*]
8+
# The content of our fragment.
9+
# Defaults to the name/title of the resource, prepended by '--'.
10+
# Useful for listing things like applied classes.
11+
#
12+
# [*order*]
13+
# The order in which our fragment should appear in the target file.
14+
# Defaults to '10'.
15+
#
16+
define motd::register(
17+
$content = " -- ${name}\n",
18+
$order = '10',
19+
) {
20+
21+
include ::motd
22+
concat::fragment{"motd_fragment_${name}":
23+
target => $motd::motd,
24+
content => $content,
25+
order => $order,
26+
}
27+
28+
}

0 commit comments

Comments
 (0)