---
- name: Dependencies installed
  community.general.pkgng:
    name: icecast,mime-support
    state: latest

- name: Icecast user created
  ansible.builtin.user:
    name: icecast

- name: MIME types linked
  file:
    src: /usr/local/etc/mime.types
    dest: /etc/mime.types
    owner: root
    state: link

- name: Icecast access logs created
  copy:
    content: ""
    dest: /var/log/icecast.access.log
    force: no
    owner: icecast
    mode: 0644

- name: Icecast access log created
  copy:
    content: ""
    dest: /var/log/icecast.error.log
    force: no
    owner: icecast
    mode: 0644

- name: Icecast silence.mp3 installed
  copy:
    src: silence.mp3
    dest: /usr/local/share/icecast/web/
    owner: root
    mode: 0664

- name: Icecast settings installed
  template:
    src: icecast.xml.j2
    dest: /usr/local/etc/icecast.xml
    owner: root
    mode: 0664
  notify: Icecast restarted

- name: Icecast enabled
  shell: sysrc icecast_enable="YES"
  notify: Icecast restarted

- name: Icecast started
  service: name=icecast state=started
