diff --git a/.fixtures.yml b/.fixtures.yml index 982f6d38..34ec1c77 100644 --- a/.fixtures.yml +++ b/.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}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dff15c1..72ff1c2a 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/README.md b/README.md index 1fc9992b..3e315569 100644 --- a/README.md +++ b/README.md @@ -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 ------------------- @@ -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 ------ @@ -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 ------------ diff --git a/manifests/init.pp b/manifests/init.pp index ddb1c570..764377ee 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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) @@ -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, + } } } diff --git a/metadata.json b/metadata.json index dd5851db..a2ea269c 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "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", @@ -10,8 +10,22 @@ "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"}, ] } diff --git a/spec/classes/motd_spec.rb b/spec/classes/motd_spec.rb index b3ce6fc5..2812b054 100644 --- a/spec/classes/motd_spec.rb +++ b/spec/classes/motd_spec.rb @@ -44,6 +44,7 @@ } end + context 'When both template and source are specified' do let(:params) { { :content => 'Hello!', @@ -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