Skip to content

Commit

Permalink
Added logic for Windows Logon Message
Browse files Browse the repository at this point in the history
  • Loading branch information
ncorrare committed Apr 14, 2015
1 parent 9a02068 commit 75a32f1
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .fixtures.yml
@@ -1,3 +1,7 @@
fixtures:
repositories:
registry:
repo: 'git://github.com/puppetlabs/puppetlabs-registry.git'
ref: '1.1.0'
symlinks:
"motd": "#{source_dir}"
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,4 +1,4 @@
## 2014-10-31 Release 1.2.0
### 2014-10-31 Release 1.2.0
### Summary
- Add content parameter to allow setting static motd content

Expand Down
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -3,7 +3,7 @@ motd

Overview
--------
This module populates `/etc/motd` with the contents of a simple template file.
This module populates `/etc/motd` in Unix systems, and a registry key in Windows Systems with the contents of a simple template file.

Module Description
-------------------
Expand All @@ -20,6 +20,9 @@ Motd utilizes the contents of `motd/motd.erb` to populate `etc/motd`. You must d

include motd

* contents of HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system\legalnoticetext and legalnoticecaption

Motd utilizes the content of `motd/motd.erb` to populate the legalnoticetext registry key, which is shown before login on a Windows System

Usage
------
Expand All @@ -41,7 +44,7 @@ If you would like to provide a static string as the MOTD content you can use the
Limitations
------------

Platforms : Linux
Platforms : Linux, Windows

Development
------------
Expand Down
18 changes: 15 additions & 3 deletions manifests/init.pp
Expand Up @@ -16,9 +16,8 @@
$template = undef,
$content = undef,
) {
if $::kernel == 'Linux' {
if $template {
if $content {
if $template {
if $content {
warning('Both $template and $content parameters passed to motd, ignoring content')
}
$motd_content = template($template)
Expand All @@ -30,10 +29,23 @@
$motd_content = template('motd/motd.erb')
}


if $::kernel == 'Linux' {
file { '/etc/motd':
ensure => file,
backup => false,
content => $motd_content,
}
} elsif $::kernel == 'windows' {
registry_value { 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system\legalnoticecaption':
ensure => present,
type => string,
data => 'Message of the day',
}
registry_value { 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system\legalnoticetext':
ensure => present,
type => string,
data => $motd_content,
}
}
}
20 changes: 17 additions & 3 deletions metadata.json
Expand Up @@ -2,16 +2,30 @@
"name": "puppetlabs-motd",
"version": "1.2.0",
"author": "puppetlabs",
"summary": "A simple module to demonstrate managing /etc/motd as a template",
"summary": "A simple module to demonstrate managing /etc/motd or Windows Logon Message as a template",
"license": "Apache License, Version 2.0",
"source": "https://github.com/puppetlabs/puppetlabs-motd",
"project_page": "https://github.com/puppetlabs/puppetlabs-motd",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"types": [

],
"description": "This module simply manages /etc/motd as a template, showing interpolation of system attributes",
"description": "This module simply manages /etc/motd or the Windows Logon Message as a template, showing interpolation of system attributes",
"operatingsystem_support": [
{
"operatingsystem":"RedHat",
"operatingsystemrelease":[ "5.0", "6.0", "7.0" ]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "12.04", "12.10", "14.04" ]
},
{
"operatingsystem": "Windows",
"operatingsystemrelease": [ "2008", "2008 R2", "2012", "2012 R2" ]
}
],
"dependencies": [

{"name":"puppetlabs/registry","version_requirement":"1.x"},
]
}
20 changes: 20 additions & 0 deletions spec/classes/motd_spec.rb
Expand Up @@ -44,6 +44,7 @@
}
end


context 'When both template and source are specified' do
let(:params) { {
:content => 'Hello!',
Expand Down Expand Up @@ -77,4 +78,23 @@
}
end
end
describe "On Windows" do
let(:facts) {{
:kernel => 'windows',
:operatingsystem => "TestOS",
:memoryfree => "1 KB",
:domain => "testdomain"
}}
context "When content is specified" do
let(:params) { {
:content => 'Hello!',
} }
it { should contain_Registry_value('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system\legalnoticetext').with(
:ensure => 'present',
:type => 'string',
:data => "Hello!"
)
}
end
end
end

1 comment on commit 75a32f1

@ferventcoder
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.