awx/awx_collection/template_galaxy.yml
2020-05-15 09:24:43 -04:00

48 lines
1.9 KiB
YAML

---
- hosts: localhost
gather_facts: false
connection: local
vars:
collection_package: awx
collection_namespace: awx
collection_version: 0.0.1 # not for updating, pass in extra_vars
tasks:
- name: Set the collection version in the tower_api.py file
replace:
path: "{{ playbook_dir }}/plugins/module_utils/tower_api.py"
regexp: '^ _COLLECTION_VERSION =.*'
replace: ' _COLLECTION_VERSION = "{{ collection_version }}"'
- name: Set the collection type in the tower_api.py file
replace:
path: "{{ playbook_dir }}/plugins/module_utils/tower_api.py"
regexp: '^ _COLLECTION_TYPE =.*'
replace: ' _COLLECTION_TYPE = "{{ collection_namespace }}"'
- name: Do file content replacements for non-default namespace or package name
block:
- name: Change module doc_fragments to support desired namespace and package names
replace:
path: "{{ item }}"
regexp: '^extends_documentation_fragment: awx.awx.auth$'
replace: 'extends_documentation_fragment: {{ collection_namespace }}.{{ collection_package }}.auth'
with_fileglob: "{{ playbook_dir }}/plugins/modules/tower_*.py"
loop_control:
label: "{{ item | basename }}"
- name: Change inventory file to support desired namespace and package names
replace:
path: "{{ playbook_dir }}/plugins/inventory/tower.py"
regexp: "^ NAME = 'awx.awx.tower' # REPLACE$"
replace: " NAME = '{{ collection_namespace }}.{{ collection_package }}.tower' # REPLACE"
when:
- (collection_package != 'awx') or (collection_namespace != 'awx')
- name: Template the galaxy.yml file
template:
src: "{{ playbook_dir }}/galaxy.yml.j2"
dest: "{{ playbook_dir }}/galaxy.yml"
force: true