- name: Install packages
  dnf:
    name: ['os-autoinst-openvswitch', 'tunctl']
    state: present
  tags:
  - packages

- name: Install network-scripts (on F29+)
  dnf:
    name: 'network-scripts'
    state: present
  tags:
  - packages
  when: ansible_distribution_major_version|int >= 29

- name: Enable ipv4_forward in sysctl
  sysctl: name=net.ipv4.ip_forward value=1 state=present sysctl_set=yes reload=yes

- name: Start openvswitch service
  service: name=openvswitch enabled=yes state=started
  with_sequence: "count={{ openqa_workers }}"

- name: Enable network service (needed for openvswitch devices)
  service: name=network enabled=yes state=started

- name: openvswitch bridge device config
  copy: src=ifcfg-br0 dest=/etc/sysconfig/network-scripts/ifcfg-br0 owner=root group=root mode=0644
  notify:
  - restart network
  tags:
  - config

- name: Install ifup-pre-local script to create tap devices
  copy: src=ifup-pre-local dest=/sbin/ifup-pre-local owner=root group=root mode=0755

- name: openvswitch tap devices config
  template: src=ifcfg-tap.j2 dest=/etc/sysconfig/network-scripts/ifcfg-tap{{ item }} owner=root group=root mode=0644
  with_sequence: start=0 end={{ openqa_workers | int }}
  notify:
  - restart network
  tags:
  - config

- name: Enable and start os-autoinst openvswitch service
  service: name=os-autoinst-openvswitch enabled=yes state=started
