mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
83 lines
2.4 KiB
YAML
83 lines
2.4 KiB
YAML
|
---
|
||
|
- name: Generate the awx.awx collection
|
||
|
hosts: localhost
|
||
|
connection: local
|
||
|
gather_facts: False
|
||
|
vars:
|
||
|
api_url: "{{ lookup('env', 'TOWER_HOST') }}"
|
||
|
vars_files:
|
||
|
- vars/generate_for.yml
|
||
|
- vars/aliases.yml
|
||
|
- vars/examples.yml
|
||
|
module_defaults:
|
||
|
uri:
|
||
|
validate_certs: False
|
||
|
force_basic_auth: True
|
||
|
url_username: "{{ lookup('env', 'TOWER_USERNAME') }}"
|
||
|
url_password: "{{ lookup('env', 'TOWER_PASSWORD') }}"
|
||
|
|
||
|
tasks:
|
||
|
- name: Get date time data
|
||
|
setup:
|
||
|
gather_subset: min
|
||
|
|
||
|
- name: Create module directory
|
||
|
file:
|
||
|
state: directory
|
||
|
name: "modules"
|
||
|
|
||
|
- name: Load api/v2
|
||
|
uri:
|
||
|
method: GET
|
||
|
url: "{{ api_url }}/api/v2/"
|
||
|
register: endpoints
|
||
|
|
||
|
- name: Load endpoint options
|
||
|
uri:
|
||
|
method: "OPTIONS"
|
||
|
url: "{{ api_url }}{{ item.value }}"
|
||
|
loop: "{{ endpoints['json'] | dict2items }}"
|
||
|
loop_control:
|
||
|
label: "{{ item.key }}"
|
||
|
register: end_point_options
|
||
|
when: "generate_for is not defined or item.key in generate_for"
|
||
|
|
||
|
- name: Scan POST options for different things
|
||
|
set_fact:
|
||
|
all_options: "{{ all_options | default({}) | combine(options[0]) }}"
|
||
|
loop: "{{ end_point_options.results }}"
|
||
|
vars:
|
||
|
options: "{{ item | json_query('json.actions.POST.[*]') }}"
|
||
|
loop_control:
|
||
|
label: "{{ item['item']['key'] }}"
|
||
|
when:
|
||
|
- item is not skipped
|
||
|
- options is defined
|
||
|
|
||
|
- name: Process endpoint
|
||
|
template:
|
||
|
src: "templates/tower_module.j2"
|
||
|
dest: "modules/{{ file_name }}"
|
||
|
loop: "{{ end_point_options['results'] }}"
|
||
|
loop_control:
|
||
|
label: "{{ item['item']['key'] }}"
|
||
|
when: "'json' in item and 'actions' in item['json'] and 'POST' in item['json']['actions']"
|
||
|
vars:
|
||
|
item_type: "{{ item['item']['key'] }}"
|
||
|
human_readable: "{{ item_type | replace('_', ' ') }}"
|
||
|
singular_item_type: "{{ item['item']['key'] | regex_replace('ies$', 'y') | regex_replace('s$', '') }}"
|
||
|
file_name: "tower_{% if item['item']['key'] in ['settings'] %}{{ item['item']['key'] }}{% else %}{{ singular_item_type }}{% endif %}.py"
|
||
|
type_map:
|
||
|
bool: 'bool'
|
||
|
boolean: 'bool'
|
||
|
choice: 'str'
|
||
|
datetime: 'str'
|
||
|
id: 'str'
|
||
|
int: 'int'
|
||
|
integer: 'int'
|
||
|
json: 'dict'
|
||
|
list: 'list'
|
||
|
object: 'dict'
|
||
|
password: 'str'
|
||
|
string: 'str'
|