diff --git a/changelogs/fragments/ansible-test-target-filter.yml b/changelogs/fragments/ansible-test-target-filter.yml new file mode 100644 index 00000000000..e0af07752f1 --- /dev/null +++ b/changelogs/fragments/ansible-test-target-filter.yml @@ -0,0 +1,5 @@ +bugfixes: + - ansible-test - Correctly detect when running as the ``root`` user (UID 0) on the origin host. + The result of the detection was incorrectly being inverted. + - ansible-test - Fix skipping of tests marked ``needs/root`` on the origin host. + - ansible-test - Fix skipping of tests marked ``needs/python`` on the origin host. diff --git a/test/lib/ansible_test/_internal/commands/integration/filters.py b/test/lib/ansible_test/_internal/commands/integration/filters.py index 9854de57c6a..0396ce9231a 100644 --- a/test/lib/ansible_test/_internal/commands/integration/filters.py +++ b/test/lib/ansible_test/_internal/commands/integration/filters.py @@ -221,7 +221,7 @@ class NetworkInventoryTargetFilter(TargetFilter[NetworkInventoryConfig]): """Target filter for network inventory.""" -class OriginTargetFilter(TargetFilter[OriginConfig]): +class OriginTargetFilter(PosixTargetFilter[OriginConfig]): """Target filter for localhost.""" diff --git a/test/lib/ansible_test/_internal/host_configs.py b/test/lib/ansible_test/_internal/host_configs.py index 720385f734d..fee741e8b97 100644 --- a/test/lib/ansible_test/_internal/host_configs.py +++ b/test/lib/ansible_test/_internal/host_configs.py @@ -419,7 +419,7 @@ class OriginConfig(ControllerHostConfig, PosixConfig): @property def have_root(self): # type: () -> bool """True if root is available, otherwise False.""" - return os.getuid() != 0 + return os.getuid() == 0 @dataclasses.dataclass