Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4644364
D2474.id6237.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D2474.id6237.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 25, 01:10 (20 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2435183
Default Alt Text
D2474.id6237.diff (2 KB)
Attached To
Mode
D2474: Update MOTD on FreeBSD 13
Attached
Detach File
Event Timeline
Log In to Comment