Ansible nmcli module, tagging vlan with bond interface

97 Views Asked by At

I am trying to run the following playbook to achive bond interface with vlan tag on top of him .

tasks:

  - name: Creating bond conn_name only & ip4 gw4 mode
    community.general.nmcli:
      type: bond
      conn_name: "{{ item.conn_name }}"
      ip4: "{{ item.ip4 }}"
      gw4: "{{ item.gw4 }}"
      mode: "{{ item.mode }}"
      state: present
    with_items:
      - "{{ nmcli_bond }}"

  - name: add bond-slave
    community.general.nmcli:
      type: bond-slave
      conn_name: "{{ item.conn_name }}"
      ifname: "{{ item.ifname }}"
      master: "{{ item.master }}"
      state: present
    with_items:
      - "{{ nmcli_bond_slave }}"

  # Define the VLAN profile
  - name: bond0.10
    nmcli:
      type: vlan
      conn_name: bond0.10
      slave_type: bond
      master: bond0
      vlandev: vlan10
      vlanid: 10
        #      parent: bond0
      state: present

What this script is config on the host is:

[root@client1 ~]# nmcli connection show
NAME       UUID                                  TYPE      DEVICE
enp0s3     1215af13-0f2d-3976-ae6c-34c0523182f3  ethernet  enp0s3
bond0      e6ae34ff-4f85-476a-84dd-595f1956a5fe  bond      bond0
bond0_if1  9eb8142f-ce33-49d2-b415-1e22bfa74900  ethernet  enp0s8
bond0_if2  4c0f66b5-2a80-47ec-ad00-725b8ee0b05d  ethernet  enp0s9
bond0.10   ed4c46dd-0da3-415e-8a91-231515f52744  vlan      --

[root@client1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:c7:bb:7f brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fec7:bb7f/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 08:00:27:f0:f8:a0 brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 08:00:27:f0:f8:a0 brd ff:ff:ff:ff:ff:ff permaddr 08:00:27:76:db:0d
214: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 08:00:27:f0:f8:a0 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.40/32 scope global noprefixroute bond0
       valid_lft forever preferred_lft forever

I would like to achieve bond with VLAN tag.

0

There are 0 best solutions below