forked from ansible/ansible
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit Galaxy API calls during ansible-galaxy dependency resolution (a…
…nsible#77468) * Limit Galaxy API calls during ansible-galaxy collection dependency resolution when possible Installing a tarfile with a dependency from a Galaxy server (e.g. dependencies: {'ns.coll': '>=1.0.0'}) does not get the available versions of the dependency from the galaxy server if a sufficient version is already installed. Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
- Loading branch information
Showing
4 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
changelogs/fragments/77468-ansible-galaxy-remove-unnecessary-api-call.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bugfixes: | ||
- >- | ||
``ansible-galaxy`` - remove extra server api call during dependency resolution | ||
for requirements and dependencies that are already satisfied | ||
(https://github.com/ansible/ansible/issues/77443). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
- set_fact: | ||
init_dir: "{{ galaxy_dir }}/offline/setup" | ||
build_dir: "{{ galaxy_dir }}/offline/build" | ||
install_dir: "{{ galaxy_dir }}/offline/collections" | ||
|
||
- name: create test directories | ||
file: | ||
path: "{{ item }}" | ||
state: directory | ||
loop: | ||
- "{{ init_dir }}" | ||
- "{{ build_dir }}" | ||
- "{{ install_dir }}" | ||
|
||
- name: test installing a tarfile with an installed dependency offline | ||
block: | ||
- name: init two collections | ||
command: ansible-galaxy collection init ns.{{ item }} --init-path {{ init_dir }} | ||
loop: | ||
- coll1 | ||
- coll2 | ||
|
||
- name: add one collection as the dependency of the other | ||
lineinfile: | ||
path: "{{ galaxy_dir }}/offline/setup/ns/coll1/galaxy.yml" | ||
regexp: "^dependencies:*" | ||
line: "dependencies: {'ns.coll2': '1.0.0'}" | ||
|
||
- name: build both collections | ||
command: ansible-galaxy collection build {{ init_dir }}/ns/{{ item }} | ||
args: | ||
chdir: "{{ build_dir }}" | ||
loop: | ||
- coll1 | ||
- coll2 | ||
|
||
- name: install the dependency from the tarfile | ||
command: ansible-galaxy collection install {{ build_dir }}/ns-coll2-1.0.0.tar.gz -p {{ install_dir }} -s offline | ||
|
||
- name: install the tarfile with the installed dependency | ||
command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-1.0.0.tar.gz -p {{ install_dir }} -s offline | ||
|
||
always: | ||
- name: clean up test directories | ||
file: | ||
path: "{{ item }}" | ||
state: absent | ||
loop: | ||
- "{{ init_dir }}" | ||
- "{{ build_dir }}" | ||
- "{{ install_dir }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters