1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Avoid applying galaxy settings if no user settings exist (#4262)

This commit is contained in:
Alan Rominger 2020-04-27 16:15:11 -04:00 committed by GitHub
parent e1cedcfb04
commit 41014e62b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 14 deletions

View File

@ -2074,29 +2074,34 @@ class RunProjectUpdate(BaseTask):
if settings.GALAXY_IGNORE_CERTS: if settings.GALAXY_IGNORE_CERTS:
env['ANSIBLE_GALAXY_IGNORE'] = True env['ANSIBLE_GALAXY_IGNORE'] = True
# Set up the public Galaxy server, if enabled # Set up the public Galaxy server, if enabled
galaxy_configured = False
if settings.PUBLIC_GALAXY_ENABLED: if settings.PUBLIC_GALAXY_ENABLED:
galaxy_servers = [settings.PUBLIC_GALAXY_SERVER] galaxy_servers = [settings.PUBLIC_GALAXY_SERVER] # static setting
else: else:
galaxy_configured = True
galaxy_servers = [] galaxy_servers = []
# Set up fallback Galaxy servers, if configured # Set up fallback Galaxy servers, if configured
if settings.FALLBACK_GALAXY_SERVERS: if settings.FALLBACK_GALAXY_SERVERS:
galaxy_configured = True
galaxy_servers = settings.FALLBACK_GALAXY_SERVERS + galaxy_servers galaxy_servers = settings.FALLBACK_GALAXY_SERVERS + galaxy_servers
# Set up the primary Galaxy server, if configured # Set up the primary Galaxy server, if configured
if settings.PRIMARY_GALAXY_URL: if settings.PRIMARY_GALAXY_URL:
galaxy_configured = True
galaxy_servers = [{'id': 'primary_galaxy'}] + galaxy_servers galaxy_servers = [{'id': 'primary_galaxy'}] + galaxy_servers
for key in GALAXY_SERVER_FIELDS: for key in GALAXY_SERVER_FIELDS:
value = getattr(settings, 'PRIMARY_GALAXY_{}'.format(key.upper())) value = getattr(settings, 'PRIMARY_GALAXY_{}'.format(key.upper()))
if value: if value:
galaxy_servers[0][key] = value galaxy_servers[0][key] = value
for server in galaxy_servers: if galaxy_configured:
for key in GALAXY_SERVER_FIELDS: for server in galaxy_servers:
if not server.get(key): for key in GALAXY_SERVER_FIELDS:
continue if not server.get(key):
env_key = ('ANSIBLE_GALAXY_SERVER_{}_{}'.format(server.get('id', 'unnamed'), key)).upper() continue
env[env_key] = server[key] env_key = ('ANSIBLE_GALAXY_SERVER_{}_{}'.format(server.get('id', 'unnamed'), key)).upper()
if galaxy_servers: env[env_key] = server[key]
# now set the precedence of galaxy servers if galaxy_servers:
env['ANSIBLE_GALAXY_SERVER_LIST'] = ','.join([server.get('id', 'unnamed') for server in galaxy_servers]) # now set the precedence of galaxy servers
env['ANSIBLE_GALAXY_SERVER_LIST'] = ','.join([server.get('id', 'unnamed') for server in galaxy_servers])
return env return env
def _build_scm_url_extra_vars(self, project_update): def _build_scm_url_extra_vars(self, project_update):

View File

@ -136,9 +136,9 @@
register: doesRequirementsExist register: doesRequirementsExist
- name: fetch galaxy roles from requirements.yml - name: fetch galaxy roles from requirements.yml
command: ansible-galaxy install -r requirements.yml -p {{roles_destination|quote}}{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }} command: ansible-galaxy install -r roles/requirements.yml -p {{roles_destination|quote}}{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }}
args: args:
chdir: "{{project_path|quote}}/roles" chdir: "{{project_path|quote}}"
register: galaxy_result register: galaxy_result
when: doesRequirementsExist.stat.exists when: doesRequirementsExist.stat.exists
changed_when: "'was installed successfully' in galaxy_result.stdout" changed_when: "'was installed successfully' in galaxy_result.stdout"
@ -157,9 +157,9 @@
register: doesCollectionRequirementsExist register: doesCollectionRequirementsExist
- name: fetch galaxy collections from collections/requirements.yml - name: fetch galaxy collections from collections/requirements.yml
command: ansible-galaxy collection install -r requirements.yml -p {{collections_destination|quote}}{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }} command: ansible-galaxy collection install -r collections/requirements.yml -p {{collections_destination|quote}}{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }}
args: args:
chdir: "{{project_path|quote}}/collections" chdir: "{{project_path|quote}}"
register: galaxy_collection_result register: galaxy_collection_result
when: doesCollectionRequirementsExist.stat.exists when: doesCollectionRequirementsExist.stat.exists
changed_when: "'Installing ' in galaxy_collection_result.stdout" changed_when: "'Installing ' in galaxy_collection_result.stdout"