Using this module, you can create a backup of a VMware ESXi host configuration:
- name: Create an esxi host configuration backup
vmware_cfg_backup:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
state: "saved"
dest: "/tmp/"
esxi_hostname: "{{ exsi_host }}"
delegate_to: "localhost"
register: cfg_backup
Please note that this module will automatically put the host into maintenance and then save the configuration too. In the preceding example, from /tmp, you can use the information registered to grab a copy of the backup using the fetch module.
You can also use this module to restore a configuration:
- name: Restore an esxi host configuration backup
vmware_cfg_backup:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
state: "loaded"
dest: "/tmp/my-host-backup.tar.gz"
esxi_hostname: "{{ exsi_host }}"
delegate_to: "localhost"
Finally, you can also reset a host configuration back to its default settings by running the following code:
- name: Reset a host configuration to the default values
vmware_cfg_backup:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
state: "absent"
esxi_hostname: "{{ exsi_host }}"
delegate_to: "localhost"