From 86d2e1f617ec0f4f33f159682ffa5f277da70d78 Mon Sep 17 00:00:00 2001 From: brusq-RH <76945214+brusq-RH@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:46:26 +0200 Subject: [PATCH] up --- aap/add_vm_to_inventory.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 aap/add_vm_to_inventory.yaml diff --git a/aap/add_vm_to_inventory.yaml b/aap/add_vm_to_inventory.yaml new file mode 100644 index 0000000..e90c0cd --- /dev/null +++ b/aap/add_vm_to_inventory.yaml @@ -0,0 +1,34 @@ +- name: Add host to VM inventory + hosts: localhost + gather_facts: false + vars: + inventory_name: "{{ inventory_name }}" + site_name: "{{ hypervisor | replace('-Baremetal', '') | replace('-', '_') | lower }}" + + tasks: + - name: Add inventory + ansible.controller.inventory: + validate_certs: false + name: "{{ inventory_name }}" + description: "VMs" + organization: "Default" + state: present + + - name: Add host to inventory + ansible.controller.host: + name: "{{ vm_name }}" + description: "" + inventory: "{{ inventory_name }}" + state: present + variables: + ansible_host: "{{ vm_ip }}" + + - name: Add group + ansible.controller.group: + name: "{{ site_name }}_virtualmachine" + description: "Local Host Group" + inventory: "{{ inventory_name }}" + hosts: + - "{{ vm_name }}" + preserve_existing_hosts: true + preserve_existing_children: true \ No newline at end of file