[BUG] salt-ssh breaks on FreeBSD if IFCONFIG_FORMAT is set to return CIDR
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
salt-ssh does not work on FreeBSD if IFCONFIG_FORMAT is set in such a way as to return CIDR notation instead of netmask notation.
Setup
FreeBSD 14.0
Steps to Reproduce the behavior
This breaks locally, before even talking to any "minions."
IFCONFIG_FORMAT=inet:cidr,inet6:cidr salt-ssh ...
Output:
salt-ssh: error: Error while processing <bound method ConfigDirMixIn.process_config_dir of <salt.cli.ssh.SaltSSH object at 0x2e898649ab50>>: Traceback (most recent call last):
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/parsers.py", line 196, in parse_args
process_option_func()
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/parsers.py", line 570, in process_config_dir
self.config.update(self.setup_config())
^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/parsers.py", line 3406, in setup_config
return config.master_config(self.get_config_file_path())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/config/__init__.py", line 3937, in master_config
opts = apply_master_config(overrides, defaults)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/config/__init__.py", line 4043, in apply_master_config
opts["id"], using_ip_for_id = get_id(opts, cache_minion_id=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/config/__init__.py", line 3658, in get_id
newid = salt.utils.network.generate_minion_id()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/network.py", line 225, in generate_minion_id
ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first())
^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/network.py", line 214, in _generate_minion_id
[addr for addr in ip_addrs() if not ipaddress.ip_address(addr).is_loopback]
^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/network.py", line 1455, in ip_addrs
return _ip_addrs(interface, include_loopback, interface_data, "inet")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/salt/lib/python3.11/site-packages/salt/utils/network.py", line 1442, in _ip_addrs
addr = ipaddress.ip_address(addr.get("address"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ipaddress.py", line 54, in ip_address
raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address')
ValueError: '192.168.1.100/24' does not appear to be an IPv4 or IPv6 address
Expected behavior
It should work as it does normally.
Additional context
https://github.com/freebsd/freebsd-src/pull/1216
It's possible to force ifconfig to use netmasks by setting the environment variable like so: IFCONFIG_FORMAT=inet:hex,inet6:numeric. This may be the easiest fix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/utils/network.py, following _generate_minion_id through ip_addrs and _ip_addrs, and reproduce the failure with IFCONFIG_FORMAT=inet:cidr,inet6:cidr on FreeBSD. The work is done when salt-ssh handles CIDR-formatted addresses without the reported ValueError and the behavior is covered by regression testing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100