common/tasks/motd.yaml

52 lines
1.4 KiB
YAML

---
- name: "manage motd"
tags: "motd"
block:
# find old motd files
- name: "motd - find old scripts"
ansible.builtin.find:
paths: "/etc/update-motd.d/"
file_type: "file"
excludes:
- "10-custom-motd"
register: "old_motd"
when: "ansible_os_family == 'Debian'"
# remove old custom motd files
- name: "motd - cleanup directory"
ansible.builtin.file:
path: "{{ item.path }}"
state: "absent"
loop: "{{ old_motd.files }}"
when:
- "old_motd.files|length > 0"
- "ansible_os_family == 'Debian'"
# remove old motd files
- name: "motd - cleanup main file"
ansible.builtin.file:
path: "/etc/motd"
state: "absent"
when: "inventory_hostname != 'bastion.siempie.internal'"
# configure motd
- name: "motd - siempie"
ansible.builtin.template:
src: "templates/motd/motd.sh.j2"
dest: "/etc/update-motd.d/10-custom-motd"
owner: "root"
group: "root"
mode: "0755"
when: 'ansible_os_family == "Debian"'
# configure motd
- name: "motd - siempie - alpine"
ansible.builtin.template:
src: "templates/motd/alpine-motd.sh.j2"
dest: "/etc/profile.d/motd.sh"
owner: "root"
group: "root"
mode: "0755"
when: 'ansible_os_family == "Alpine"'