This role manages the Message of the Day (MOTD) configuration.
Find a file
2025-10-17 16:07:45 +02:00
defaults fix variable name 2025-07-09 13:36:02 +02:00
meta add namespace 2025-06-21 11:33:57 +02:00
tasks fix linting warnings 2025-10-17 16:07:45 +02:00
templates Initial commit 2025-06-02 22:04:46 +02:00
.gitignore add namespace 2025-06-21 11:33:57 +02:00
LICENSE Initial commit 2025-06-02 22:04:46 +02:00
README.md fix variable name 2025-07-09 13:36:02 +02:00

motd_management Role

This role manages the Message of the Day (MOTD) configuration by removing pre-existing MOTD scripts, deploying custom MOTD templates, and ensuring a consistent and informative MOTD display.

Description

The motd_management role provides a way to customize the Message of the Day (MOTD) on Linux systems. It dynamically removes existing MOTD scripts, deploys new ones based on provided templates, and ensures that the MOTD contains useful system information. The role is designed to be update-safe by allowing users to specify custom template directories without modifying the role itself.

Installation

  1. Ensure that Ansible is installed on your system. The recommended version is at least 2.17.
  2. Clone this repository or add the role to your existing project.
  3. No additional dependencies are required.

Usage

Basic Example

- name: Configure MOTD
  hosts: all
  become: true
  roles:
    - motd_management

Custom Template Directory

You can specify a custom template directory to use your own MOTD templates:

- name: Configure MOTD with custom templates
  hosts: all
  become: true
  roles:
    - role: motd_management
      vars:
        motd_management_dir: './custom_templates/motd'

Template Structure

The role expects Jinja2 templates (.j2 files) in the template directory. By default, the role includes:

  • 00-header.j2 - Welcome header
  • 10-sysinfo.j2 - System information display
  • 30-packages.j2 - Package update notifications
  • 90-footer.j2 - Footer information

Features

  • Dynamic Template Discovery: Automatically finds and deploys all .j2 templates from the specified directory
  • Clean Deployment: Removes unwanted MOTD scripts and ensures only your templates are active
  • Update-Safe Configuration: Uses configurable template directories to preserve custom templates during role updates
  • Flexible Template Management: Supports any number of custom MOTD scripts with proper naming conventions
  • Automatic Permissions: Sets executable permissions (0755) on deployed scripts
  • System Integration: Removes /etc/motd and manages /etc/update-motd.d directory

Configuration Variables

Variable Default Description
motd_management_dir {{ role_path }}/templates Directory containing MOTD template files

You can override this variable in your playbook, inventory, or group/host variables.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Submit a pull request describing your changes.

License

This project is licensed under the AGPL License. The AGPL license requires that modifications to the software be disclosed when distributed or made available over a network. For more information, see the LICENSE file.