--- - name: Step 0000 - Install Galaxy roles hosts: localhost connection: local gather_facts: false become: false vars: # User can override this variable to specify a different requirements.yml, like: # -e requirements_path=.../requirements_prod.yml ## PS: ROLE_IMPROVE_TASK ## Needs to be validated ## var is called from main.yml requirements_path: "configs/{{ env_type }}/requirements.yml" tasks: - name: Check if requirements.yml exists stat: path: "{{ requirements_path }}" register: r_requirements_stat - set_fact: r_requirements_content: "{{ lookup('file', requirements_path) | from_yaml }}" when: r_requirements_stat.stat.exists - name: Import roles from requirements.yml command: >- ansible-galaxy install -r "{{ requirements_path }}" -p "{{ ANSIBLE_REPO_PATH | default('.') }}/configs/{{ env_type }}/roles" when: >- r_requirements_stat.stat.exists and r_requirements_content | length > 0 and ( r_requirements_content is mapping and 'roles' in r_requirements_content ) or r_requirements_contet is sequence - name: Import collections from requirements.yml command: >- ansible-galaxy collection install -r "{{ requirements_path }}" -p "configs/{{ env_type }}/collections" when: >- r_requirements_stat.stat.exists and r_requirements_content | length > 0 and r_requirements_content is mapping and "collections" in r_requirements_content