mirror of
https://github.com/Adam-Ant/puppet-motd
synced 2024-11-05 07:46:22 +00:00
Initial Commit
This commit is contained in:
commit
56b3923c99
27
README.md
Normal file
27
README.md
Normal file
@ -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`
|
12
examples/init.pp
Normal file
12
examples/init.pp
Normal file
@ -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
|
2
examples/install.pp
Normal file
2
examples/install.pp
Normal file
@ -0,0 +1,2 @@
|
||||
# Put this under the master node to install figlet - needed for this module
|
||||
include motd::install
|
31
manifests/init.pp
Normal file
31
manifests/init.pp
Normal file
@ -0,0 +1,31 @@
|
||||
# Class: motd
|
||||
# ===========================
|
||||
#
|
||||
# Install a standardized motd across all your nodes.
|
||||
#
|
||||
#
|
||||
# Examples
|
||||
# --------
|
||||
#
|
||||
# @example
|
||||
# include ::motd
|
||||
#
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# Adam Dodman <hello@adam-ant.co.uk>
|
||||
#
|
||||
# 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),
|
||||
}
|
||||
}
|
19
manifests/install.pp
Normal file
19
manifests/install.pp
Normal file
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
18
metadata.json
Normal file
18
metadata.json
Normal file
@ -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
|
||||
}
|
||||
|
6
spec/classes/init_spec.rb
Normal file
6
spec/classes/init_spec.rb
Normal file
@ -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
|
1
spec/spec_helper.rb
Normal file
1
spec/spec_helper.rb
Normal file
@ -0,0 +1 @@
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
17
templates/motd.epp
Normal file
17
templates/motd.epp
Normal file
@ -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'] %>
|
||||
------------------------------------------------------------
|
Loading…
Reference in New Issue
Block a user