Sfoglia il codice sorgente

Set message of the day

tags/2016.12
Filip Pytloun 9 anni fa
parent
commit
e874dfbd4a
5 ha cambiato i file con 73 aggiunte e 0 eliminazioni
  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 Vedi File

@@ -236,6 +236,32 @@ PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
``/etc/skel/.bashrc``). This formula will do this automatically, but will not
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
-------------


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

@@ -0,0 +1,8 @@
{%- 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 Vedi File

@@ -6,6 +6,7 @@
'group': {},
'job': {},
'limit': {},
'motd': {},
'repo': {},
'package': {},
'selinux': 'permissive',
@@ -18,6 +19,7 @@
'group': {},
'job': {},
'limit': {},
'motd': {},
'repo': {},
'package': {},
'selinux': 'permissive',
@@ -30,6 +32,7 @@
'group': {},
'job': {},
'limit': {},
'motd': {},
'repo': {},
'package': {},
'selinux': 'permissive',

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

@@ -48,3 +48,6 @@ include:
{%- if system.limit|length > 0 %}
- linux.system.limit
{%- endif %}
{%- if system.motd|length > 0 %}
- linux.system.motd
{%- endif %}

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

@@ -0,0 +1,33 @@
{%- 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…
Annulla
Salva