From f02fe0e9915d4f0f16d2d40a537ed1ef328673cb Mon Sep 17 00:00:00 2001 From: Przemyslaw Kalitowski Date: Fri, 11 Oct 2024 14:38:46 +0200 Subject: [PATCH] feat: support inventory id --- changelogs/fragments/filetree_create_single_inventory.yaml | 4 ++++ roles/filetree_create/README.md | 1 + roles/filetree_create/tasks/inventory.yml | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/filetree_create_single_inventory.yaml diff --git a/changelogs/fragments/filetree_create_single_inventory.yaml b/changelogs/fragments/filetree_create_single_inventory.yaml new file mode 100644 index 00000000..5e71bc1f --- /dev/null +++ b/changelogs/fragments/filetree_create_single_inventory.yaml @@ -0,0 +1,4 @@ +--- +minor_changes: + - filetree_create able to export single inventory +... diff --git a/roles/filetree_create/README.md b/roles/filetree_create/README.md index 9bca0885..1899c09d 100644 --- a/roles/filetree_create/README.md +++ b/roles/filetree_create/README.md @@ -17,6 +17,7 @@ The following variables are required for that role to work properly: | `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. | +| `inventory_id` | N/A | no | int | Specifiying the inventory id to filter by. Exports the inventory 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. | | `schedule_id` | N/A | no | int | Specifiying the schedule id to filter by. Exports the schedule belonging to the specified object. | | `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. | diff --git a/roles/filetree_create/tasks/inventory.yml b/roles/filetree_create/tasks/inventory.yml index 3ba5a20d..f8069442 100644 --- a/roles/filetree_create/tasks/inventory.yml +++ b/roles/filetree_create/tasks/inventory.yml @@ -2,7 +2,8 @@ - name: "Get the inventories from the API" ansible.builtin.set_fact: inventory_lookvar: "{{ query(controller_api_plugin, 'api/v2/inventories/', - 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': inventory_id} if inventory_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) }}"