瀏覽代碼

Update motd.sls

This patch unifies /etc/motd managing approach for both RedHat and
Ubuntu systems. Providing a string value via linux:system:motd
pillar will configure static /etc/motd and remove dynamic scripts
from /etc/update-motd.d (if present).

update-motd can safely be removed because Ubuntu supports dynamic
motd by pam_motd means since 2009.

Related-Prod: PROD-17287

Change-Id: Ic9b7e18abb12cfe8704717b14dc1237e40715319
pull/148/merge
Dmitry Teselkin 6 年之前
父節點
當前提交
538c824aae
共有 2 個文件被更改,包括 27 次插入16 次删除
  1. +20
    -1
      README.rst
  2. +7
    -15
      linux/system/motd.sls

+ 20
- 1
README.rst 查看文件

@@ -825,9 +825,28 @@ default).
Message of the day
~~~~~~~~~~~~~~~~~~

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

Setting static motd will replace existing ``/etc/motd`` and remove scripts from
``/etc/update-motd.d``.

Setting static motd:

.. code-block:: yaml

linux:
system:
motd: |
UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED

You must have explicit, authorized permission to access or configure this
device. Unauthorized attempts and actions to access or use this system may
result in civil and/or criminal penalties.
All activities performed on this system are logged and monitored.

Setting dynamic motd:

.. code-block:: yaml

linux:

+ 7
- 15
linux/system/motd.sls 查看文件

@@ -1,27 +1,19 @@
{%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %}
{%- if system.enabled and system.motd|length > 0 %}

{%- if grains.os_family == 'RedHat' %}
/etc/update-motd.d:
file.directory:
- clean: true

{#- update-motd is not available in RedHat, so support only static motd #}
{%- if system.motd is string %}

{#- Set static motd only #}
/etc/motd:
file.managed:
- contents_pillar: linux:system:motd

{%- else %}

{%- if grains.os == 'Ubuntu' %}
package_update_motd:
pkg.installed:
- name: update-motd
- require_in:
- file: /etc/update-motd.d
{%- endif %}

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

{%- if grains.oscodename == "jessie" %}
motd_fix_pam_sshd:
file.replace:

Loading…
取消
儲存