Skip to content

Commit

Permalink
Allowing for combined roles/collection install during project sync
Browse files Browse the repository at this point in the history
  • Loading branch information
john-westcott-iv committed Jun 28, 2023
1 parent aed96fb commit d431a8e
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions awx/playbooks/project_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
name: Install content with ansible-galaxy command if necessary
vars:
galaxy_task_env: # configure in settings
# This environment variable is used for install roles
ANSIBLE_ROLES_PATH: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_roles"
additional_collections_env:
# These environment variables are used for installing collections, in addition to galaxy_task_env
# setting the collections paths silences warnings
Expand All @@ -212,10 +214,9 @@
- name: End play due to disabled content sync
ansible.builtin.meta: end_play

- name: Fetch galaxy roles from requirements.(yml/yaml)
- name: Fetch galaxy roles from roles/requirements.(yml/yaml)
ansible.builtin.command: >
ansible-galaxy role install -r {{ item }}
--roles-path {{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_roles
{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }}
args:
chdir: "{{ project_path | quote }}"
Expand All @@ -232,20 +233,37 @@
- name: Fetch galaxy collections from collections/requirements.(yml/yaml)
ansible.builtin.command: >
ansible-galaxy collection install -r {{ item }}
--collections-path {{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_collections
{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }}
args:
chdir: "{{ project_path | quote }}"
register: galaxy_collection_result
with_fileglob:
- "{{ project_path | quote }}/collections/requirements.yaml"
- "{{ project_path | quote }}/collections/requirements.yml"
- "{{ project_path | quote }}/requirements.yaml"
- "{{ project_path | quote }}/requirements.yml"
changed_when: "'Installing ' in galaxy_collection_result.stdout"
environment: "{{ additional_collections_env | combine(galaxy_task_env) }}"
when:
- "ansible_version.full is version_compare('2.9', '>=')"
- collections_enabled | bool
tags:
- install_collections

- name: Fetch galaxy roles and collections from requirements.(yml/yaml)
ansible.builtin.command: >
ansible-galaxy install -r {{ item }}
{{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }}
args:
chdir: "{{ project_path | quote }}"
register: galaxy_combined_result
with_fileglob:
- "{{ project_path | quote }}/requirements.yaml"
- "{{ project_path | quote }}/requirements.yml"
changed_when: "'Nothing to do.' not in galaxy_combined_result.stdout"
environment: "{{ additional_collections_env | combine(galaxy_task_env) }}"
when:
- "ansible_version.full is version_compare('2.10', '>=')"
- collections_enabled | bool
- roles_enabled | bool
tags:
- install_collections
- install_roles

0 comments on commit d431a8e

Please sign in to comment.