-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install dependencies before running component
- Loading branch information
Showing
2 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
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,46 @@ | ||
--- | ||
- name: Check for plugin requirements file | ||
stat: | ||
path: /rsc/plugins/{{ remote_plugin.script_folder | basename }}/requirements.yml | ||
register: register_requirements_1 | ||
|
||
- name: Check for plugin requirements file 2 | ||
stat: | ||
path: /rsc/plugins/{{ remote_plugin.script_folder | basename }}/{{ remote_plugin.path | dirname }}/requirements.yml | ||
register: register_requirements_2 | ||
|
||
- name: Set path to file 1 if it exists | ||
set_fact: | ||
requirements_path: /rsc/plugins/{{ remote_plugin.script_folder | basename }}/requirements.yml | ||
when: register_requirements_1.stat.exists | ||
|
||
- name: Set path to file 2 if file 1 does not exist and file 2 exists | ||
set_fact: | ||
requirements_path: /rsc/plugins/{{ remote_plugin.script_folder | basename }}/{{ remote_plugin.path | dirname }}/requirements.yml | ||
when: not register_requirements_1.stat.exists and register_requirements_2.stat.exists | ||
|
||
- name: Install role dependencies for Ansible plugin | ||
command: | | ||
ansible-galaxy role install -r {{ requirements_path }} -p /rsc/plugins/{{ remote_plugin.script_folder | basename }} | ||
args: | ||
chdir: /rsc/plugins/{{ remote_plugin.script_folder | basename }} | ||
executable: /bin/bash | ||
when: requirements_path is defined | ||
|
||
- name: Install collection dependencies for Ansible plugin | ||
command: | | ||
ansible-galaxy collection install -r {{ requirements_path }} -p /rsc/plugins/{{ remote_plugin.script_folder | basename }}/collections | ||
args: | ||
chdir: /rsc/plugins/{{ remote_plugin.script_folder | basename }} | ||
executable: /bin/bash | ||
when: requirements_path is defined | ||
|
||
- name: Test the component by executing it using ansible on the workspace | ||
Check warning on line 38 in _run_component.yml GitHub Actions / Ansible Lintjinja[spacing]
|
||
ansible.builtin.command: > | ||
ansible-playbook -c local -v -b {{ remote_plugin.arguments }} --extra-vars='{{ remote_plugin.parameters }}' /rsc/plugins/ | ||
{{ remote_plugin.script_folder }}/{{remote_plugin.path }} | ||
register: ansible_on_workspace | ||
changed_when: > | ||
ansible_on_workspace.stdout_lines is not defined or | ||
'changed=0' not in | ||
ansible_on_workspace.stdout_lines[ lookup('ansible.utils.index_of', ansible_on_workspace.stdout_lines, 'regex', '\s*PLAY RECAP\s*')+1 ] |
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