Page MenuHomeDevCentral

D2474.diff
No OneTemporary

D2474.diff

diff --git a/_modules/motd.py b/_modules/motd.py
new file mode 100644
--- /dev/null
+++ b/_modules/motd.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+# -------------------------------------------------------------
+# Salt — MOTD execution module
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Description: Allow to generate MOTD
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+
+def get_path():
+ os = __grains__['os_family']
+
+ if os == "Debian":
+ return "/etc/motd.tail"
+
+ if os == "FreeBSD" and __grains__['osmajorrelease'] >= 13:
+ return "/etc/motd.template"
+
+ return "/etc/motd"
diff --git a/roles/core/motd/init.sls b/roles/core/motd/init.sls
--- a/roles/core/motd/init.sls
+++ b/roles/core/motd/init.sls
@@ -6,27 +6,53 @@
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+{% set motd_path = salt['motd.get_path']() %}
{% set network = salt['node.get']('network') %}
motd:
file.managed:
- {% if grains['os_family'] == 'Debian' %}
- - name: /etc/motd.tail
- {% else %}
- - name: /etc/motd
- {% endif %}
+ - name: {{ motd_path }}
- source: salt://roles/core/motd/files/{{ grains['id'] }}
- template: jinja
- context:
ipv4_address: {{ network['ipv4_address'] }}
ipv4_gateway: {{ network['ipv4_gateway'] }}
-# Fixes T858
-get_rid_of_scaleway_motd:
- file.absent:
- - name: /etc/update-motd.d/50-scw
+# -------------------------------------------------------------
+# Provide a `motd` command to read /etc/motd
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/usr/local/bin/motd:
file.managed:
- source: salt://roles/core/motd/files/motd.sh
- mode: 755
+
+{% if motd_path != "/etc/motd" %}
+/etc/motd:
+ file.symlink:
+ - target: {{ motd_path }}
+{% endif %}
+
+# -------------------------------------------------------------
+# Scaleway instances
+#
+# Fixes T858.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+get_rid_of_scaleway_motd:
+ file.absent:
+ - name: /etc/update-motd.d/50-scw
+
+# -------------------------------------------------------------
+# Generate MOTD from templates
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if grains['os_family'] == 'FreeBSD' and grains['osmajorrelease'] >= 13 %}
+
+update_motd:
+ cmd.run:
+ - name: service motd restart
+ - onchanges:
+ - file: motd
+
+{% endif %}

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 24, 22:13 (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2435183
Default Alt Text
D2474.diff (2 KB)

Event Timeline