Skip to content

Extending and streamlining #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name 'alkivi-motd'
version '0.0.3'
source 'https://github.com/alkivi-sas/puppet-motd'
author 'alkivi'
license 'LGPLv3'
summary 'Controls motd file on unix system'
description 'Setup motd and give hability to register module'
project_page 'https://github.com/alkivi-sas/puppet-motd'
dependency 'puppetlabs/concat', '1.0.0'
name 'alkivi-motd'
version '0.0.3'
source 'https://github.com/alkivi-sas/puppet-motd'
author 'alkivi'
license 'LGPLv3'
summary 'Controls motd file on unix system'
description 'Setup motd and give hability to register module'
project_page 'https://github.com/alkivi-sas/puppet-motd'
dependency 'puppetlabs/concat', '1.0.0'
64 changes: 41 additions & 23 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
class motd (
$motd = '/etc/motd',
$headers = false,
) {

concat { $motd:
owner => root,
group => root,
mode => '0644',
}

# Add base info if necessary
if($headers)
{
concat::fragment{'motd_header':
target => $motd,
content => template('motd/header.erb'),
order => 01,
}
}

}

# == Class: motd
#
# configures concat target file with, optionally, a header.
#
# == parameters
#
# [*motd*]
# The path to our motd file
#
# [*headers*]
# If true, create a header file at the top of the concatted motd file.
# Defaults to false
#
# [*template*]
# Template to use to create headers.
# Defaults to a rather fetching graphic.
#
class motd (
$motd = '/etc/motd',
$headers = false,
$template = 'motd/header.erb',
) {

concat { $motd:
owner => root,
group => root,
mode => '0644',
}

# Add base info if necessary
if($headers)
{
concat::fragment{'motd_header':
target => $motd,
content => template($template),
order => 01,
}
}

}

43 changes: 28 additions & 15 deletions manifests/register.pp
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
define motd::register($content='', $order=10) {
if($content == '')
{
$body = " -- ${name}\n"
}
else
{
$body = $content
}

concat::fragment{"motd_fragment_${name}":
target => $motd::motd,
content => $body,
}
}
# == Define: motd::register
#
# Can be used to add snippets to our motd file.
#
# == Parameters
#
# [*content*]
# The content of our fragment.
# Defaults to the name/title of the resource, prepended by '--'.
# Useful for listing things like applied classes.
#
# [*order*]
# The order in which our fragment should appear in the target file.
# Defaults to '10'.
#
define motd::register(
$content = " -- ${name}\n",
$order = '10',
) {

include ::motd
concat::fragment{"motd_fragment_${name}":
target => $motd::motd,
content => $content,
order => $order,
}

}