Add option for not configuring MOTD

This commit is contained in:
Tyler Hale 2022-08-22 13:35:30 -06:00
parent 67032f2dc7
commit 44d7644dfe
Signed by: Tyler
GPG key ID: C7CC4B910D88EF96
2 changed files with 41 additions and 35 deletions

View file

@ -32,6 +32,9 @@ base_core_timezone: "America/Boise"
# MOTD # MOTD
# ==== # ====
# Banner to add to MOTD
base_core_motd_enabled: true
# Banner to add to MOTD # Banner to add to MOTD
base_core_motd_banner: "" base_core_motd_banner: ""

View file

@ -1,7 +1,9 @@
--- ---
# file: roles/base/tasks/core_motd.yml # file: roles/base/tasks/core_motd.yml
- name: Disable unnecessary MOTD files - name: "Configure standard MOTD"
block:
- name: Disable unnecessary MOTD files
file: file:
path: "{{ item }}" path: "{{ item }}"
mode: 644 mode: 644
@ -12,7 +14,7 @@
- "/etc/update-motd.d/50-landscape-sysinfo" - "/etc/update-motd.d/50-landscape-sysinfo"
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: Disable motd-news service in config file - name: Disable motd-news service in config file
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/default/motd-news path: /etc/default/motd-news
regexp: ^ENABLED= regexp: ^ENABLED=
@ -21,22 +23,23 @@
notify: notify:
- Reboot Host - Reboot Host
- name: Disable motd-news timer - name: Disable motd-news timer
service: service:
name: motd-news.timer name: motd-news.timer
state: stopped state: stopped
enabled: no enabled: no
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: Install the MOTD Script - name: Install the MOTD Script
template: template:
src: motd.j2 src: motd.j2
dest: /etc/profile.d/login-info.sh dest: /etc/profile.d/login-info.sh
- name: Configure SSH to not use the default MOTD - name: Configure SSH to not use the default MOTD
lineinfile: lineinfile:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
regexp: '^#?PrintMotd ' regexp: '^#?PrintMotd '
line: PrintMotd no line: PrintMotd no
notify: notify:
- Restart SSH - Restart SSH
when: base_core_motd_enabled == true