Compare commits

...

No commits in common. "8016aec966ea46b2f442d4134a4ba0e851c5c8e9" and "master" have entirely different histories.

37 changed files with 350 additions and 190 deletions

View File

@ -1,2 +0,0 @@
# ansible-networkconfig
This repo is intended to be used as an ansible role

17
files/ovsovn.service Normal file
View File

@ -0,0 +1,17 @@
[Unit]
Description=OpenVSwitch and OVN Controller service
After=network-pre.target systemd-udev-settle.service
Before=networking.service
StartLimitIntervalSec=0
[Service]
Type=oneshot
RestartSec=5
RemainAfterExit=true
ExecStart=/usr/sbin/ovsovn-service-manager.sh START
ExecStop=/usr/sbin/ovsovn-service-manager.sh STOP
[Install]
WantedBy=multi-user.target

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,3 @@
--- ---
- name: restart ovsovn.service
- name: restart frr-docker action: service name=ovsovn enabled=yes state=restarted
action: service name=frr-docker enabled=yes state=restarted

2
readme.md Normal file
View File

@ -0,0 +1,2 @@
OpenVSwitch binaries installer
Intended to be used as an ansible role

View File

@ -1,58 +1,94 @@
- name: Install required system packages #OVS Version 2.13.0 \ Ubuntu 18
apt: name={{ item }} state=present update_cache=yes #ovsdb_server_md5_value: "f0a820cb40824c3a9f87f57644037d64"
loop: [ #OVN Version 20.06.0 \ Ubuntu 18
'ifupdown', #ovn_nbctl_md5_value: "4310864bd9676925a49909013071cbec"
'ifenslave',
] #OVS Version 2.14.0 \ Ubuntu 18
tags: interfaces #ovsdb_server_md5_value: "ffd9ba2a6b3da6108d7eb97c70e51761"
#OVN Version 20.09.0 \ Ubuntu 18
- name: Configure /etc/network/interfaces #ovn_nbctl_md5_value: "031e770fd969617c221b156726c2f1dc"
template:
src: templates/interfaces.j2 #OVS Version 2.14.0 \ Ubuntu 20
dest: /etc/network/interfaces #ovsdb_server_md5_value: "2183d20b8df5b5cb790aa238f6e1432e"
backup: yes #OVN Version 20.09.0 \ Ubuntu 20
tags: interfaces #ovn_nbctl_md5_value: "6007bc53bf30b8d4b4c0fab039ee576b"
- name: Remove /etc/network/interfaces.d/eth0
file:
path: /etc/network/interfaces.d/eth0 - name: "Checking presense of OpenVsitch and comparing MD5 hash value"
state: absent stat:
tags: interfaces path: /usr/sbin/ovsdb-server
checksum_algorithm: md5
- name: Remove /etc/netplan/01-netcfg.yaml register: ovsdb_server_exists
file:
path: /etc/netplan/01-netcfg.yaml # This will ensure that all OpenvSwitch binaries are running the desired version, based on the MD5 value stored in the variables file
state: absent # When releasing a new version of ovs, update this md5 an update the copy and install tasks below
tags: interfaces
- name: "Set fact to False"
- name: Remove /etc/netplan/50-cloud-init.yaml set_fact:
file: force_new_ovs_download: False
path: /etc/netplan/50-cloud-init.yaml
state: absent - name: "Checking presense of OVN and comparing MD5 hash value"
tags: interfaces stat:
path: /usr/bin/ovn-nbctl
- name: Add the bonding module checksum_algorithm: md5
modprobe: register: ovn_nbctl_exists
name: bonding
state: present # This will ensure that all OVN binaries are running the desired version, based on the MD5 value stored in the variables file
tags: interfaces # When releasing a new version of OVN, update this md5 an update the copy and install tasks below
- name: Add the 8021q module - name: "Set fact to False"
modprobe: set_fact:
name: 8021q force_new_ovn_download: False
state: present
tags: interfaces
- name: Make sure 8021q\dot1q makes it into /etc/modules for loading at boot time
lineinfile: - name: Include tasks based on OS being Ubuntu 18
path: /etc/modules include_tasks: ubuntu18.yml
state: present when:
line: '8021q' - ansible_distribution_major_version=="18"
tags: interfaces - ansible_distribution == "Ubuntu"
tags: ceph
- name: Make sure bonding makes it into /etc/modules for loading at boot time
lineinfile: - name: Include tasks based on OS being Ubuntu 20
path: /etc/modules include_tasks: ubuntu20.yml
state: present when:
line: 'bonding' - ansible_distribution_major_version=="20"
tags: interfaces - ansible_distribution == "Ubuntu"
tags: ceph
#Install the custom service to start OVS and OVN as required
- name: "Copy /usr/sbin/ovsovn-service-manager.sh file"
template:
src: ovsovn-service-manager.sh.j2
dest: "/usr/sbin/ovsovn-service-manager.sh"
mode: +x
notify:
- restart ovsovn.service
tags: service
- name: "Configure ovsovn.service"
action: template src=files/ovsovn.service dest=/etc/systemd/system/ovsovn.service backup=no
notify:
- restart ovsovn.service
tags: service
- name: "Reload systemctl then enable & start ovsovn service"
systemd:
state: started
enabled: True
daemon_reload: yes
name: ovsovn.service
tags: service

