Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to fileglob loop for yml requirement locations #9945

Merged
merged 2 commits into from
Apr 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions awx/playbooks/project_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,17 @@
tasks:

- block:
- name: detect roles/requirements.(yml/yaml)
stat:
path: "{{project_path|quote}}/roles/requirements{{ item.ext }}"
with_items: "{{ yaml_exts }}"
register: doesRequirementsExist

- name: fetch galaxy roles from requirements.(yml/yaml)
command: >
ansible-galaxy role install -r {{ item.stat.path }}
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}}"
register: galaxy_result
with_items: "{{ doesRequirementsExist.results }}"
when: item.stat.exists
with_fileglob:
- "{{project_path|quote}}/roles/requirements.yaml"
- "{{project_path|quote}}/roles/requirements.yml"
changed_when: "'was installed successfully' in galaxy_result.stdout"
environment:
ANSIBLE_FORCE_COLOR: false
Expand All @@ -187,22 +182,19 @@
- install_roles

- block:
- name: detect collections/requirements.(yml/yaml)
stat:
path: "{{project_path|quote}}/collections/requirements{{ item.ext }}"
with_items: "{{ yaml_exts }}"
register: doesCollectionRequirementsExist

- name: fetch galaxy collections from collections/requirements.(yml/yaml)
command: >
ansible-galaxy collection install -r {{ item.stat.path }}
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_items: "{{ doesCollectionRequirementsExist.results }}"
when: item.stat.exists
with_fileglob:
- "{{project_path|quote}}/collections/requirements.yaml"
- "{{project_path|quote}}/collections/requirements.yml"
- "{{project_path|quote}}/requirements.yaml"
- "{{project_path|quote}}/requirements.yml"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geerlingguy with #106 in mind, am I getting hotter or colder?

Did Ansible itself roll out a combined ansible-galaxy install command that handled both collections and roles? If it did, then using that for the top-level requirements would be preferable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was thinking about ansible/ansible#67843 by @jborean93

and after reading back over that, I believe there's nothing we can really use from it. We still support Ansible 2.9 (which doesn't have the combined command), and we have to specify the roles path, which isn't compatible with the combined roles & collections install command.

So I think this answers the question for me - we have to keep using ansible-galaxy role/collection install forever.

Now I'm questioning if we should install roles from {{project_path|quote}}/requirements.yaml or not.

changed_when: "'Installing ' in galaxy_collection_result.stdout"
environment:
ANSIBLE_FORCE_COLOR: false
Expand Down