Browse Source

up

main scenarios
brusq-RH 2 months ago
parent
commit
86d2e1f617
  1. 34
      aap/add_vm_to_inventory.yaml

34
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
Loading…
Cancel
Save