86
tasks/ubuntu18.yml Normal file
View File

@ -0,0 +1,86 @@
- name: set ovsdb_server_md5_value fact
set_fact:
ovsdb_server_md5_value: "ffd9ba2a6b3da6108d7eb97c70e51761"
- name: set ovn_nbctl_md5_value fact
set_fact:
ovn_nbctl_md5_value: "031e770fd969617c221b156726c2f1dc"
- name: "Set fact to true if the source file exists but the MD5 sum does not match"
set_fact:
force_new_ovs_download: "{{ ovsdb_server_exists.stat.checksum != ovsdb_server_md5_value }}"
when: ovsdb_server_exists.stat.exists
- name: "Set fact to true if the source file does not exist"
set_fact:
force_new_ovs_download: True
when: not ovsdb_server_exists.stat.exists
- name: Debug out force_new_ovs_download
debug: msg="Installing OpenVSwitch"
when: force_new_ovs_download
- name: Debug out force_new_ovs_download
debug: msg="NOT Installing OpenVSwitch, MD5 sum matches"
when: not force_new_ovs_download
- name: "Copy OpenVSwitch packages"
copy:
src: "ubuntu18/{{ item }}"
dest: "/tmp/{{ item }}"
with_items:
- libopenvswitch_2.14.0-1_amd64.deb
- openvswitch-common_2.14.0-1_amd64.deb
- openvswitch-switch_2.14.0-1_amd64.deb
when: force_new_ovs_download
- name: "Install OpenVSwitch packages"
apt:
deb: "{{ item }}"
with_items:
- "/tmp/libopenvswitch_2.14.0-1_amd64.deb"
- "/tmp/openvswitch-common_2.14.0-1_amd64.deb"
- "/tmp/openvswitch-switch_2.14.0-1_amd64.deb"
when: force_new_ovs_download
- name: "Set fact to true if the source file exists but the MD5 sum does not match"
set_fact:
force_new_ovn_download: "{{ ovn_nbctl_exists.stat.checksum != ovn_nbctl_md5_value }}"
when: ovn_nbctl_exists.stat.exists and use_ovn
#- debug: msg={{ovn_nbctl_md5_value}}
#- debug: msg={{ovn_nbctl_exists}}
- name: "Set fact to true if the source file does not exist"
set_fact:
force_new_ovn_download: True
when: not ovn_nbctl_exists.stat.exists and use_ovn
- debug: msg="Installing OVN"
when: force_new_ovn_download and use_ovn
- debug: msg="NOT Installing OVN, MD5 sum matches"
when: not force_new_ovn_download and use_ovn
- name: "Copy OVN binaries"
copy:
src: "ubuntu18/{{ item }}"
dest: "/tmp/{{ item }}"
with_items:
- ovn_20.09.0-1_amd64.deb
when: force_new_ovn_download and use_ovn
- name: "Install packages"
apt:
deb: "{{ item }}"
with_items:
- "/tmp/ovn_20.09.0-1_amd64.deb"
when: force_new_ovn_download and use_ovn

86
tasks/ubuntu20.yml Normal file
View File

