Simplify build loop, make demo data in tests

This commit is contained in:
AlanCoding 2020-03-04 13:53:06 -05:00
parent 4fcd2c594c
commit c073e39c69
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B
2 changed files with 33 additions and 11 deletions

View File

@ -10,22 +10,17 @@
tasks:
- name: Do file content replacements for non-default namespace or package name
block:
- name: Find all module files
find:
paths: "{{ playbook_dir }}/plugins/modules"
patterns: "*.py"
register: module_files
- name: Change files to support desired namespace and package names
- name: Change module doc_fragments to support desired namespace and package names
replace:
path: "{{ item.path }}"
path: "{{ item }}"
regexp: '^extends_documentation_fragment: awx.awx.auth$'
replace: 'extends_documentation_fragment: {{ collection_namespace }}.{{ collection_package }}.auth'
loop: "{{ module_files.files }}"
with_fileglob: "{{ playbook_dir }}/plugins/modules/tower_*.py"
loop_control:
label: "{{ item.path | basename }}"
label: "{{ item | basename }}"
- name: Change files to support desired namespace and package names
- 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$"
@ -34,4 +29,7 @@
- (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
template:
src: "{{ playbook_dir }}/galaxy.yml.j2"
dest: "{{ playbook_dir }}/galaxy.yml"
force: true

View File

@ -0,0 +1,24 @@
---
- name: Assure that default organization exists
tower_organization:
name: Default
- name: Assure that demo project exists
tower_project:
name: "Demo Project"
scm_type: 'git'
scm_url: 'https://github.com/ansible/ansible-tower-samples'
scm_update_on_launch: true
organization: Default
- name: Assure that demo inventory exists
tower_inventory:
name: "Demo Inventory"
organization: Default
- name: Assure that demo job template exists
tower_job_template:
name: "Demo Job Template"
project: "Demo Project"
inventory: "Demo Inventory"
playbook: "hello_world.yml"