111 lines
3.3 KiB
YAML
111 lines
3.3 KiB
YAML
---
|
|
- name: ensure packages are installed
|
|
become: true
|
|
ansible.builtin.package:
|
|
name: "{{ munin_packages }}"
|
|
state: present
|
|
|
|
- name: Ensure needed dirs exists
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
owner: munin
|
|
group: munin
|
|
loop: "{{ munin_dirs }}"
|
|
|
|
- name: Ensure permissions are set
|
|
ansible.builtin.file:
|
|
path: /var/lib/munin/cgi-tmp
|
|
mode: 'ugo+rw'
|
|
state: directory
|
|
owner: munin
|
|
group: munin
|
|
recurse: true
|
|
|
|
- name: Template apache config
|
|
ansible.builtin.template:
|
|
src: apache.conf
|
|
dest: /etc/apache2/sites-available/000-default.conf
|
|
notify: "restart apache2"
|
|
|
|
- name: Enable fgcid
|
|
community.general.apache2_module:
|
|
state: present
|
|
name: fcgid
|
|
|
|
- name: Template munin-server plugins
|
|
ansible.builtin.template:
|
|
src: "{{ item }}"
|
|
dest: "/etc/munin/plugins/{{ item }}"
|
|
mode: '0755'
|
|
loop: "{{ munin_server_plugins }}"
|
|
|
|
- name: Template munin config
|
|
ansible.builtin.template:
|
|
src: munin.conf
|
|
dest: /etc/munin/munin.conf
|
|
mode: '0644'
|
|
owner: munin
|
|
group: munin
|
|
notify: "restart munin"
|
|
|
|
- name: Enable or disable the munin cron job.
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/cron.d/munin
|
|
state: "{{ munin_cron_job }}"
|
|
regexp: "^\\*/5 \\* \\* \\* \\*"
|
|
line: "*/5 * * * * munin if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi"
|
|
create: true
|
|
mode: '0644'
|
|
|
|
# TODO mail config? wie senden?
|
|
# COPY munin_mail.conf /etc/munin/munin-conf.d/munin_mail.conf
|
|
|
|
|
|
# # configure mail notification
|
|
# if [[ -n "$MAILCONTACT" && -n "$MAILSERVER" && -n "$MAILPORT" && -n "$MAILUSER" && -n "$MAILPASSWORD" && -n "$MAILDOMAIN" ]] ; then
|
|
# MAILCONTACT=${MAILCONTACT:="contact@domain.test"}
|
|
# sed -i "s/mailcontact/$MAILCONTACT/g" /etc/ssmtp/ssmtp.conf
|
|
# sed -i "s/mailcontact/$MAILCONTACT/g" /etc/munin/munin-conf.d/munin_mail.conf
|
|
# MAILSERVER=${MAILSERVER:="mail.domain.test"}
|
|
# sed -i "s/mailserver/$MAILSERVER/g" /etc/ssmtp/ssmtp.conf
|
|
# sed -i "s/mailserver/$MAILSERVER/g" /etc/ssmtp/revaliases
|
|
# MAILPORT=${MAILPORT:="25"}
|
|
# sed -i "s/mailport/$MAILPORT/g" /etc/ssmtp/ssmtp.conf
|
|
# sed -i "s/mailport/$MAILPORT/g" /etc/ssmtp/revaliases
|
|
# MAILUSER=${MAILUSER:="alert@domain.test"}
|
|
# sed -i "s/mailuser/$MAILUSER/g" /etc/ssmtp/ssmtp.conf
|
|
# MAILFROM=${MAILFROM:="munin@domain.test"}
|
|
# sed -i "s/mailfrom/$MAILFROM/g" /etc/ssmtp/revaliases
|
|
# MAILPASSWORD=${MAILPASSWORD:="XXXXXXXXX"}
|
|
# sed -i "s/mailpassword/$MAILPASSWORD/g" /etc/ssmtp/ssmtp.conf
|
|
# MAILDOMAIN=${MAILDOMAIN:="domain.test"}
|
|
# sed -i "s/maildomain/$MAILDOMAIN/g" /etc/ssmtp/ssmtp.conf
|
|
# sed -i "s/mailhost/$MAILDOMAIN/g" /etc/ssmtp/ssmtp.conf
|
|
# MAILNAME=${MAILNAME:="Munin"}
|
|
# sed -i "s/munin application user/$MAILNAME/g" /etc/passwd
|
|
# else
|
|
# rm /etc/munin/munin-conf.d/munin_mail.conf /etc/ssmtp/ssmtp.conf
|
|
# fi
|
|
|
|
# cronjoib? timer? TODO
|
|
|
|
# sed -i "s/\*\/5/\*\/5/g" /etc/cron.d/munin kommt imho aus paket
|
|
|
|
- name: check if munin has been run
|
|
ansible.builtin.stat:
|
|
path: /var/cache/munin/www/index.html
|
|
register: placeholder
|
|
|
|
- name: Template website placeholder
|
|
ansible.builtin.template:
|
|
src: placeholder.html
|
|
dest: /var/cache/munin/www/index.html
|
|
mode: '0644'
|
|
owner: munin
|
|
group: munin
|
|
when: not placeholder.stat.exists
|
|
|
|
|
|
# url ohne /munin TODO
|