@ -0,0 +1,86 @@
- name: set ovsdb_server_md5_value fact
set_fact:
ovsdb_server_md5_value: "2183d20b8df5b5cb790aa238f6e1432e"
- name: set ovn_nbctl_md5_value fact
set_fact:
ovn_nbctl_md5_value: "6007bc53bf30b8d4b4c0fab039ee576b"
- name: "Set fact to true if the source file exists but the MD5 sum does not match"
set_fact:
force_new_ovs_download: "{{ ovsdb_server_exists.stat.checksum != ovsdb_server_md5_value }}"
when: ovsdb_server_exists.stat.exists
- name: "Set fact to true if the source file does not exist"
set_fact:
force_new_ovs_download: True
when: not ovsdb_server_exists.stat.exists
- name: Debug out force_new_ovs_download
debug: msg="Installing OpenVSwitch"
when: force_new_ovs_download
- name: Debug out force_new_ovs_download
debug: msg="NOT Installing OpenVSwitch, MD5 sum matches"
when: not force_new_ovs_download
- name: "Copy OpenVSwitch packages"
copy:
src: "ubuntu20/{{ item }}"
dest: "/tmp/{{ item }}"
with_items:
- libopenvswitch_2.14.0-1_amd64.deb
- openvswitch-common_2.14.0-1_amd64.deb
- openvswitch-switch_2.14.0-1_amd64.deb
when: force_new_ovs_download
- name: "Install OpenVSwitch packages"
apt:
deb: "{{ item }}"
with_items:
- "/tmp/libopenvswitch_2.14.0-1_amd64.deb"
- "/tmp/openvswitch-common_2.14.0-1_amd64.deb"
- "/tmp/openvswitch-switch_2.14.0-1_amd64.deb"
when: force_new_ovs_download
- name: "Set fact to true if the source file exists but the MD5 sum does not match"
set_fact:
force_new_ovn_download: "{{ ovn_nbctl_exists.stat.checksum != ovn_nbctl_md5_value }}"
when: ovn_nbctl_exists.stat.exists and use_ovn
#- debug: msg={{ovn_nbctl_md5_value}}
#- debug: msg={{ovn_nbctl_exists}}
- name: "Set fact to true if the source file does not exist"
set_fact:
force_new_ovn_download: True
when: not ovn_nbctl_exists.stat.exists and use_ovn
- debug: msg="Installing OVN"
when: force_new_ovn_download and use_ovn
- debug: msg="NOT Installing OVN, MD5 sum matches"
when: not force_new_ovn_download and use_ovn
- name: "Copy OVN packages"
copy:
src: "ubuntu20/{{ item }}"
dest: "/tmp/{{ item }}"
with_items:
- ovn_20.06.0-1_amd64.deb
when: force_new_ovn_download and use_ovn
- name: "Install OVN packages"
apt:
deb: "{{ item }}"
with_items:
- "/tmp/ovn_20.06.0-1_amd64.deb"
when: force_new_ovn_download and use_ovn

View File

