Fix isinstance check (#79159)

Use GalaxyAPI for isinstance check instead of RoleDistributionServer, since the latter is defined in __main__ sometimes (when running integration tests or ansible-galaxy from source) and importing from ansible.cli.galaxy won't reference the same object.
pull/79161/head
Sloane Hertel 2 years ago committed by GitHub
parent 5b04dff7bd
commit 89d682464b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,6 +33,7 @@ from shutil import rmtree
from ansible import context
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.galaxy.api import GalaxyAPI
from ansible.galaxy.user_agent import user_agent
from ansible.module_utils._text import to_native, to_text
from ansible.module_utils.common.yaml import yaml_dump, yaml_load
@ -105,9 +106,7 @@ class GalaxyRole(object):
@property
def api(self):
# prevent recursive imports
from ansible.cli.galaxy import RoleDistributionServer
if isinstance(self._api, RoleDistributionServer):
if not isinstance(self._api, GalaxyAPI):
return self._api.api
return self._api

@ -1,3 +1,6 @@
- name: Install role from Galaxy (should not fail with AttributeError)
command: ansible-galaxy role install ansible.nope -vvvv --ignore-errors
- name: Archive directories
file:
state: directory

Loading…
Cancel
Save