Closed handcraftedcomputers closed 1 year ago
So, poking at this further (as such is my wont), it appears that patching distro._UNIXCONFDIR
as pyinfra currently does breaks the result of distro.LinuxDistribution()
since at least distro v1.6.0 when the root_dir
named parameter was introduced. With the attached test script, you can see the difference in the return result (using the files returned by Centos 6 fact retrieval) when using the patched distro._UNIXCONFDIR variable versus using the named root_dir parameter. The fix is relatively simple, but I'm not sure what (if anything) this would break. At a bare minimum, distro would need to be pinned >= 1.6.0 for the root_dir named parameter to work, but given that the distro package was moved subordinate to distro in v1.7.0 (i.e. from distro import distro) this would need to be done anyway.
new_rootdir_distro:
{'id': 'centos',
'major': 6,
'minor': 10,
'name': 'CentOS',
'release_meta': {}}
old_rootdir_distro:
{'id': 'debian',
'major': 11,
'minor': None,
'name': 'Debian '
'GNU/Linux',
'release_meta': {'BUG_REPORT_URL': 'https://bugs.debian.org/',
'CODENAME': 'bullseye',
'HOME_URL': 'https://www.debian.org/',
'ID': 'debian',
'NAME': 'Debian '
'GNU/Linux',
'PRETTY_NAME': 'Debian '
'GNU/Linux '
'11 '
'(bullseye)',
'SUPPORT_URL': 'https://www.debian.org/support',
'VERSION': '11 '
'(bullseye)',
'VERSION_CODENAME': 'bullseye',
'VERSION_ID': '11'}}
Thank you for digging into this @handcraftedcomputers - indeed it looks like there's another variable that needs patching to cover this, but I think it's a good time to bump the minimum version up to 1.6 and remove the patching hack entirely.
Describe the bug
This could be a me issue (I am a neophyte to pyinfra). I have several "older Linux distributions" under my care. When running
pyinfra inventory.py fact server.LinuxDistribution
, the facts returned for these servers match the host I'm running pyinfra from, not the target. Although the files appear to be returned successfully, the distro module is unable to interpret correctly (see the following output):The result should definitely not be Debian 11 for a Centos 6 and Ubuntu 9.04 (I did say they were old) servers. While I'm not expecting facts to necessarily identify these older servers, defaulting to the underlying host's OS is unexpected behaviour.
To Reproduce
$ pyinfra inventory.py fact server.LinuxDistribution
(where inventory.py points to a couple of archaic distributions).
Host is an up to date Debian 11 laptop.
Expected behavior
Either undefined (if distro module was unable to find an appropriate match), or the appropriate response.
Meta
Include output of
pyinfra --support
.How was pyinfra installed (source/pip)? Via pip in venv.
Consider including output with
-vv
and--debug
. As noted aboveAdditional info Version of distro is v1.8.0. Output captured while debugging from distro's return result (note: showing os_release_file pointing inappropriately to the localhost's
/usr/lib/os-release
):