Browse Source

Set message of the day

tags/2016.12
Filip Pytloun 9 years ago
parent
commit
e874dfbd4a
5 changed files with 73 additions and 0 deletions
  1. +26
    -0
      README.rst
  2. +8
    -0
      linux/files/motd.sh
  3. +3
    -0
      linux/map.jinja
  4. +3
    -0
      linux/system/init.sls
  5. +33
    -0
      linux/system/motd.sls

+ 26
- 0
README.rst View File

``/etc/skel/.bashrc``). This formula will do this automatically, but will not ``/etc/skel/.bashrc``). This formula will do this automatically, but will not
touch existing user's ``~/.bashrc`` files except root. touch existing user's ``~/.bashrc`` files except root.


Message of the day
~~~~~~~~~~~~~~~~~~

``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
day. Setting custom motd will cleanup existing ones.

.. code-block:: yaml

linux:
system:
motd:
- release: |
#!/bin/sh
[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
# Fall back to using the very slow lsb_release utility
DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi

printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
- warning: |
#!/bin/sh
printf "This is [company name] network.\n"
printf "Unauthorized access strictly prohibited.\n"

Linux network Linux network
------------- -------------



+ 8
- 0
linux/files/motd.sh View File

{%- from "linux/map.jinja" import system with context -%}
{%- for motd in system.motd -%}
{%- if loop.index == index -%}
{%- for name, value in motd.iteritems() -%}
{%- if name == motd_name -%}{{ value }}{%- endif %}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}

+ 3
- 0
linux/map.jinja View File

'group': {}, 'group': {},
'job': {}, 'job': {},
'limit': {}, 'limit': {},
'motd': {},
'repo': {}, 'repo': {},
'package': {}, 'package': {},
'selinux': 'permissive', 'selinux': 'permissive',
'group': {}, 'group': {},
'job': {}, 'job': {},
'limit': {}, 'limit': {},
'motd': {},
'repo': {}, 'repo': {},
'package': {}, 'package': {},
'selinux': 'permissive', 'selinux': 'permissive',
'group': {}, 'group': {},
'job': {}, 'job': {},
'limit': {}, 'limit': {},
'motd': {},
'repo': {}, 'repo': {},
'package': {}, 'package': {},
'selinux': 'permissive', 'selinux': 'permissive',

+ 3
- 0
linux/system/init.sls View File

{%- if system.limit|length > 0 %} {%- if system.limit|length > 0 %}
- linux.system.limit - linux.system.limit
{%- endif %} {%- endif %}
{%- if system.motd|length > 0 %}
- linux.system.motd
{%- endif %}

+ 33
- 0
linux/system/motd.sls View File

{%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %}

package_update_motd:
pkg.installed:
- name: update-motd

/etc/update-motd.d:
file.directory:
- clean: true
- require:
- pkg: package_update_motd

{%- for motd in system.motd %}
{%- set motd_index = loop.index %}

{%- for name, value in motd.iteritems() %}
motd_{{ motd_index }}_{{ name }}:
file.managed:
- name: /etc/update-motd.d/5{{ motd_index }}-{{ name }}
- source: salt://linux/files/motd.sh
- template: jinja
- mode: 755
- require:
- file: /etc/update-motd.d
- defaults:
index: {{ motd_index }}
motd_name: {{ name }}
{%- endfor %}

{%- endfor %}

{%- endif %}

Loading…
Cancel
Save