ansibleopenvswitch

How can I create Open vSwitch QoS settings with Ansible?


I'm trying to create Open vSwitch QoS settings by using the Ansible openvswitch_db module.

The Ansible task should emulate a command like the following:

ovs-vsctl set port vm00-eth1 qos=@newqos -- --id=@newqos create qos type=egress-policer other-config:cir=30000000 other-config:cbs=3000000

I tried an Ansible task like the following, but it doesn't change any QoS settings.

- openvswitch.openvswitch.openvswitch_db:
    table: Port
    record: vm00-eth1
    col: other_config
    key: cir
    value: 30000000

The Ansible task runs through successfully, but there is still no QoS setting on that port:

root@host00 ~ # ovs-appctl qos/show vm00-eth1
QoS not configured on vm00-eth1

Solution

  • ovs-vsctl set port vm00-eth1 qos=@newqos -- --id=@newqos create qos type=egress-policer other-config:cir=30000000 other-config:cbs=3000000

    When you use the command above, you are operating two tables in fact. Port table and QoS table are refered together by "--".

    The comand do actions:

    So you have to understand the relationship of key, column and table in ovsdb. And connections between tables.

    It would not be easy to put all db operations in the ansible openvswitch_db module. I would recommand you use ansible shell command instead instead:

    - name: setting qos
      shell: "{{ item.command }}"
      args:
        warn: false
      with_items:
        - { "command": "ovs-vsctl set port vm00-eth1 qos=@newqos -- --id=@newqos create qos type=egress-policer other-config:cir=30000000 other-config:cbs=3000000" }