diff --git a/roles/mgrote.motd/handlers/main.yml b/roles/mgrote.motd/handlers/main.yml index 6cbb0aac..d73eb213 100644 --- a/roles/mgrote.motd/handlers/main.yml +++ b/roles/mgrote.motd/handlers/main.yml @@ -1,15 +1,10 @@ --- - - name: Erzwinge_Aktualisierung + - name: force update become: yes command: update-motd - when: ansible_facts['os_family'] == "Ubuntu" - name: restart_sshd become: yes systemd: name: sshd state: restarted - - - name: systemctl_reset_failed - become: yes - ansible.builtin.shell: systemctl reset-failed diff --git a/roles/mgrote.motd/tasks/base.yml b/roles/mgrote.motd/tasks/base.yml new file mode 100644 index 00000000..9cd148de --- /dev/null +++ b/roles/mgrote.motd/tasks/base.yml @@ -0,0 +1,74 @@ +--- +# - name: install packages +# become: yes +# ansible.builtin.package: +# name: +# - update-motd +# state: present +# when: "ansible_facts['distribution'] == 'Ubuntu'" + + - name: remove default packages + become: yes + ansible.builtin.package: + name: + - motd-news-config + state: absent + + - name: 'remove unwanted motd messages' + become: yes + ansible.builtin.file: + path: '/etc/update-motd.d/{{ item }}' + state: absent + with_items: + - 00-header + - 10-help-text + - 10-uname + - 50-motd-news + - 80-livepatch + - 50-landscape-sysinfo + - 51-cloudguest + - 99-esm + - 00-ansible + - 20-facts + - 90-updates + - 91-reboot + - 90-updates-available + - 91-release-upgrade + notify: force update + + - name: delete "no warranty" - Message + become: yes + ansible.builtin.file: + path: /etc/motd + state: absent + + - name: setup new motd + become: yes + ansible.builtin.template: + src: '{{ item }}' + dest: '/etc/update-motd.d/{{ item }}' + owner: root + group: root + mode: '755' + with_items: + - 00-ansible-mgrote + - 20-facts-mgrote + - 90-updates-mgrote + - 91-reboot-mgrote + notify: force update + + - name: delete fortune + become: yes + ansible.builtin.file: + path: /etc/update-motd.d/05-fortune-mgrote + state: absent + when: not motd_fortune_aktiv + notify: force update + + - name: delete Wetter + become: yes + ansible.builtin.file: + path: '/etc/update-motd.d/10-wetter-mgrote' + state: absent + when: not motd_wetter_aktiv + notify: force update diff --git a/roles/mgrote.motd/tasks/fortune.yml b/roles/mgrote.motd/tasks/fortune.yml new file mode 100644 index 00000000..26c6db55 --- /dev/null +++ b/roles/mgrote.motd/tasks/fortune.yml @@ -0,0 +1,17 @@ +--- + - name: install fortune + become: yes + ansible.builtin.package: + name: + - fortune + state: present + + - name: setup new motd - fortune + become: yes + ansible.builtin.template: + src: '05-fortune-mgrote' + dest: '/etc/update-motd.d/05-fortune-mgrote' + owner: root + group: root + mode: '755' + notify: force update diff --git a/roles/mgrote.motd/tasks/main.yml b/roles/mgrote.motd/tasks/main.yml index 8340b3dd..493099ef 100644 --- a/roles/mgrote.motd/tasks/main.yml +++ b/roles/mgrote.motd/tasks/main.yml @@ -1,105 +1,15 @@ --- - - name: install fortune - become: yes - ansible.builtin.package: - name: - - fortune - state: present - when: motd_fortune_aktiv - - - name: install packages - become: yes - ansible.builtin.package: - name: - - update-motd - state: present - when: ansible_facts['os_family'] == "Ubuntu" - - - name: remove default packages - become: yes - ansible.builtin.package: - name: - - motd-news-config - state: absent - when: ansible_facts['os_family'] == "Ubuntu" - - - name: 'remove unwanted motd messages' - become: yes - ansible.builtin.file: - path: '/etc/update-motd.d/{{ item }}' - state: absent - with_items: - - 00-header - - 10-help-text - - 10-uname - - 50-motd-news - - 80-livepatch - - 50-landscape-sysinfo - - 51-cloudguest - - 99-esm - - 00-ansible - - 20-facts - - 90-updates - - 91-reboot - - 90-updates-available - - 91-release-upgrade - - - name: delete "no warranty" - Message - become: yes - ansible.builtin.file: - path: /etc/motd - state: absent - - - name: setup new motd - become: yes - ansible.builtin.template: - src: '{{ item }}' - dest: '/etc/update-motd.d/{{ item }}' - owner: root - group: root - mode: '755' - with_items: - - 00-ansible-mgrote - - 20-facts-mgrote - - 90-updates-mgrote - - 91-reboot-mgrote - notify: Erzwinge_Aktualisierung - - - name: setup new motd - fortune - become: yes - ansible.builtin.template: - src: '05-fortune-mgrote' - dest: '/etc/update-motd.d/05-fortune-mgrote' - owner: root - group: root - mode: '755' - notify: Erzwinge_Aktualisierung - when: motd_fortune_aktiv - - - name: delete fortune - become: yes - ansible.builtin.file: - path: /etc/update-motd.d/05-fortune-mgrote - state: absent - when: not motd_fortune_aktiv - - - name: setup new motd - wetter - become: yes - ansible.builtin.template: - src: '10-wetter-mgrote' - dest: '/etc/update-motd.d/10-wetter-mgrote' - owner: root - group: root - mode: '755' - notify: Erzwinge_Aktualisierung - when: motd_wetter_aktiv - - - name: delete Wetter - become: yes - ansible.builtin.file: - path: '/etc/update-motd.d/10-wetter-mgrote' - state: absent - when: not motd_wetter_aktiv - - name: include systemctl tasks include_tasks: systemctl.yml + + - name: include base tasks + include_tasks: base.yml + - name: include fortune tasks + include_tasks: fortune.yml + when: + - motd_wetter_aktiv + + - name: include weather tasks + include_tasks: weather.yml + when: + - motd_wetter_aktiv diff --git a/roles/mgrote.motd/tasks/systemctl.yml b/roles/mgrote.motd/tasks/systemctl.yml index 5951ace7..b92cb478 100644 --- a/roles/mgrote.motd/tasks/systemctl.yml +++ b/roles/mgrote.motd/tasks/systemctl.yml @@ -6,28 +6,4 @@ masked: yes state: stopped enabled: no - notify: systemctl_reset_failed - register: scsstop - ignore_errors: true - - - name: disable units - become: yes - ansible.builtin.shell: systemctl disable motd-news - when: scsstop.changed - - - name: Remove files - become: yes - ansible.builtin.file: - path: - - rm /etc/systemd/system/motd-news - - rm /usr/lib/systemd/system/motd-news - state: absent - - - name: force systemd to reread configs - become: yes - ansible.builtin.systemd: daemon_reload: yes - when: scsstop.changed - - -# https://superuser.com/questions/513159/how-to-remove-systemd-services diff --git a/roles/mgrote.motd/tasks/weather.yml b/roles/mgrote.motd/tasks/weather.yml new file mode 100644 index 00000000..d5db24cc --- /dev/null +++ b/roles/mgrote.motd/tasks/weather.yml @@ -0,0 +1,9 @@ + - name: setup new motd - wetter + become: yes + ansible.builtin.template: + src: '10-wetter-mgrote' + dest: '/etc/update-motd.d/10-wetter-mgrote' + owner: root + group: root + mode: '755' + notify: force update