From 39f6e624f1a2850da11f3e1e7ea1214b72e31e14 Mon Sep 17 00:00:00 2001 From: Tyler Hale Date: Mon, 22 Aug 2022 13:50:58 -0600 Subject: [PATCH] Add option for not configuring MOTD --- roles/base/tasks/core.yml | 1 + roles/base/tasks/core_motd.yml | 73 ++++++++++++++++------------------ 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/roles/base/tasks/core.yml b/roles/base/tasks/core.yml index 38e6b8c..c3f2a07 100644 --- a/roles/base/tasks/core.yml +++ b/roles/base/tasks/core.yml @@ -32,6 +32,7 @@ file: core_motd.yml apply: tags: motd + when: base_core_motd_enabled == true tags: - motd diff --git a/roles/base/tasks/core_motd.yml b/roles/base/tasks/core_motd.yml index de4463b..1bbe7f8 100644 --- a/roles/base/tasks/core_motd.yml +++ b/roles/base/tasks/core_motd.yml @@ -1,45 +1,42 @@ --- # file: roles/base/tasks/core_motd.yml -- name: "Configure standard MOTD" - block: - - name: Disable unnecessary MOTD files - file: - path: "{{ item }}" - mode: 644 - with_items: - - "/etc/update-motd.d/00-header" - - "/etc/update-motd.d/10-help-text" - - "/etc/update-motd.d/50-motd-news" - - "/etc/update-motd.d/50-landscape-sysinfo" - when: ansible_os_family == "Debian" +- name: Disable unnecessary MOTD files + file: + path: "{{ item }}" + mode: 644 + with_items: + - "/etc/update-motd.d/00-header" + - "/etc/update-motd.d/10-help-text" + - "/etc/update-motd.d/50-motd-news" + - "/etc/update-motd.d/50-landscape-sysinfo" + when: ansible_os_family == "Debian" - - name: Disable motd-news service in config file - ansible.builtin.lineinfile: - path: /etc/default/motd-news - regexp: ^ENABLED= - line: "ENABLED=0" - when: ansible_os_family == "Debian" - notify: - - Reboot Host +- name: Disable motd-news service in config file + ansible.builtin.lineinfile: + path: /etc/default/motd-news + regexp: ^ENABLED= + line: "ENABLED=0" + when: ansible_os_family == "Debian" + notify: + - Reboot Host - - name: Disable motd-news timer - service: - name: motd-news.timer - state: stopped - enabled: no - when: ansible_os_family == "Debian" +- name: Disable motd-news timer + service: + name: motd-news.timer + state: stopped + enabled: no + when: ansible_os_family == "Debian" - - name: Install the MOTD Script - template: - src: motd.j2 - dest: /etc/profile.d/login-info.sh +- name: Install the MOTD Script + template: + src: motd.j2 + dest: /etc/profile.d/login-info.sh - - name: Configure SSH to not use the default MOTD - lineinfile: - path: /etc/ssh/sshd_config - regexp: '^#?PrintMotd ' - line: PrintMotd no - notify: - - Restart SSH - when: base_core_motd_enabled == true +- name: Configure SSH to not use the default MOTD + lineinfile: + path: /etc/ssh/sshd_config + regexp: '^#?PrintMotd ' + line: PrintMotd no + notify: + - Restart SSH