Set message of the day
diff --git a/README.rst b/README.rst
index 32a9b2c..a9652c1 100644
--- a/README.rst
+++ b/README.rst
@@ -236,6 +236,32 @@
``/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
-------------
diff --git a/linux/files/motd.sh b/linux/files/motd.sh
new file mode 100644
index 0000000..d29fc88
--- /dev/null
+++ b/linux/files/motd.sh
@@ -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 -%}
diff --git a/linux/map.jinja b/linux/map.jinja
index 9feed99..fd538c3 100644
--- a/linux/map.jinja
+++ b/linux/map.jinja
@@ -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',
diff --git a/linux/system/init.sls b/linux/system/init.sls
index 943c1d0..6c149bb 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -48,3 +48,6 @@
{%- if system.limit|length > 0 %}
- linux.system.limit
{%- endif %}
+{%- if system.motd|length > 0 %}
+- linux.system.motd
+{%- endif %}
diff --git a/linux/system/motd.sls b/linux/system/motd.sls
new file mode 100644
index 0000000..e45a9f3
--- /dev/null
+++ b/linux/system/motd.sls
@@ -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 %}