diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py index b7bc4077e3d..99bb525e593 100644 --- a/lib/ansible/galaxy/role.py +++ b/lib/ansible/galaxy/role.py @@ -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 diff --git a/test/integration/targets/ansible-galaxy-role/tasks/main.yml b/test/integration/targets/ansible-galaxy-role/tasks/main.yml index e49e4e2958a..03d0b3c2433 100644 --- a/test/integration/targets/ansible-galaxy-role/tasks/main.yml +++ b/test/integration/targets/ansible-galaxy-role/tasks/main.yml @@ -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