diff options
author | Jordan Borean <jborean93@gmail.com> | 2019-09-05 11:46:44 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-05 11:46:44 +1000 |
commit | 3a7b77a94ce534c502828ebd2959f6fdf9d183f5 (patch) | |
tree | e66c4f0c61bad9119cccca4c6f281c4be032c11f /lib/ansible/galaxy | |
parent | f81b7dd10a674c72659b25be20461865bb997eed (diff) | |
download | ansible-3a7b77a94ce534c502828ebd2959f6fdf9d183f5.tar.gz |
ansible-galaxy fix --server option for roles (#61820)
Diffstat (limited to 'lib/ansible/galaxy')
-rw-r--r-- | lib/ansible/galaxy/__init__.py | 1 | ||||
-rw-r--r-- | lib/ansible/galaxy/role.py | 12 |
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/ansible/galaxy/__init__.py b/lib/ansible/galaxy/__init__.py index 2be986c54c..a73baac888 100644 --- a/lib/ansible/galaxy/__init__.py +++ b/lib/ansible/galaxy/__init__.py @@ -44,6 +44,7 @@ class Galaxy(object): ''' Keeps global galaxy info ''' def __init__(self): + # TODO: eventually remove this as it contains a mismash of properties that aren't really global # roles_path needs to be a list and will be by default roles_path = context.CLIARGS.get('roles_path', C.DEFAULT_ROLES_PATH) diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py index 5cf188eef9..c82a022a52 100644 --- a/lib/ansible/galaxy/role.py +++ b/lib/ansible/galaxy/role.py @@ -31,13 +31,11 @@ import yaml from distutils.version import LooseVersion from shutil import rmtree -import ansible.constants as C from ansible import context from ansible.errors import AnsibleError from ansible.module_utils._text import to_native, to_text from ansible.module_utils.urls import open_url from ansible.playbook.role.requirement import RoleRequirement -from ansible.galaxy.api import GalaxyAPI from ansible.utils.display import Display display = Display() @@ -50,7 +48,7 @@ class GalaxyRole(object): META_INSTALL = os.path.join('meta', '.galaxy_install_info') ROLE_DIRS = ('defaults', 'files', 'handlers', 'meta', 'tasks', 'templates', 'vars', 'tests') - def __init__(self, galaxy, name, src=None, version=None, scm=None, path=None): + def __init__(self, galaxy, api, name, src=None, version=None, scm=None, path=None): self._metadata = None self._install_info = None @@ -59,6 +57,7 @@ class GalaxyRole(object): display.debug('Validate TLS certificates: %s' % self._validate_certs) self.galaxy = galaxy + self.api = api self.name = name self.version = version @@ -205,17 +204,16 @@ class GalaxyRole(object): role_data = self.src tmp_file = self.fetch(role_data) else: - api = GalaxyAPI(self.galaxy, 'role_default', C.GALAXY_SERVER) - role_data = api.lookup_role_by_name(self.src) + role_data = self.api.lookup_role_by_name(self.src) if not role_data: - raise AnsibleError("- sorry, %s was not found on %s." % (self.src, api.api_server)) + raise AnsibleError("- sorry, %s was not found on %s." % (self.src, self.api.api_server)) if role_data.get('role_type') == 'APP': # Container Role display.warning("%s is a Container App role, and should only be installed using Ansible " "Container" % self.name) - role_versions = api.fetch_role_related('versions', role_data['id']) + role_versions = self.api.fetch_role_related('versions', role_data['id']) if not self.version: # convert the version names to LooseVersion objects # and sort them to get the latest version. If there |