commit 56b3923c99258db1619ac00aceb955d3e821b331 Author: Adam Dodman Date: Tue Feb 20 20:58:41 2018 +0000 Initial Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..76910fd --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# motd + +#### Table of Contents + +1. [Description](#description) +1. [Setup - The basics of getting started with motd](#setup) + * [What motd affects](#what-motd-affects) +1. [Usage - Configuration options and additional functionality](#usage) +## Description + +This module configures a standardized motd file for all hosts, including node hostname in ascii art for easy host recognition. + +## Setup + +Make sure to include the below in the puppet master, to install dependencies: + +`include motd::install` + +### What motd affects + +This module replaces /etc/motd, and nothing else. It requires Facter>=3. + +## Usage + +Simply include the motd class into your nodes, no configuration is required. + +`include ::motd` diff --git a/examples/init.pp b/examples/init.pp new file mode 100644 index 0000000..5065cfc --- /dev/null +++ b/examples/init.pp @@ -0,0 +1,12 @@ +# The baseline for module testing used by Puppet Inc. is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# https://docs.puppet.com/guides/tests_smoke.html +# +include ::motd diff --git a/examples/install.pp b/examples/install.pp new file mode 100644 index 0000000..7eebb81 --- /dev/null +++ b/examples/install.pp @@ -0,0 +1,2 @@ +# Put this under the master node to install figlet - needed for this module +include motd::install diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..e8a230e --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,31 @@ +# Class: motd +# =========================== +# +# Install a standardized motd across all your nodes. +# +# +# Examples +# -------- +# +# @example +# include ::motd +# +# Authors +# ------- +# +# Adam Dodman +# +# Copyright +# --------- +# +# Copyright 2018 Adam Dodman, unless otherwise noted. +# +class motd { + $motd_hash = { + 'ascii' => generate('/bin/sh', '-c', "/usr/bin/figlet -cw 60 ${$facts['networking']['hostname']}"), + } + + file { '/etc/motd': + content => epp('motd/motd.epp', $motd_hash), + } +} diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..1e93dac --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,19 @@ +# This manifest is used to install figlet, required by the motd package. +# It should only be required on the puppet master. + +class motd::install { + if $facts['os']['family'] == 'Redhat' { + include repoforge + + package { 'figlet': + ensure => present, + require => Yumrepo['rpmforge'], + } + } + + else { + package { 'figlet': + ensure => present, + } + } +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..f0606b5 --- /dev/null +++ b/metadata.json @@ -0,0 +1,18 @@ +{ + "name": "adamant-motd", + "version": "0.1.0", + "author": "Adam Dodman", + "summary": "Install a standardized MOTD banner", + "license": "GPLv3", + "source": "", + "project_page": "github.com/REPLACEME", + "issues_url": "github.com/REPLACEISSUE", + "dependencies": [ + { + "name": "puppetlabs-stdlib", + "version_requirement": ">= 1.0.0" + } + ], + "data_provider": null +} + diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..7ed9953 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,6 @@ +require 'spec_helper' +describe 'motd' do + context 'with default values for all parameters' do + it { should contain_class('motd') } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2c6f566 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/templates/motd.epp b/templates/motd.epp new file mode 100644 index 0000000..ed6868f --- /dev/null +++ b/templates/motd.epp @@ -0,0 +1,17 @@ +<%- | + $ascii, +| -%> + +------------------------------------------------------------ +<%= $ascii %> +------------------------------------------------------------ + Welcome to <%= $facts['networking']['fqdn'] %> + OS: <%= $facts['os']['name'] %> <%= $facts['os']['release']['full'] %> + OS Family: <%= $facts['os']['family'] %> + Architecture: <%= $facts['os']['architecture'] %> + Kernel Version: <%= $facts['kernelversion'] %> + IP: <%= $facts['networking']['ip'] %> + RAM: <%= $facts['memory']['system']['total'] %> +------------------------------------------------------------ + This system is managed by Puppet version <%= $facts['puppetversion'] %> +------------------------------------------------------------