@ -1,127 +0,0 @@
auto lo
iface lo inet loopback
{% if host_loopback_IP is defined %}
auto lo:1
iface lo:1 inet static
address {{host_loopback_IP}}/32
{% endif %}
{% if OOBNET_NIC is defined %}
auto {{OOBNET_NIC}}
allow-hotplug {{OOBNET_NIC}}
iface {{OOBNET_NIC}} inet static
address {{OOBNET_IP}}/{{OOBNET_Netmask}}
{% if OOBNET_GW is defined %}gateway {{OOBNET_GW}}{% endif %}
{% endif %}
{% if autobgp_interfaces is defined %}
{% for item in autobgp_interfaces %}
auto {{ item['name'] }}
allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet static
address {{host_loopback_IP}}/32
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
{% if item['force10G'] is defined and item['force10G']|lower == "true" %}
#Force speed to 10G
post-up sudo ethtool -s {{ item['name'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %}
{% if item['force40G'] is defined and item['force40G']|lower == "true" %}
#Force speed to 40G
pre-up sudo ethtool -s {{ item['name'] }} autoneg off
pre-up sudo ethtool -s {{ item['name'] }} speed 40000
{% endif %}
{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %}
#Auto speed
pre-up sudo /bin/ip link set down {{ item['name'] }} && sleep 1
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 duplex full autoneg on
post-up sudo /bin/ip link set up {{ item['name'] }}
{% endif %}
{% endfor %}
{% endif %}
{% if addressed_interfaces is defined and addressed_interfaces != [] %}
{% for item in addressed_interfaces %}
auto {{ item['name'] }}
allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}}
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
{% if item['ip_gateway'] is defined %}
gateway {{item['ip_gateway']}}
{% endif %}
{% if item['force10G'] is defined and item['force10G']|lower == "true" %}
post-up sudo ethtool -s {{ item['name'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %}
{% endfor %}
{% endif %}
{% if bond_interfaces is defined and bond_interfaces != [] %}
{% for item in bond_interfaces %}
{% for slave in item['slaves'] %}
auto {{slave['name']}}
iface {{slave['name']}} inet manual
bond-master {{ item['name'] }}
{% endfor %}
auto {{ item['name'] }}
{% if item['ip_address'] is defined %}
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}}
{% else %}
iface {{ item['name'] }} inet manual
{% endif %}
{% if item['ip_gateway'] is defined %}
gateway {{item['ip_gateway']}}
{% endif %}
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
bond-mode active-backup
bond-miimon 100
bond-slaves none
{% endfor %}
{% endif %}
{% if vlan_interfaces is defined and vlan_interfaces != [] %}
{% for item in vlan_interfaces %}
auto {{ item['name'] }}
{% if item['ip_address'] is defined %}
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}}
{% else %}
iface {{ item['name'] }} inet manual
{% endif %}
{% if item['ip_gateway'] is defined %}
gateway {{item['ip_gateway']}}
{% endif %}
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
vlan-raw-device {{ item['vlan-raw-device'] }}
{% endfor %}
{% endif %}
{% if unused_interfaces is defined and unused_interfaces != [] %}
{% for item in unused_interfaces %}
allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet manual
{% endfor %}
{% endif %}

View File

@ -0,0 +1,63 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit 1
fi
echo "Command recieved: $1"
START(){
hostname=$(hostname)
loopbackIP={{host_loopback_IP}}
DIR="/var/run/openvswitch/db.sock"
if [ -d "$DIR" ]; then
rm -rf $DIR
echo "Removed extraneous dir $DIR"
fi
/usr/share/openvswitch/scripts/ovs-ctl start --system-id=$hostname
echo "OVS started"
#Instruct OVSDB to listen on 127.0.0.2:6640 so the ovs-vsctl command from within a container can access OpenVswitch
ovs-appctl -t ovsdb-server ovsdb-server/add-remote ptcp:6640
#ovs-vsctl del-br br-int
{% if use_ovn is defined and use_ovn == true %}
echo "Starting OpenVSwitch and OVN on $hostname with $loopbackIP and pointing to OVN controller {{OVN_SB_Connection}}"
ovs-vsctl set open . external-ids:ovn-bridge=br-int
ovs-vsctl set open . external-ids:ovn-remote={{OVN_SB_Connection}}
ovs-vsctl set open . external-ids:ovn-encap-type=geneve
ovs-vsctl set open . external-ids:ovn-encap-ip=$loopbackIP
/usr/share/ovn/scripts/ovn-ctl start_controller
echo "OVS and OVN started"
{% else %}
{% endif %}
{% if ansible_fqdn in groups['br_provider_nodes'] %}
echo "Bringing online br-provider for WAN1"
ovs-vsctl --may-exist add-br br-provider
ovs-vsctl set open . external-ids:ovn-bridge-mappings=WAN1:br-provider
ovs-vsctl --may-exist add-port br-provider bond0.11
{% endif %}
}
STOP() {
{% if use_ovn is defined and use_ovn == true %}
echo "Stopping OVN"
/usr/share/ovn/scripts/ovn-ctl stop_controller
/usr/share/ovn/scripts/ovn-ctl stop_ovsdb
echo "OpenVSwitch and OVN Stopped"
{% else %}
echo "Stopping OpenVSwitch"
/usr/share/openvswitch/scripts/ovs-ctl stop
echo "OpenVSwitch Stopped"
{% endif %}
}
case $1 in
START|STOP) "$1" ;;
esac