---
- name: manage firmware directory
  file:
    path: /var/www/html/firmware
    state: directory
    mode: 0755
    owner: www-data
    group: www-data

- name: write systemd unit firmware-sync.service
  template:
    src: firmware-sync.service.j2
    dest: /etc/systemd/system/firmware-sync.service
    owner: root
    group: root
    mode: 0644
  notify: reload systemd

- name: write systemd timer firmware-sync.timer
  template:
    src: firmware-sync.timer.j2
    dest: /etc/systemd/system/firmware-sync.timer
    owner: root
    group: root
    mode: 0644
  notify: reload systemd

- name: configure systemd unit/timer firmware-sync
  systemd:
    name: firmware-sync.timer
    enabled: yes
    state: started

- name: write firmware.conf
  template:
    src: firmware_vhost.conf.j2
    dest: /etc/nginx/conf.d/firmware.conf
    owner: root
    group: root
    mode: 0644
  notify: reload nginx

- name: write opkg.conf
  template:
    src: opkg_vhost.conf.j2
    dest: /etc/nginx/conf.d/opkg.conf
    owner: root
    group: root
    mode: 0644
  notify: reload nginx