You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
935 B
34 lines
935 B
- 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
|