openvswitch.openvswitch icon indicating copy to clipboard operation
openvswitch.openvswitch copied to clipboard

openvswitch_bridge failure with pre-existing bridge

Open dbalagansky opened this issue 4 years ago • 0 comments
trafficstars

SUMMARY

openvswitch_bridge module fails with pre-existing OVS bridge, created via netplan.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

openvswitch_bridge

ANSIBLE VERSION
ansible [core 2.11.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.pyenv/versions/3.9.2/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.pyenv/versions/3.9.2/bin/ansible
  python version = 3.9.2 (default, Mar 12 2021, 10:09:55) [GCC 7.5.0]
  jinja version = 2.11.3
  libyaml = True
COLLECTION VERSION
Collection              Version
----------------------- -------
openvswitch.openvswitch 2.0.2
CONFIGURATION
# default
OS / ENVIRONMENT

Target:

NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
STEPS TO REPRODUCE

The playbook below is a minimal test case for reproduction. The actual problem (that is, how I've spotted it) is that Netplan on Ubuntu creates new OVS bridges with fail-mode explicitly set to "standalone" (https://github.com/canonical/netplan/blob/main/src/openvswitch.c#L355) and all the consecutive runs of the openvswitch_bridge without explicit fail_mode arg would fail.

- hosts: all
  tasks:
    - name: update netplan
      apt:
        name: netplan.io
        update_cache: yes
        state: latest

    - name: install ovs stuff
      apt:
        name: openvswitch-switch
        state: present

    - name: create bridge via ovs-vsctl
      command: ovs-vsctl --may-exist add-br br-vlan

    - name: set fail-mode via ovs-vsctl
      command: ovs-vsctl set-fail-mode br-vlan standalone

    - name: create OVS bridge via ansible
      openvswitch_bridge:
        bridge: br-vlan
        state: present
EXPECTED RESULTS

All the tasks run fine.

ACTUAL RESULTS
PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [ubuntu01]

TASK [update netplan] **********************************************************
changed: [ubuntu01]

TASK [install ovs stuff] *******************************************************
changed: [ubuntu01]

TASK [create bridge via ovs-vsctl] *********************************************
changed: [ubuntu01]

TASK [set fail-mode via ovs-vsctl] *********************************************
changed: [ubuntu01]

TASK [create OVS bridge via ansible] *******************************************
fatal: [ubuntu01]: FAILED! => {"changed": false, "cmd": "/usr/bin/ovs-vsctl -t 5 set-fail-mode br-vlan None", "msg": "ovs-vsctl: fail-mode must be \"standalone\" or \"secure\"", "rc": 1, "stderr": "ovs-vsctl: fail-mode must be \"standalone\" or \"secure\"\n", "stderr_lines": ["ovs-vsctl: fail-mode must be \"standalone\" or \"secure\""], "stdout": "", "stdout_lines": []}

PLAY RECAP *********************************************************************
ubuntu01                   : ok=5    changed=4    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

dbalagansky avatar Oct 27 '21 09:10 dbalagansky