promote develop to master #6
@ -52,4 +52,8 @@ class profiles::base (
|
|||||||
# default users
|
# default users
|
||||||
include profiles::accounts::sysadmin
|
include profiles::accounts::sysadmin
|
||||||
|
|
||||||
|
# add a motd
|
||||||
|
include profiles::base::facts
|
||||||
|
include profiles::base::motd
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
29
site/profiles/manifests/base/facts.pp
Normal file
29
site/profiles/manifests/base/facts.pp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# a class to define some global facts
|
||||||
|
class profiles::base::facts {
|
||||||
|
|
||||||
|
# The path where external facts are stored
|
||||||
|
$facts_d_path = '/opt/puppetlabs/facter/facts.d'
|
||||||
|
|
||||||
|
# Ensure the directory exists
|
||||||
|
file { $facts_d_path:
|
||||||
|
ensure => directory,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0755',
|
||||||
|
}
|
||||||
|
|
||||||
|
# facts to create
|
||||||
|
$fact_list = [ 'enc_role', 'enc_env' ]
|
||||||
|
|
||||||
|
# Manage the external fact file with content from the template
|
||||||
|
$fact_list.each | String $item | {
|
||||||
|
file { "${facts_d_path}/${item}.txt":
|
||||||
|
ensure => file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0644',
|
||||||
|
content => template("profiles/base/facts/${item}.erb"),
|
||||||
|
require => File[$facts_d_path],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
site/profiles/manifests/base/motd.pp
Normal file
20
site/profiles/manifests/base/motd.pp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# set the motd
|
||||||
|
class profiles::base::motd (
|
||||||
|
String $enc_role = pick($facts['enc_role'], 'undefined'),
|
||||||
|
String $enc_env = pick($facts['enc_env'], 'undefined'),
|
||||||
|
String $fqdn = $facts['networking']['fqdn'],
|
||||||
|
String $addr = $facts['networking']['ip'],
|
||||||
|
String $nic = $facts['networking']['primary'],
|
||||||
|
String $os_name = $facts['os']['name'],
|
||||||
|
String $os_release = $facts['os']['release']['full'],
|
||||||
|
) {
|
||||||
|
|
||||||
|
# Use the regsubst function to remove the 'roles::' prefix from the role name
|
||||||
|
$clean_role = regsubst($enc_role, '^roles::', '')
|
||||||
|
|
||||||
|
# Manage the content of the /etc/motd file
|
||||||
|
file { '/etc/motd':
|
||||||
|
ensure => file,
|
||||||
|
content => template('profiles/base/motd/motd.erb'),
|
||||||
|
}
|
||||||
|
}
|
||||||
1
site/profiles/templates/base/facts/enc_env.erb
Normal file
1
site/profiles/templates/base/facts/enc_env.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
enc_env=<%= @enc_env %>
|
||||||
1
site/profiles/templates/base/facts/enc_role.erb
Normal file
1
site/profiles/templates/base/facts/enc_role.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
enc_role=<%= @enc_role[0] %>
|
||||||
13
site/profiles/templates/base/motd/motd.erb
Normal file
13
site/profiles/templates/base/motd/motd.erb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<%
|
||||||
|
# calculate padding for the longest word
|
||||||
|
max_length = ['fqdn:', 'os:', 'role:', 'branch:', 'addr:', 'nic:'].max_by(&:length).length
|
||||||
|
# helper lambda to right-align text
|
||||||
|
align = ->(word) { word.ljust(max_length) }
|
||||||
|
%>
|
||||||
|
<%= align.call('fqdn:') %> <%= @fqdn %>
|
||||||
|
<%= align.call('os:') %> <%= @os_name %> <%= @os_release %>
|
||||||
|
<%= align.call('role:') %> <%= @clean_role %>
|
||||||
|
<%= align.call('branch:') %> <%= @enc_env %>
|
||||||
|
<%= align.call('addr:') %> <%= @addr %>
|
||||||
|
<%= align.call('nic:') %> <%= @nic %>
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user