- name: Install Wondershaper systemd unit file from template
  template:
    backup: yes
    src: roles/network/templates/wondershaper/wondershaper.service
    dest: /etc/systemd/system/wondershaper.service
    mode: 0644

- name: Install /usr/bin/wondershaper from template
  template:
    backup: yes
    src: roles/network/templates/wondershaper/wondershaper.j2
    dest: /usr/bin/wondershaper
    owner: root
    group: root
    mode: 0744

- name: Create conf.d directory
  file:
    path: /etc/conf.d
    owner: root
    group: root
    mode: 0755
    state: directory

- name: Install /etc/conf.d/wondershaper.conf from template
  template:
    src: roles/network/templates/wondershaper/wondershaper.conf
    dest: /etc/conf.d/wondershaper.conf
    owner: root
    group: root
    mode: 0600

- name: Create fact (link) for /etc/conf.d/wondershaper.conf
  file:
    src: /etc/conf.d/wondershaper.conf
    dest: /etc/ansible/facts.d/wondershaper.fact
    owner: root
    group: root
    state: link

- name: Add 'wondershaper' variable values to {{ iiab_ini_file }}
  ini_file:
    dest: "{{ iiab_ini_file }}"
    section: wondershaper
    option: "{{ item.option }}"
    value: "{{ item.value }}"
  with_items:
    - option: name
      value: wondershaper
    - option: description
      value: '"Wondershaper is a command line tool to set maximum transfer rates for network adapters."'
    - option: enabled
      value: "{{ wondershaper_enabled }}"
