Saturday, June 12, 2021

Ansible playbook to delete multiple vms

Ansible playbook to delete multiple vms

---
- name: Delete VMs from Vcenter
  hosts: localhost
  gather_facts: no
  vars:
    hostname: vcenter_ip
    username: vcenter_user
    password: vcenter_password
  tasks:
  - name: Delete Vms
    vmware_guest:
      hostname: "{{ hostname }}"
      username: "{{ username }}"
      password: "{{ password }}"
      validate_certs: False
      name: "{{ item }}"
      state: absent
      wait_for_ip_address: no
    delegate_to: localhost
    with_items:
    - testvm2
    - testvm_3

No comments: