---

- name: Install the TripleO-CI VXLAN networking script
  template:
    src: vxlan_networking.sh.j2
    dest: "{{ working_dir }}/vxlan_networking.sh"
    mode: 0755

- name: Run the TripleO-CI VXLAN networking script
  shell: >
    set -o pipefail &&
    {{ working_dir }}/vxlan_networking.sh 2>&1 {{ timestamper_cmd }} > {{ working_dir }}/vxlan_networking.sh.log

- name: Bring up the bridge on overcloud nodes
  shell: >
    set -o pipefail &&
    sudo ip link set dev {{ undercloud_local_interface }} up 2>&1 {{ timestamper_cmd }} >>
    {{ working_dir }}/vxlan_networking.sh.log
  delegate_to: "{{ item }}"
  with_items: "{{ groups['overcloud'] | default([]) }}"

- name: Set the MTU on overcloud nodes
  shell: >
    set -o pipefail &&
    sudo ip link set dev {{ undercloud_local_interface }} mtu {{ vxlan_mtu }} 2>&1 {{ timestamper_cmd }} >>
    {{ working_dir }}/vxlan_networking.sh.log;
    echo "MTU={{ vxlan_mtu }}" | sudo tee -a /etc/sysconfig/network-scripts/ifcfg-{{ undercloud_local_interface }}
  delegate_to: "{{ item }}"
  with_items: "{{ groups['overcloud'] | default([]) }}"

- name: Test ping across vxlan tunnel (and optionally restart ovs)
  shell: "ping -c 6 -W 3 {{ vxlan_networking_addr_prefix }}.2 || (sudo systemctl restart openvswitch && ping -c 6 -W 3 {{ vxlan_networking_addr_prefix }}.2)"
  delegate_to: "{{ item }}"
  with_items: "{{ groups['overcloud'] | default([]) }}"
