OVN: Make OVS db entries idempotent

Co-Authored-By: Bartosz Bezak <bartosz@stackhpc.com>

Depends-On: https://review.opendev.org/c/openstack/kolla/+/782906

Change-Id: I73cd776772a45c9ffcb045f4d0eff8f4bdc997f1
This commit is contained in:
Michal Nasiadka 2020-09-09 13:51:42 +02:00 committed by Mark Goddard
parent d1e7964a8d
commit 3c3191692f
4 changed files with 28 additions and 40 deletions

View File

@ -79,6 +79,7 @@ kolla_toolbox_default_volumes:
- "/dev/:/dev/" - "/dev/:/dev/"
- "/run/:/run/:shared" - "/run/:/run/:shared"
- "kolla_logs:/var/log/kolla/" - "kolla_logs:/var/log/kolla/"
- "/run/openvswitch:/run/openvswitch:shared"
cron_default_volumes: cron_default_volumes:
- "{{ node_config_directory }}/cron/:{{ container_config_directory }}/:ro" - "{{ node_config_directory }}/cron/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro" - "/etc/localtime:/etc/localtime:ro"

View File

@ -1,45 +1,33 @@
--- ---
- name: Create br-int bridge on OpenvSwitch - name: Create br-int bridge on OpenvSwitch
become: true become: true
command: > kolla_toolbox:
docker exec openvswitch_vswitchd ovs-vsctl --may-exist user: root
add-br br-int -- set Bridge br-int fail-mode=secure module_name: openvswitch_bridge
when: inventory_hostname in groups['ovn-controller'] module_args:
bridge: br-int
state: present
fail_mode: secure
- name: Set OVN encapsulation settings - name: Configure OVN in OVSDB
become: true
command: >
docker exec openvswitch_vswitchd ovs-vsctl set Open_vSwitch .
external_ids:ovn-encap-ip={{ tunnel_interface_address }}
external_ids:ovn-encap-type=geneve
external_ids:ovn-remote={{ ovn_sb_connection }}
when: inventory_hostname in groups['ovn-controller']
- name: Set OVN bridge mappings
vars: vars:
ovn_mappings: "{% for bridge in neutron_bridge_name.split(',') %}physnet{{ loop.index0 + 1 }}:{{ bridge }}{% if not loop.last %},{% endif %}{% endfor %}" ovn_mappings: "{% for bridge in neutron_bridge_name.split(',') %}physnet{{ loop.index0 + 1 }}:{{ bridge }}{% if not loop.last %},{% endif %}{% endfor %}"
ovn_cms_opts: "{{ 'enable-chassis-as-gw' if inventory_hostname in groups['ovn-controller-network'] else '' }}"
become: true become: true
command: docker exec openvswitch_vswitchd ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings={{ ovn_mappings }} kolla_toolbox:
when: user: root
- inventory_hostname in groups["ovn-controller-network"] module_name: openvswitch_db
or (inventory_hostname in groups["ovn-controller-compute"] and computes_need_external_bridge | bool) module_args:
table: Open_vSwitch
- name: Enable chassis as gateway record: .
become: true col: external_ids
command: docker exec openvswitch_vswitchd ovs-vsctl set Open_vSwitch . external-ids:ovn-cms-options="enable-chassis-as-gw" key: "{{ item.name }}"
when: inventory_hostname in groups["ovn-controller-network"] value: "{{ item.value }}"
state: "{{ item.state | default('present') }}"
- name: Ensure chassis as gateway is disabled where required loop:
become: true - { name: ovn-encap-ip, value: "{{ tunnel_interface_address }}" }
command: docker exec openvswitch_vswitchd ovs-vsctl remove Open_vSwitch . external-ids ovn-cms-options - { name: ovn-encap-type, value: geneve }
when: - { name: ovn-remote, value: "{{ ovn_sb_connection }}" }
- inventory_hostname in groups["openvswitch"] - { name: ovn-remote-probe-interval, value: "{{ ovn_remote_probe_interval }}" }
- inventory_hostname not in groups["ovn-controller-network"] - { name: ovn-bridge-mappings, value: "{{ ovn_mappings if ovn_mappings != '' else omit }}", state: "{{ 'present' if (inventory_hostname in groups['ovn-controller-network'] or computes_need_external_bridge | bool) else 'absent' }}" }
- { name: ovn-cms-options, value: "{{ ovn_cms_opts }}", state: "{{ 'present' if ovn_cms_opts != '' else 'absent' }}" }
- name: Set OVN remote probe interval
become: true
command: >
docker exec openvswitch_vswitchd ovs-vsctl set Open_vSwitch .
external_ids:ovn-remote-probe-interval={{ ovn_remote_probe_interval }}
when:
- inventory_hostname in groups["ovn-controller"]

View File

@ -4,6 +4,7 @@
- import_tasks: check-containers.yml - import_tasks: check-containers.yml
- import_tasks: bootstrap.yml - import_tasks: bootstrap.yml
when: inventory_hostname in groups['ovn-controller']
- name: Flush handlers - name: Flush handlers
meta: flush_handlers meta: flush_handlers

View File

@ -3,7 +3,5 @@
- import_tasks: check-containers.yml - import_tasks: check-containers.yml
- import_tasks: bootstrap.yml
- name: Flush handlers - name: Flush handlers
meta: flush_handlers meta: flush_handlers