我正在尝试运行以下剧本来实现其顶部带有
vlan
标签的绑定界面。
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
这个脚本在主机上的配置是:
[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
我想实现与VLAN标签的绑定。
我有一些与你非常相似的东西,它对我有用
- name: Create bond connection
community.general.nmcli:
conn_name: "{{ iname }}.bond"
type: bond
ifname: "{{ iname }}.bond"
mode: 802.3ad
method4: disabled
method6: disabled
autoconnect: yes
state: present
mtu: 9000
- name: Add physical devices to bond
loop: "{{ dev.split(',') }}"
community.general.nmcli:
conn_name: "{{ iname }}.bond-slave.{{ item }}"
type: bond-slave
ifname: "{{ item }}"
master: "{{ iname }}.bond"
autoconnect: yes
state: present
mtu: 9000
- name: Create VLAN connection on bond0
community.general.nmcli:
conn_name: "{{ iname }}"
type: vlan
vlanid: "{{ vlanid }}"
vlandev: "{{ iname }}.bond"
method4: manual
ip4: "{{ ip }}{{ netmask }}"
gw4: "{{ gw }}"
method6: disabled
autoconnect: yes
state: present
mtu: 9000
但是,请注意,对我来说,我需要对其中每一个进行“nmcli con up”,否则,它将不起作用。