diff --git a/changelogs/fragments/filetree_create_filter.yml b/changelogs/fragments/filetree_create_filter.yml new file mode 100644 index 000000000..e80a29ebb --- /dev/null +++ b/changelogs/fragments/filetree_create_filter.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - filetree_create able to filter by project_id, workflow_job_template_id or job_template_id diff --git a/roles/filetree_create/README.md b/roles/filetree_create/README.md index c4a8465aa..4a52e5215 100644 --- a/roles/filetree_create/README.md +++ b/roles/filetree_create/README.md @@ -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.
Can have two possible values:
  - awx.awx.controller_api # For the community Collection version
  - 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 | diff --git a/roles/filetree_create/tasks/job_templates.yml b/roles/filetree_create/tasks/job_templates.yml index 90f7076bf..667d33d2e 100644 --- a/roles/filetree_create/tasks/job_templates.yml +++ b/roles/filetree_create/tasks/job_templates.yml @@ -2,7 +2,9 @@ - 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, + query_params=(query_params | combine({'organization': organization_id} if organization_id is defined else {}, + {'project': 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) }}" diff --git a/roles/filetree_create/tasks/projects.yml b/roles/filetree_create/tasks/projects.yml index 4cf7a838b..8ec460d3b 100644 --- a/roles/filetree_create/tasks/projects.yml +++ b/roles/filetree_create/tasks/projects.yml @@ -2,7 +2,8 @@ - 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 {})), host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs, return_all=true, max_objects=query_controller_api_max_objects) }}" diff --git a/roles/filetree_create/tasks/workflow_job_templates.yml b/roles/filetree_create/tasks/workflow_job_templates.yml index 32e3c56ef..9d87b2809 100644 --- a/roles/filetree_create/tasks/workflow_job_templates.yml +++ b/roles/filetree_create/tasks/workflow_job_templates.yml @@ -2,7 +2,8 @@ - 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 {}, + {'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) }}"