---
- name: Dependencies installed
  community.general.pkgng:
    name: "searx,filtron,morty"
    state: latest

- name: Searx enabled
  shell: sysrc searx_enable="YES"

- name: Searx user set to root
  shell: sysrc searx_user="root"

- name: Filtron enabled
  shell: sysrc filtron_enable="YES"

- name: Morty enabled
  shell: sysrc morty_enable="YES"

- name: Searx settings installed
  template:
    src: searx-settings.yml.j2
    dest: /usr/local/etc/searx-settings.yml
    mode: 0600
  notify: Searx restarted

- name: Filtron rules installed
  copy:
    src: filtron-rules.json
    dest: /usr/local/etc/filtron-rules.json
    owner: root
    mode: 0655
  notify: Filtron restarted

- name: Filtron rc script installed
  copy:
    src: filtron.rc
    dest: /usr/local/etc/rc.d/filtron
    owner: root
    mode: 0700
  notify: Filtron restarted

- name: Morty rc script installed
  template:
    src: morty.rc.j2
    dest: /usr/local/etc/rc.d/morty
    owner: root
    mode: 0700
  notify: Morty restarted

- name: Filtron started
  service: name=filtron state=started

- name: Morty started
  service: name=morty state=started

- name: Searx started
  service: name=searx state=started
