Open metalwanderer opened 3 years ago
Hello, sorry for a late reply. Next time you might want to consider creating an issue in the main debops/debops
repository, the separate role repositories are not maintained anymore.
As for your issue - it seems that you either didn't show the full configuration (just eth0
interface), or you have shown details from two different hosts. The generated configuration seems to be for a host with Predictable Network Interface Naming Scheme enabled (eno1
instead of eth0
, etc. The ifupdown
role should detect such case and use the Ethernet network interfaces that are present on a given host, but without seeing the interface state before and after the configuration is applied it's hard to guess what might have happened to break the script.
So, can you show the ip addr list
output before you apply the ifupdown
role, as well as your desired configuration for all of the network interfaces that you want to create?
Hi @drybjed - thanks for your reply. I didn't realize this was the wrong place to open an issue... I'll make sure to use the main repo next time.
Sorry for the slightly confusing initial report - let me see if I can be a little clearer. Yes, I did show output from two hosts... ultimately, I'd like to manage the interfaces for all of my hosts (baremetal + container), but in the interest of simplicity, I'll restrict to my baremetal server here:
root@thor:~# ip addr list
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: idrac: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 2c:ea:7f:f9:c1:61 brd ff:ff:ff:ff:ff:ff
inet 169.254.0.2/16 brd 169.254.255.255 scope global idrac
valid_lft forever preferred_lft forever
inet6 fe80::2eea:7fff:fef9:c161/64 scope link
valid_lft forever preferred_lft forever
3: ens1f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 2c:ea:7f:6a:1d:c3 brd ff:ff:ff:ff:ff:ff
4: ens1f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 2c:ea:7f:6a:1d:c4 brd ff:ff:ff:ff:ff:ff
5: eno1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
link/ether 2c:ea:7f:f9:c1:64 brd ff:ff:ff:ff:ff:ff
6: eno2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
link/ether 2c:ea:7f:f9:c1:64 brd ff:ff:ff:ff:ff:ff
8: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP group default qlen 1000
link/ether 2c:ea:7f:f9:c1:64 brd ff:ff:ff:ff:ff:ff
72: lxcbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 00:16:3e:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 10.0.3.1/24 scope global lxcbr0
valid_lft forever preferred_lft forever
148: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 2c:ea:7f:f9:c1:64 brd ff:ff:ff:ff:ff:ff
inet 10.254.10.10/16 brd 10.254.255.255 scope global br1
valid_lft forever preferred_lft forever
inet6 fe80::2eea:7fff:fef9:c164/64 scope link
valid_lft forever preferred_lft forever
149: bond0.1@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP group default qlen 1000
link/ether 2c:ea:7f:f9:c1:64 brd ff:ff:ff:ff:ff:ff
150: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 2c:ea:7f:f9:c1:64 brd ff:ff:ff:ff:ff:ff
inet 10.100.0.10/16 brd 10.100.255.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::2eea:7fff:fef9:c164/64 scope link
valid_lft forever preferred_lft forever
154: vethVHW4Q0@if153: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP group default qlen 1000
link/ether fe:ca:6d:9a:bd:52 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::fcca:6dff:fe9a:bd52/64 scope link
valid_lft forever preferred_lft forever
156: veth18FPNW@if155: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP group default qlen 1000
link/ether fe:95:73:99:33:f3 brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet6 fe80::fc95:73ff:fe99:33f3/64 scope link
valid_lft forever preferred_lft forever
158: vethLN0OMY@if157: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP group default qlen 1000
link/ether fe:dc:1e:7d:87:3c brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet6 fe80::fcdc:1eff:fe7d:873c/64 scope link
valid_lft forever preferred_lft forever
160: vethJ191X8@if159: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP group default qlen 1000
link/ether fe:e7:c9:58:2f:92 brd ff:ff:ff:ff:ff:ff link-netnsid 2
inet6 fe80::fce7:c9ff:fe58:2f92/64 scope link
valid_lft forever preferred_lft forever
162: vethB888VF@if161: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br0 state LOWERLAYERDOWN group default qlen 1000
link/ether fe:bf:39:24:fc:a5 brd ff:ff:ff:ff:ff:ff link-netnsid 3
(bridges have been renamed br_local
->br0
and br_mgmt
->br1
since first comment)
For the time being, I'm just trying to get debops.ifupdown
to manage the previously manual configuration:
---
ifupdown__interface_layout: static
ifupdown__host_interfaces:
'eno1':
allow: hotplug
'eno2':
allow: hotplug
'bond0':
inet: manual
slaves:
- eno1
- eno2
bond_mode: 802.3ad
auto: True
'br0':
inet: static
allow: hotplug
bridge_ports: bond0
bridge_stp: 'no'
bridge_fd: 0
bridge_maxwait: 0
address: >
{{ [ ansible_facts.br0.ipv4.address, ansible_facts.br0.ipv4.netmask ] |
join('/') | ansible.netcommon.ipv4 }}
gateway: "{{ gateways_prod[0] }}"
dns_nameservers: "{{ nameservers_prod }}"
dns_search: "{{ ( [netbase__domain] + [site_domain] ) | unique }}"
auto: True
'bond0.1':
inet: manual
vlan_device: bond0
'br1':
inet: static
allow: hotplug
bridge_ports: bond0.1
bridge_stp: 'no'
bridge_fd: 0
bridge_maxwait: 0
address: >
{{ [ ansible_facts.br1.ipv4.address, ansible_facts.br1.ipv4.netmask ] |
join('/') | ansible.netcommon.ipv4 }}
options: >-
up ip route add
{{ [ ansible_facts.br1.ipv4.network, ansible_facts.br1.ipv4.netmask ] |
join('/') | ansible.netcommon.ipv4 }} dev br1 proto kernel scope
link src {{ ansible_facts.br1.ipv4.address }} table mgmt
up ip route add default via {{ gateways_mgmt[0] }} dev br1 table mgmt
up ip rule add from {{ ansible_facts.br1.ipv4.address }}/32 table mgmt
up ip rule add to {{ ansible_facts.br1.ipv4.address }}/32 table mgmt
auto: True
'bond0.1200':
inet: manual
vlan_device: bond0
'br2':
inet: manual
bridge_ports: bond0.1200
bridge_stp: 'no'
bridge_fd: 0
bridge_maxwait: 0
The configuration is correctly generated by ifupdown
- no issues there. The configs are placed in /etc/network/interfaces.config.d/
, but this is where my issue centers: the task to apply the new configs fails, and the correctly generated config files are not moved to /etc/network/interfaces.d/
. I can't get it to work either as part of the playbook run or when manually running /usr/local/lib/ifupdown-reconfigure-interfaces
.
Looking at the ifupdown-reconfigure-interfaces
script, the failure appears to be here:
# Check what init we are using and bring interface down correctly
interface_down () {
if is_systemd ; then
local -a if_hotplug_interfaces
local -a if_boot_interfaces
local -a systemd_ifup_instances
mapfile -t if_hotplug_interfaces < <(ifquery --list --allow=hotplug)
mapfile -t if_boot_interfaces < <(ifquery --list --allow=boot)
mapfile -t systemd_ifup_instances < <(systemctl list-units --no-legend --state=active 'ifup@*.service' | awk '{print $1}' | sed -e 's/^ifup\@//' -e 's/\.service$//')
if [ ${#if_hotplug_interfaces[@]} -gt 0 ] && containsElement "${1}" "${if_hotplug_interfaces[@]}" ; then
systemctl stop "ifup@${1}.service"
elif [ ${#if_boot_interfaces[@]} -gt 0 ] && containsElement "${1}" "${if_boot_interfaces[@]}" ; then
if [ ${#if_hotplug_interfaces[@]} -gt 0 ] && [ ${#systemd_ifup_instances[@]} -gt 0 ] && containsElement "${1}" "${systemd_ifup_instances[@]}" ; then
systemctl stop "ifup@${1}.service"
else
systemctl stop "iface@${1}.service"
fi
fi
else
ifdown "${1}"
fi
}
is_systemd
evaluates as true, but there are no active ifup@*.service
units on the system:
root@thor:~# systemctl list-units --all 'ifup@*.service'
0 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
So the script always fails when bringing down the interfaces.
Bringing the interfaces up and down with ifup
and ifdown
works fine, but ifupdown-reconfigure-interfaces
will only try that on non-systemd systems. I'm guessing I'm supposed to have those systemd units active, but they're not active.
If there are not ifup@*.service
units, it probably means that this host network is managed by NetworkManager or other service. It would be a good idea to find out what manages them before we mess up further.
How did you install it, via Debian Installer directly, or is it some kind of VPS deployed from a prepared image? With Debian Installer and just a base install I get a host managed with ifupdown
with corresponding ifup@.service
unit. If the installation method was different (or even if it's say, a Vagrant box), your host might be managed by systemd-networkd
. In that case switching to ifupdown
might need to be more involved.
We can of course fix this in the ifupdown-reconfigure-interfaces
script, but it needs to know how to stop the existing interfaces first correctly. Knowing what manages them will help.
This is a a pretty default install. It's a Dell PowerEdge R7515, installed via the netinst ISO mounted as virtual media over iDRAC.
I installed manually, didn't select any tasks other than web-server
and ssh-server
. Wouldn't knowingly install NeworkManager on a server, and no netplan either:
root@thor:~# dpkg -s network-manager
dpkg-query: package 'network-manager' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
root@thor:~# dpkg -s netplan.io
dpkg-query: package 'netplan.io' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
root@thor:~# dpkg -s networkd-dispatcher
dpkg-query: package 'networkd-dispatcher' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
root@thor:~# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-networkd.service(8)
One of my goals has been to keep the host OS as "stock" as possible, and isolate all application-specific stuff to containers. I don't even install Docker directly on the host, but rather nested within LXC containers.
I have just noticed something interesting, although i don't know what to make of it.
After a fresh reboot:
root@thor:~# ip l | grep UP
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: idrac: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
5: eno1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
6: eno2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
7: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
9: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
10: bond0.1@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP mode DEFAULT group default qlen 1000
11: br_guest: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
12: lxcbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
14: vethM6PHY8@if13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
16: vethXGJQ6S@if15: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP mode DEFAULT group default qlen 1000
18: vethD622GR@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP mode DEFAULT group default qlen 1000
20: vethOIOUNF@if19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP mode DEFAULT group default qlen 1000
root@thor:~# systemctl list-units --all 'ifup@*.service'
0 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
All interfaces are up, but no ifup@ units loaded.
But if I tell systemd to bring up an already-active interface:
root@thor:~# systemctl start 'ifup@bond0'
root@thor:~# echo $?
0
root@thor:~# systemctl list-units --all 'ifup@*.service'
UNIT LOAD ACTIVE SUB DESCRIPTION
ifup@bond0.service loaded active exited ifup for bond0
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
1 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
Now systemd is aware of that interface.
So I guess the question becomes: why isn't this happening automatically?
Note: systemd doesn't like something about some of the interfaces - bond0.1
is working, but the manual systemctl probe doesn't result in success:
root@thor:~# systemctl start 'ifup@bond0.1'
root@thor:~# systemctl list-units --all 'ifup@*.service'
UNIT LOAD ACTIVE SUB DESCRIPTION
● ifup@bond0.1.service loaded failed failed ifup for bond0.1
ifup@bond0.service loaded active exited ifup for bond0
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
2 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
root@thor:~# systemctl status 'ifup@bond0.1'
● ifup@bond0.1.service - ifup for bond0.1
Loaded: loaded (/lib/systemd/system/ifup@.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2021-09-10 15:16:09 CEST; 10min ago
Process: 7329 ExecStart=/bin/sh -ec ifup --allow=hotplug bond0.1; ifquery --state bond0.1 (code=exited, status=1/FAIL
Main PID: 7329 (code=exited, status=1/FAILURE)
Sep 10 15:16:09 thor systemd[1]: Started ifup for bond0.1.
Sep 10 15:16:09 thor systemd[1]: ifup@bond0.1.service: Main process exited, code=exited, status=1/FAILURE
Sep 10 15:16:09 thor systemd[1]: ifup@bond0.1.service: Failed with result 'exit-code'.
From journalctl -xe
:
Sep 10 15:16:09 thor systemd[1]: Started ifup for bond0.1.
-- Subject: A start job for unit ifup@bond0.1.service has finished successfully
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit ifup@bond0.1.service has finished successfully.
--
-- The job identifier is 826.
Sep 10 15:16:09 thor systemd[1]: ifup@bond0.1.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- An ExecStart= process belonging to unit ifup@bond0.1.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Sep 10 15:16:09 thor systemd[1]: ifup@bond0.1.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit ifup@bond0.1.service has entered the 'failed' state with result 'exit-code'.
Here's the original (pre-debops) /etc/network/interfaces
sections for those interfaces:
# Bonding slaves
allow-hotplug eno1
allow-hotplug eno2
# The primary network interface
auto bond0
iface bond0 inet manual
slaves eno1 eno2
bond-mode 802.3ad
iface bond0.1 inet manual
vlan-raw-device bond0
If those ifup@
units activated automatically, then the logic in ifupdown-reconfigure-interfaces
would work just fine.
Hi! I really appreciate the debops project! :-) I've done my best to exclude errors on my part, but as best as I can tell, the
ifupdown-reconfigure-interfaces
can never successfully reconfigure interfaces on my Debian Buster system.The scenario: A baremetal server with some LXC containers running on it, interfaces are configured statically. The
ifupdown
role will generate the interface configs in/etc/network/interface.config.d/
but the task to apply the new configs always fails.From looking at the script, it seems the issue revolves around the assumption that systemd-based systems always have
ifup@${if}.service
units to control their network interfaces... my system is systemd-based, but has no such units, either on host or in containers.For the sake of sparing the baremetal host a lot of mucking around with the network, I've done most of my testing with a test container, but the behavior is the same when applied against the host:
Relevant hostvars:
Filesystem state after run:
To attempt to manually apply, I restore the /etc/network/interfaces file, and run with:
debops -l test1 --tags "role::ifupdown" --extra-vars "ifupdown__reconfigure_auto=False"
After the run, on the container:
This is a systemd-based system:
But there are no
ifup@${if}.service
units:So it seems to me that
interface_down()
will always fail to stop any interfaces.There is nothing particularly unusual about my install that I can think of which make networking behave radically different. Am I missing something obvious?
Here's some output from the baremetal host:
Note: I have manually moved the interface configs from
interfaces.config.d/
tointerfaces.d/
to activate them.What's so strange about my setup that it breaks the script assumptions?