Manage motd on both deb/ubuntu and centos installations.

This commit is contained in:
Andrea Dell'Amico 2019-02-14 15:15:54 +01:00
parent efc0b242ba
commit 14df9121a8
6 changed files with 44 additions and 0 deletions

8
motd/defaults/main.yml Normal file
View File

@ -0,0 +1,8 @@
---
motd_setup: True
motd_additional_text: "\nThis host runs services\n"
deb_motd_packages:
- update-notifier-common
- landscape-common

17
motd/tasks/deb_motd.yml Normal file
View File

@ -0,0 +1,17 @@
---
- block:
- name: Install the packages that manage the dynamic motd file on debian based distributions
apt: pkg={{ deb_motd_packages }} state=present update_cache=yes cache_valid_time=3600
register: motd_pkgs
- name: Install our motd template file on debian based distributions
template: src=motd.j2 dest=/etc/static-motd owner=root group=root mode=0644
- name: Install the dynamic merge script of the motd file on debian based distributions
template: src=update_motd.j2 dest=/etc/update-motd.d/05-motd-message owner=root group=root mode=0755
- name: Initialise the motd prompt on debian based distributions
command: run-parts --lsbsysinit /etc/update-motd.d > /run/motd.dynamic
when: motd_pkgs is changed
tags: motd

6
motd/tasks/main.yml Normal file
View File

@ -0,0 +1,6 @@
---
- import_tasks: deb_motd.yml
when: ansible_distribution_file_variety == "Debian"
- import_tasks: rh_motd.yml
when: ansible_distribution_file_variety == "RedHat"

6
motd/tasks/rh_motd.yml Normal file
View File

@ -0,0 +1,6 @@
- block:
- name: Install our motd template file on RH/CentOS based distributions
template: src=motd.j2 dest=/etc/motd owner=root group=root mode=0644
tags: motd

2
motd/templates/motd.j2 Normal file
View File

@ -0,0 +1,2 @@
{{ motd_additional_text }}

View File

@ -0,0 +1,5 @@
#!/bin/sh
cat /etc/static-motd
exit 0