Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support of export single project/workflow/job #836

Merged
merged 14 commits into from
Jun 13, 2024
3 changes: 3 additions & 0 deletions roles/filetree_create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ The following variables are required for that role to work properly:
| `controller_api_plugin` | `ansible.controller` | yes | str | Full path for the controller_api_plugin to be used. <br/> Can have two possible values: <br/>&nbsp;&nbsp;- awx.awx.controller_api # For the community Collection version <br/>&nbsp;&nbsp;- ansible.controller.controller_api # For the Red Hat Certified Collection version|
| `organization_filter` | N/A | no | str | Exports only the objects belonging to the specified organization (applies to all the objects that can be assigned to an organization). |
| `organization_id` | N/A | no | int | Alternative to `organization_filter`, but specifiying the current organization's ID to filter by. Exports only the objects belonging to the specified organization (applies to all the objects that can be assigned to an organization). |
| `project_id` | N/A | no | int | Specifiying the project id to filter by. Exports the project belonging to the specified organization. |
| `job_template_id` | N/A | no | int | Specifiying the job template id to filter by. Exports the job template belonging to the specified organization. |
| `workflow_job_template_id` | N/A | no | int | Specifiying the workflow job template id to filter by. Exports the workflow job template belonging to the specified organization. |
| `output_path` | `/tmp/filetree_output` | yes | str | The path to the output directory where all the generated `yaml` files with the corresponding Objects as code will be written to. |
| `input_tag` | `['all']` | no | List of Strings | The tags which are applied to the 'sub-roles'. If 'all' is in the list (the default value) then all roles will be called. Valid tags include ['all', 'labels', 'applications', 'instance_groups', 'settings', 'inventory', 'credentials', 'credential_types', 'notification_templates', 'users', 'teams', 'roles', 'organizations', 'projects', 'execution_environments', 'job_templates', 'workflow_job_templates', 'workflow_job_template_nodes', 'schedules'] |
| `flatten_output` | N/A | no | bool | Whether to flatten the output in single files per each object type instead of the normal exportation structure |
Expand Down
6 changes: 4 additions & 2 deletions roles/filetree_create/tasks/job_templates.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
- name: "Get current Job Templates from the API"
ansible.builtin.set_fact:
job_templates_lookvar: "{{ query(controller_api_plugin, 'api/v2/job_templates/',
query_params=(query_params | combine({'organization': organization_id})) if organization_id is defined else query_params,
job_templates_lookvar: "{{ query(controller_api_plugin, 'api/v2/job_templates/'
ivarmu marked this conversation as resolved.
Show resolved Hide resolved
query_params=(query_params | combine({'organization': organization_id} if organization_id is defined else {},
{'project_id': project_id} if project_id is defined else {},
{'id': job_template_id} if job_template_id is defined else {})),
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"
Expand Down
6 changes: 4 additions & 2 deletions roles/filetree_create/tasks/projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
- name: "Get current Projects from the API"
ansible.builtin.set_fact:
projects_lookvar: "{{ query(controller_api_plugin, 'api/v2/projects/',
query_params=(query_params | combine({'organization': organization_id})) if organization_id is defined else query_params,
query_params=(query_params | combine({'organization': organization_id} if organization_id is defined else {},
{'id': project_id} if project_id is defined else {},
{'name': project_name} if project_name is defined else {})),
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"
}}"
ivarmu marked this conversation as resolved.
Show resolved Hide resolved
vars:
query_params:
order_by: 'organization,id'
Expand Down
4 changes: 3 additions & 1 deletion roles/filetree_create/tasks/workflow_job_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
- name: "Get current Workflow Job Templates from the API"
ansible.builtin.set_fact:
workflow_job_templates_lookvar: "{{ query(controller_api_plugin, 'api/v2/workflow_job_templates/',
query_params=(query_params | combine({'organization': organization_id})) if organization_id is defined else query_params,
query_params=(query_params | combine({'organization': organization_id} if organization_id is defined else {},
{'project_id': project_id} if project_id is defined else {},
ivarmu marked this conversation as resolved.
Show resolved Hide resolved
{'id': workflow_job_template_id} if workflow_job_template_id is defined else {})),
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"
Expand Down