Repository navigation
Description
Description
I want to add a route on a RHEL8.4 system, instead I get a failure about that network.service is not found on RHEL8. I can't find this network.service in the Salt code (quick searches via GitHub). I also don't see how I can override this behavior. It is also quite strange that it does this, as if the OS is not detected properly, or that the wrong conditional is triggered, or that simply the wrong service is called. The documentation also doesn't include more info about it: https://docs.saltproject.io/en/master/ref/states/all/salt.states.network.html#salt.states.network.routes
Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Please be as specific as possible and give set-up details.
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging (RPM install)
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
(Include debug logs if possible and relevant)
The salt state I run.
elk_network:
network.routes:
- name: ens4f0np0
- routes:
- name: elk_cluster
ipaddr: 192.168.0.0
netmask: 255.255.255.224
gateway: 172.18.48.1[ERROR ] Command 'systemd-run' failed with return code: 5
[ERROR ] stderr: Running scope as unit: run-r1d9fd2a20f2e490587cae5966260d944.scope
Failed to restart network.service: Unit network.service not found.
[ERROR ] retcode: 5
[ERROR ] An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/state.py", line 2180, in call
*cdata["args"], **cdata["kwargs"]
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/states/network.py", line 746, in routes
__salt__["ip.apply_network_settings"](**kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/rh_ip.py", line 1253, in apply_network_settings
res = __salt__["service.restart"]("network")
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/systemd_service.py", line 964, in restart
raise CommandExecutionError(_strip_scope(ret["stderr"]))
salt.exceptions.CommandExecutionError: Failed to restart network.service: Unit network.service not found.
local:
----------
ID: elk_network
Function: network.routes
Name: ens4f0np0
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/state.py", line 2180, in call
*cdata["args"], **cdata["kwargs"]
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/states/network.py", line 746, in routes
__salt__["ip.apply_network_settings"](**kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/rh_ip.py", line 1253, in apply_network_settings
res = __salt__["service.restart"]("network")
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/systemd_service.py", line 964, in restart
raise CommandExecutionError(_strip_scope(ret["stderr"]))
salt.exceptions.CommandExecutionError: Failed to restart network.service: Unit network.service not found.
Started: 10:27:28.812661
Duration: 47.008 ms
Changes:
Summary for local
------------
Succeeded: 1
Failed: 1
------------
Total states run: 2
Total run time: 1.172 s
Expected behavior
I expect the route to be added and active after Salt is done.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3004.1
Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: 0.26.8
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.14
pycrypto: Not Installed
pycryptodome: 3.9.7
pygit2: 0.26.4
Python: 3.6.8 (default, Sep 9 2021, 07:49:02)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 19.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: rhel 8.5 Ootpa
locale: UTF-8
machine: x86_64
release: 4.18.0-348.el8.x86_64
system: Linux
version: Red Hat Enterprise Linux 8.5 OotpaAdditional context
Add any other context about the problem here.
Activity
welcome commentedon Oct 10, 2022
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
OrangeDog commentedon Oct 10, 2022
Most networking states don't work properly on most current OS versions.
See also: #13085, #54791
rossengeorgiev commentedon Oct 11, 2022
In RHEL8, and now RHEL9, you should be using NetworkManager manage network configuration. NM can handle the old network-scripts. See #54791 (comment)
You could work around the unmaintained
network.managedstate module by usingfile.managedto generate the config files, which will work on 7/8/9, and thencmd.runto invokenmclito reload and activate networks.kees-closed commentedon Oct 11, 2022
It's possible to install network-scripts, but wouldn't it be much better if Salt supports what RHEL officially supports? I don't really want to install the deprecated network-scripts.
Ikramromdhani commentedon Jan 3, 2025
any updates on this issue, I see the same problem happening on amazonLinux 2023 with 3006
rossengeorgiev commentedon Jan 3, 2025
I wouldn't hold my breath 🤷♂️
dwoz commentedon Jul 1, 2026
Fixed in 3006+ by cd9ac8d (PR #61538, Feb 2022).
rh_ip.apply_network_settingsnow restartsNetworkManageronosmajorrelease >= 8instead of the missingnetworkservice. Reporter was on 3004.1 which predates the fix. Closing.Note: PR #69620 is in flight to also fix the broader
network.managedbreakage on EL8+ via a newnm_ipprovider.Add nm_ip NetworkManager provider for network.managed (saltstack#54791)
Add nm_ip NetworkManager provider for network.managed (#54791)