We have a playbook where we are trying to create a bonded interface between 2 physical interfaces. We are specifying the connection name (conn_name) but we get errors stating that the interface file could not be found. For example, one of the interfaces is eno2, so the interface should be /etc/sysconfig/network-scripts/ifcfg-eno2, however, Ansible is looking for /etc/sysconfig/network-scripts/ifcfg-eno2-1, which doesn’t exist.
Here’s the error:
TASK [Create the bond-slave interfaces] ************************************************************************************************************************************
failed: [server1] (item={u’conn_name’: u’enp216s0f1’, u’ifname’: u’enp216s0f1’, u’master’: u’bond1’}) => {“ansible_loop_var”: “item”, “changed”: false, “item”: {“conn_name”: “enp216s0f1”, “ifname”: “enp216s0f1”, “master”: “bond1”}, “msg”: “Error: Failed to modify connection ‘enp216s0f1’: Could not read file ‘/etc/sysconfig/network-scripts/ifcfg-enp216s0f1-1’: No such file or directory\n”, “name”: “enp216s0f1”, “rc”: 1}
failed: [server2] (item={u’conn_name’: u’enp216s0f1’, u’ifname’: u’enp216s0f1’, u’master’: u’bond1’}) => {“ansible_loop_var”: “item”, “changed”: false, “item”: {“conn_name”: “enp216s0f1”, “ifname”: “enp216s0f1”, “master”: “bond1”}, “msg”: “Error: Failed to modify connection ‘enp216s0f1’: connection.slave-type: Cannot set ‘master’ without ‘slave-type’\n”, “name”: “enp216s0f1”, “rc”: 1}
failed: [server1] (item={u’conn_name’: u’eno2’, u’ifname’: u’eno2’, u’master’: u’bond1’}) => {“ansible_loop_var”: “item”, “changed”: false, “item”: {“conn_name”: “eno2”, “ifname”: “eno2”, “master”: “bond1”}, “msg”: “Error: Failed to modify connection ‘eno2’: Could not read file ‘/etc/sysconfig/network-scripts/ifcfg-eno2-1’: No such file or directory\n”, “name”: “eno2”, “rc”: 1}
failed: [server2] (item={u’conn_name’: u’eno2’, u’ifname’: u’eno2’, u’master’: u’bond1’}) => {“ansible_loop_var”: “item”, “changed”: false, “item”: {“conn_name”: “eno2”, “ifname”: “eno2”, “master”: “bond1”}, “msg”: “Error: Failed to modify connection ‘eno2’: Could not read file ‘/etc/sysconfig/network-scripts/ifcfg-eno2-1’: No such file or directory\n”, “name”: “eno2”, “rc”: 1}
Here’s how we have the variables setup that the playbook uses:
pre_tasks:
- setup:
filter: ‘ansible_default_ipv4’
vars:
-
bond_interface:
-
conn_name: bond1
ip4: 192.168.99.{{ansible_default_ipv4.address.split(‘.’)[3] }}
gw4: 192.168.99.1
mode: 802.3ad
mtu: 9000
-
bond_slave:
-
conn_name: enp216s0f1
ifname: enp216s0f1
master: bond1
- conn_name: eno2
ifname: eno2
master: bond1
-
name: Create bond1 interface
nmcli:
conn_name: ‘{{ item.conn_name }}’
ip4: ‘{{ item.ip4 }}’
gw4: ‘{{ item.gw4 }}’
mode: ‘{{ item.mode }}’
mtu: ‘{{ item.mtu }}’
type: bond
state: present
with_items: -
‘{{ bond_interface }}’
-
name: Create the bond-slave interfaces
nmcli:
type: bond-slave
conn_name: ‘{{ item.conn_name }}’
ifname: ‘{{ item.ifname }}’
master: ‘{{ item.master }}’
state: present
with_items: -
‘{{ bond_slave }}’
It appears as though the conn_name for the bond_slave play is being ignored. The docs state for conn_name: Where conn_name will be the name used to call the connection. when not provided a default name is generated: [-][-].
Any ideas?
Harry