summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/vmware/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/community/vmware/tests/integration')
-rw-r--r--ansible_collections/community/vmware/tests/integration/cloud-config-vcenter.ini.sample12
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/__init__.py0
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory.yml23
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_with_cache.yml14
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_without_cache.yml14
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/install_dependencies.yml7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/prepare_vmware.yml17
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_inventory_cache.yml51
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_options.yml208
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_vmware_host_inventory.yml18
-rwxr-xr-xansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/runme.sh56
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_with_cache.yml11
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_without_cache.yml12
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/install_dependencies.yml7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/prepare_vmware.yml18
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_inventory_cache.yml51
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_options.yml332
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_vmware_vm_inventory.yml18
-rwxr-xr-xansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/runme.sh56
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/meta/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml31
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/main.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/move_host_out_of_cluster.yml35
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml54
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_category.yml9
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_cluster.yml10
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_content_library.yml7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml11
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml42
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvs_portgroup.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvswitch.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml15
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_tag.yml15
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml47
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown.yml22
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown_with_esxi.yml94
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/common.yml12
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_1esxi.yml33
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_2esxi.yml34
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_only.yml6
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/aliases6
-rwxr-xr-xansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/runme.sh58
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/test_vmware_inventory.yml18
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/vmware_inventory.sh3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/tasks/main.yml177
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/meta/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/tasks/main.yml13
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/meta/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/main.yml214
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/regression_folder_collision.yml135
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_license/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_license/meta/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_license/tasks/main.yml25
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml58
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_category/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml38
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_types.yml123
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/tasks/main.yml33
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/tasks/main.yml120
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/tasks/main.yml62
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/tasks/main.yml157
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/tasks/main.yml303
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/tasks/main.yml194
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml134
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/tasks/main.yml35
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/tasks/main.yml37
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/tasks/main.yml231
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/tasks/main.yml142
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/tasks/main.yml288
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/tasks/main.yml104
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/tasks/main.yml74
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/tasks/main.yml45
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/tasks/main.yml147
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/tasks/main.yml140
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/tasks/main.yml349
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/tasks/main.yml81
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/tasks/main.yml73
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/tasks/main.yml42
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/tasks/main.yml98
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/tasks/main.yml45
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/tasks/main.yml113
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml807
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/tasks/main.yml101
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml110
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/tasks/main.yml266
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/tasks/main.yml220
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/tasks/main.yml101
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml72
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml73
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/meta/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/tasks/main.yml50
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/tasks/main.yml60
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/tasks/main.yml290
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml52
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/defaults/main.yml30
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/advanced_settings.yml97
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml111
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml230
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f1.yml365
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml85
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml69
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_d1_c1_f0.yml49
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_resize_disks.yml75
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml88
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml162
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_guest_invalid_d1_c1_f0.yml30
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_nw_d1_c1_f0.yml38
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_rp_d1_c1_f0.yml208
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_vm_using_special_characters.yml82
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/delete_vm.yml82
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml86
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_size_d1_c1_f0.yml31
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_type_d1_c1_f0.yml33
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mac_address_d1_c1_f0.yml37
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/main.yml18
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/max_connections.yml43
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mem_reservation.yml123
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/multiple_disk_controllers_d1_c1_f0.yml216
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_negative_test.yml339
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_with_device.yml62
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/non_existent_vm_ops.yml23
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/reconfig_vm_to_latest_version.yml97
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/remove_vm_from_inventory.yml61
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/run_test_playbook.yml32
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/shares.yml122
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/vapp_d1_c1_f0.yml96
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml119
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/tasks/main.yml49
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/tasks/main.yml190
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml80
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/tasks/main.yml160
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/tasks/main.yml85
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/tasks/main.yml157
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/tasks/main.yml36
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml610
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml73
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/tasks/main.yml60
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/tasks/main.yml247
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/tasks/main.yml385
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/tasks/main.yml81
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml537
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml87
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/tasks/main.yml359
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/tasks/main.yml52
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/tasks/main.yml53
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/tasks/main.yml590
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml172
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/tasks/main.yml27
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/tasks/main.yml209
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/tasks/main.yml51
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml45
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host/tasks/main.yml253
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml39
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/tasks/main.yml85
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/esxi_auto_start_ops.yml368
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml57
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/reset_auto_start_config.yml35
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/vcenter_auto_start_ops.yml367
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/tasks/main.yml38
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/tasks/main.yml66
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/tasks/main.yml123
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/tasks/main.yml94
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/tasks/main.yml80
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/tasks/main.yml35
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/dhcp.yml303
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/main.yml26
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/static.yml223
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/teardown.yaml15
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/tasks/main.yml70
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/tasks/main.yml69
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/tasks/main.yml76
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/tasks/main.yml65
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/tasks/main.yml260
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/tasks/main.yml91
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/tasks/main.yml89
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/iscsi_module_test_tasks.yml1170
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/main.yml52
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/iscsi_info_module_test_tasks.yml126
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/main.yml22
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/tasks/main.yml50
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/tasks/main.yml98
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/tasks/main.yml195
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/tasks/main.yml263
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/tasks/main.yml38
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/tasks/main.yml262
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/tasks/main.yml21
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/tasks/main.yml21
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/main.yml22
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/pre.yml40
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough.yml229
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough_pci_id.yml229
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml102
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/tasks/main.yml31
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/tasks/main.yml23
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml71
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/tasks/main.yml36
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/tasks/main.yml82
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml70
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/tasks/main.yml118
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/tasks/main.yml70
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/destroy.yml54
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/main.yml17
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/pre.yml95
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/vmware_host_tcpip_stacks_tests.yml327
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/main.yml14
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_ESXi.yml196
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_vcenter.yml196
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/tasks/main.yml36
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/tasks/main.yml94
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/tasks/main.yml45
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/tasks/main.yml162
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/tasks/main.yml34
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/tasks/main.yml39
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/tasks/main.yml76
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/aliases5
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/tasks/main.yml299
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/cleanup.yml41
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/main.yml19
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/pre.yml100
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml105
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/dc_rename.yml66
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml5
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/alias3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/main.yml26
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/user_friendly_role_name_tests.yml40
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/vmware_object_role_permission_tests.yml881
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/alias3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/main.yml18
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/vmware_object_role_permission_tests.yml41
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/tasks/main.yml214
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/tasks/main.yml67
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/tasks/main.yml92
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/tasks/main.yml445
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/tasks/main.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_crud_ops.yml112
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_duplicate_tag_cat.yml188
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml90
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml5
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/tag_info.yml22
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/cleanup.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml33
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/tag_manager_dict.yml187
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/tasks/main.yml37
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/tasks/main.yml72
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/tasks/main.yml222
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/tasks/main.yml53
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/tasks/main.yml126
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/tasks/main.yml154
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml121
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/tasks/main.yml98
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/ansible.cfg9
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml55
-rwxr-xr-xansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/runme.sh7
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/test_inventory.yml10
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/tasks/main.yml164
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/tasks/main.yml23
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml163
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/tasks/main.yml62
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/tasks/main.yml35
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/tasks/main.yml131
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/aliases4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/tasks/main.yml20
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/tasks/main.yml102
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/main.yml278
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/teardown.yml16
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/tasks/main.yml60
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vsphere_file/aliases1
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vsphere_file/tasks/main.yml369
414 files changed, 29088 insertions, 0 deletions
diff --git a/ansible_collections/community/vmware/tests/integration/cloud-config-vcenter.ini.sample b/ansible_collections/community/vmware/tests/integration/cloud-config-vcenter.ini.sample
new file mode 100644
index 00000000..1a0a3240
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/cloud-config-vcenter.ini.sample
@@ -0,0 +1,12 @@
+; VMWARE_TEST_PLATFORM=static ansible-test integration --python 3.8
+[DEFAULT]
+vcenter_hostname: vcenter.test
+vcenter_username: user
+vcenter_password: pass
+vmware_validate_certs: false
+esxi1_hostname: esxi1.test
+esxi1_username: root
+esxi1_password: pass
+esxi2_hostname: test2.test
+esxi2_username: root
+esxi2_password: pass
diff --git a/ansible_collections/community/vmware/tests/integration/targets/__init__.py b/ansible_collections/community/vmware/tests/integration/targets/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/__init__.py
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/aliases b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory.yml
new file mode 100644
index 00000000..1479778c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory.yml
@@ -0,0 +1,23 @@
+---
+ - name: Set inventory content
+ copy:
+ dest: "{{ lookup('env', 'INVENTORY_DIR') }}/tmp.vmware.yml"
+ content: |
+ {{ content }}
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ port: '{{ vcenter_port|default('443') }}'
+ validate_certs: {{ vmware_validate_certs|default('no') }}
+ changed_when: false
+ check_mode: false
+
+ - meta: refresh_inventory
+
+ - debug:
+ msg: "{{ hostvars }}"
+
+ - name: Refresh test_host
+ set_fact:
+ test_host: "{{ hostvars | dict2items | first }}"
+ when: hostvars | length >= 1 \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_with_cache.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_with_cache.yml
new file mode 100644
index 00000000..1fcb0cda
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_with_cache.yml
@@ -0,0 +1,14 @@
+---
+- hosts: localhost
+ tasks:
+ - name: Inventory with 'cache' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ cache: true
+ properties:
+ - name
+ - summary.runtime.powerState
+ - customValue
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_without_cache.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_without_cache.yml
new file mode 100644
index 00000000..4b50b26e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/build_inventory_without_cache.yml
@@ -0,0 +1,14 @@
+---
+- hosts: localhost
+ tasks:
+ - name: Inventory without 'cache' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: true
+ cache: false
+ properties:
+ - name
+ - summary.runtime.powerState
+ - customValue
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/install_dependencies.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/install_dependencies.yml
new file mode 100644
index 00000000..d3aab8c6
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/install_dependencies.yml
@@ -0,0 +1,7 @@
+---
+- name: Install dependencies
+ hosts: localhost
+ gather_facts: false
+ tasks:
+ - pip:
+ name: toml \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/prepare_vmware.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/prepare_vmware.yml
new file mode 100644
index 00000000..921edb43
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/prepare_vmware.yml
@@ -0,0 +1,17 @@
+---
+- name: Prepare VMware folders for testing dynamic inventory folder support
+ hosts: localhost
+ gather_facts: false
+ module_defaults:
+ group/vmware:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ port: "{{ vcenter_port|default('443') }}"
+ validate_certs: "{{ vmware_validate_certs|default('no') }}"
+ tasks:
+ - import_role:
+ name: ../prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_inventory_cache.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_inventory_cache.yml
new file mode 100644
index 00000000..2fd597c5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_inventory_cache.yml
@@ -0,0 +1,51 @@
+---
+- name: Test inventory cache
+ hosts: localhost
+ gather_facts: false
+ tasks:
+ - find:
+ paths: "{{ lookup('env', 'ANSIBLE_CACHE_PLUGIN_CONNECTION') }}"
+ patterns: "community.vmware.vmware_host_inventory*"
+ register: result
+
+ - name: Cache directory exist
+ fail:
+ msg: Cache not found. Please debug.
+ when: result.matched|int == 0
+ ignore_errors: true
+
+ - when: result.matched|int == 0
+ meta: end_play
+
+ - set_fact:
+ cached_groups: "{{groups}}"
+ cached_hostvars: "{{hostvars}}"
+
+ - meta: refresh_inventory
+
+ - name: 'Compare groups'
+ fail:
+ msg: "{{ item.key }} not found in cached groups. Please debug."
+ when: cached_groups[item.key] is not defined
+ loop: "{{ q('dict', groups) }}"
+ loop_control:
+ label: "{{ item.key }}"
+
+ - name: 'Compare hosts'
+ fail:
+ msg: "{{ item.key }} not found in cached hosts. Please debug."
+ when: cached_hostvars[item.key] is not defined
+ loop: "{{ q('dict', hostvars) }}"
+ loop_control:
+ label: "{{ item.key }}"
+
+ - set_fact:
+ test_host: "{{ hostvars | dict2items | first }}"
+
+ - name: 'Compare hostvars'
+ fail:
+ msg: "{{ item.key }} not found in cached hostvars. Please debug."
+ when: cached_hostvars[test_host.key][item.key] is not defined
+ loop: "{{ q('dict', test_host.value) }}"
+ loop_control:
+ label: "{{ item.key }}" \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_options.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_options.yml
new file mode 100644
index 00000000..79a3e36b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_options.yml
@@ -0,0 +1,208 @@
+---
+- name: Test Hostnames option
+ hosts: localhost
+ tasks:
+ - name: Inventory with 'hostnames' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_nested_properties: false
+ properties:
+ - runtime.powerState
+ hostnames:
+ - 'skip_undefined_empty_none_var'
+ - 'runtime.powerState'
+
+ - name: Test properties option are populate
+ assert:
+ that:
+ - "'runtime.powerState' in test_host.value"
+
+ - name: Test hostnames option
+ assert:
+ that:
+ - test_host.key == (test_host.value['runtime.powerState'])
+
+ - name: Inventory with 'config' root properties
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_nested_properties: false
+ properties:
+ - config.lockdownMode
+ - name
+ - summary
+ - name: Test properties(config) option are populate
+ assert:
+ that:
+ - "'name' in test_host.value"
+ - "'summary.runtime.powerState' in test_host.value"
+ - "'config.lockdownMode' in test_host.value"
+
+ - name: Inventory with 'with_path' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_path: true
+ properties:
+ - name
+ - summary.runtime.powerState
+ - name: Test path option
+ assert:
+ that:
+ - "'path' in test_host.value"
+
+ - name: Inventory with rooted 'with_path' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_path: my_center
+ - name: Test path option with rooted path
+ assert:
+ that:
+ - "'path' in test_host.value"
+ - "'my_center' in test_host.value.group_names"
+
+ - name: Inventory 'with_nested_properties' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ properties:
+ - name
+ - summary.runtime.powerState
+ - config.lockdownMode
+ with_nested_properties: true
+ - name: Test 'with_nested_properties' option
+ assert:
+ that:
+ - test_host.value.config.lockdownMode is defined
+
+
+ - name: Inventory 'sanitize_property_name' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ properties:
+ - name
+ - summary.runtime.powerState
+ - config.lockdownMode
+ with_sanitized_property_name: true
+ - name: Test 'with_nested_properties' option
+ assert:
+ that:
+ - test_host.value.config_lockdown_mode is defined
+
+
+ - name: Inventory 'Constructable' options - keyed_groups
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - name
+ - summary.runtime.powerState
+ - config.lockdownMode
+ keyed_groups:
+ - key: 'config.lockdownMode'
+ separator: ''
+ - name: Test 'Constructable' options - keyed_groups
+ assert:
+ that:
+ - "'lockdownDisabled' in test_host.value.group_names"
+
+
+ - name: Inventory filters options
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - name
+ - summary.runtime.powerState
+ filters:
+ - summary.runtime.powerState == "poweredOn"
+
+ - debug:
+ msg: "{{ test_host.value.groups }}"
+
+ - name: Test filters options
+ assert:
+ that:
+ - "test_host.key in test_host.value.groups.all"
+
+
+ - name: Inventory 'Constructable' options - compose, groups
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - name
+ - summary.runtime.powerState
+ compose:
+ ansible_host: 'name'
+ composed_var: 'name'
+ groups:
+ my_hosts: true
+ - name: Test 'Constructable' options - compose, groups
+ assert:
+ that:
+ - "'my_hosts' in test_host.value.group_names"
+ - "'ansible_host' in test_host.value"
+ - "'composed_var' in test_host.value"
+ - test_host.value.composed_var == test_host.value.name
+
+
+ - name: Inventory 'with_tag' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ with_nested_properties: true
+ with_tags: true
+ properties:
+ - name
+ - summary.runtime.powerState
+ - name: Test 'with_tags' options
+ assert:
+ that:
+ - "'tags' in test_host.value"
+ - "'categories' in test_host.value"
+ - "'tag_category' in test_host.value"
+
+
+ - name: Inventory 'resources' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_host_inventory
+ strict: false
+ resources:
+ - datacenter:
+ - DC0
+ resources:
+ - compute_resource:
+ - DC0_C0_NOT_EXIST
+ - name: Test 'resources' options with 'DC0_C0_NOT_EXIST'
+ assert:
+ that:
+ - hostvars | length == 0
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_vmware_host_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_vmware_host_inventory.yml
new file mode 100644
index 00000000..39950ace
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/playbook/test_vmware_host_inventory.yml
@@ -0,0 +1,18 @@
+# Test code for the vmware host dynamic plugin module
+# Copyright: (c) 2021, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+---
+- name: Test VMware Host Dynamic Inventory Plugin
+ hosts: localhost
+ tasks:
+ - name: Check that there is 'all' group present in inventory
+ assert:
+ that:
+ - "'all' in groups"
+
+ - name: Check if Hostname and other details are populated in hostvars
+ assert:
+ that:
+ - hostvars[item].name is defined
+ with_items: "{{ groups['all'] }}" \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/runme.sh b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/runme.sh
new file mode 100755
index 00000000..62915a3f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_host_inventory/runme.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+set -eux
+
+# Envs
+export ANSIBLE_PYTHON_INTERPRETER=${ANSIBLE_TEST_PYTHON_INTERPRETER:-$(command -v python)}
+export ANSIBLE_INVENTORY_ENABLED="community.vmware.vmware_host_inventory,host_list,ini"
+export ANSIBLE_CACHE_PLUGIN_CONNECTION="${PWD}/inventory_cache"
+export ANSIBLE_CACHE_PLUGIN="jsonfile"
+
+export INVENTORY_DIR="${PWD}/_test/hosts"
+mkdir -p "${INVENTORY_DIR}" 2>/dev/null
+touch "${INVENTORY_DIR}/empty.vmware.yml"
+
+cleanup() {
+ echo "Cleanup"
+ if [ -d "${ANSIBLE_CACHE_PLUGIN_CONNECTION}" ]; then
+ echo "Removing ${ANSIBLE_CACHE_PLUGIN_CONNECTION}"
+ rm -rf "${ANSIBLE_CACHE_PLUGIN_CONNECTION}"
+ fi
+
+ if [ -d "${INVENTORY_DIR}" ]; then
+ echo "Removing ${INVENTORY_DIR}"
+ rm -rf "${INVENTORY_DIR}"
+ fi
+
+ unset ANSIBLE_INVENTORY_ENABLED
+ unset ANSIBLE_CACHE_PLUGIN ANSIBLE_CACHE_PLUGIN_CONNECTION
+ unset INVENTORY_DIR
+
+ echo "Done"
+}
+
+trap cleanup INT TERM EXIT
+
+# Prepare tests
+ansible-playbook playbook/prepare_vmware.yml "$@"
+
+# Test Cache
+# Cache requires jsonfile
+# ansible-playbook playbook/build_inventory_with_cache.yml "$@"
+# ansible-inventory -i "${INVENTORY_DIR}" --list
+# ansible-playbook -i "${INVENTORY_DIR}" playbook/test_inventory_cache.yml "$@"
+
+# Test YAML and TOML
+ansible-playbook playbook/install_dependencies.yml "$@"
+ansible-playbook playbook/build_inventory_without_cache.yml "$@"
+ansible-inventory -i "${INVENTORY_DIR}" --list --yaml 1>/dev/null
+if ${ANSIBLE_PYTHON_INTERPRETER} -m pip list 2>/dev/null | grep toml >/dev/null 2>&1; then
+ ansible-inventory -i "${INVENTORY_DIR}" --list --toml 1>/dev/null
+fi
+
+# Test playbook with the given inventory
+ansible-playbook -i "${INVENTORY_DIR}" playbook/test_vmware_host_inventory.yml "$@"
+
+# Test options
+ansible-playbook -i "${INVENTORY_DIR}" playbook/test_options.yml "$@"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/aliases b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/aliases
new file mode 100644
index 00000000..ad593838
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory.yml
new file mode 100644
index 00000000..18a656ab
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory.yml
@@ -0,0 +1,20 @@
+---
+ - name: Set inventory content
+ copy:
+ dest: "{{ lookup('env', 'INVENTORY_DIR') }}/tmp.vmware.yml"
+ content: |
+ {{ content }}
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ port: '{{ vcenter_port|default('443') }}'
+ validate_certs: {{ vmware_validate_certs|default('no') }}
+ changed_when: false
+ check_mode: false
+
+ - meta: refresh_inventory
+
+ - name: Refresh test_host
+ set_fact:
+ test_host: "{{ hostvars | dict2items | first}}"
+ when: hostvars | length > 1 \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_with_cache.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_with_cache.yml
new file mode 100644
index 00000000..f43ae8cf
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_with_cache.yml
@@ -0,0 +1,11 @@
+---
+- hosts: localhost
+ tasks:
+ - name: Inventory with 'cache' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ cache: true
+ properties: [all] \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_without_cache.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_without_cache.yml
new file mode 100644
index 00000000..f07512cc
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/build_inventory_without_cache.yml
@@ -0,0 +1,12 @@
+---
+- hosts: localhost
+ tasks:
+
+ - name: Inventory with 'cache' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ cache: false
+ properties: [all] \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/install_dependencies.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/install_dependencies.yml
new file mode 100644
index 00000000..d3aab8c6
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/install_dependencies.yml
@@ -0,0 +1,7 @@
+---
+- name: Install dependencies
+ hosts: localhost
+ gather_facts: false
+ tasks:
+ - pip:
+ name: toml \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/prepare_vmware.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/prepare_vmware.yml
new file mode 100644
index 00000000..9fc9662f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/prepare_vmware.yml
@@ -0,0 +1,18 @@
+---
+- name: Prepare VMware folders for testing dynamic inventory folder support
+ hosts: localhost
+ gather_facts: false
+ module_defaults:
+ group/vmware:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ port: "{{ vcenter_port|default('443') }}"
+ validate_certs: "{{ vmware_validate_certs|default('no') }}"
+ tasks:
+ - import_role:
+ name: ../prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_inventory_cache.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_inventory_cache.yml
new file mode 100644
index 00000000..eeed6d26
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_inventory_cache.yml
@@ -0,0 +1,51 @@
+---
+- name: Test inventory cache
+ hosts: localhost
+ gather_facts: false
+ tasks:
+ - find:
+ paths: "{{ lookup('env', 'ANSIBLE_CACHE_PLUGIN_CONNECTION') }}"
+ patterns: "community.vmware.vmware_vm_inventory*"
+ register: result
+
+ - name: Cache directory exist
+ fail:
+ msg: Cache not found. Please debug.
+ when: result.matched|int == 0
+ ignore_errors: true
+
+ - when: result.matched|int == 0
+ meta: end_play
+
+ - set_fact:
+ cached_groups: "{{groups}}"
+ cached_hostvars: "{{hostvars}}"
+
+ - meta: refresh_inventory
+
+ - name: 'Compare groups'
+ fail:
+ msg: "{{ item.key }} not found in cached groups. Please debug."
+ when: cached_groups[item.key] is not defined
+ loop: "{{ q('dict', groups) }}"
+ loop_control:
+ label: "{{ item.key }}"
+
+ - name: 'Compare hosts'
+ fail:
+ msg: "{{ item.key }} not found in cached hosts. Please debug."
+ when: cached_hostvars[item.key] is not defined
+ loop: "{{ q('dict', hostvars) }}"
+ loop_control:
+ label: "{{ item.key }}"
+
+ - set_fact:
+ test_host: "{{ hostvars | dict2items | first }}"
+
+ - name: 'Compare hostvars'
+ fail:
+ msg: "{{ item.key }} not found in cached hostvars. Please debug."
+ when: cached_hostvars[test_host.key][item.key] is not defined
+ loop: "{{ q('dict', test_host.value) }}"
+ loop_control:
+ label: "{{ item.key }}" \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_options.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_options.yml
new file mode 100644
index 00000000..3861cc95
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_options.yml
@@ -0,0 +1,332 @@
+---
+- name: Test Hostnames option
+ hosts: localhost
+ tasks:
+
+ - name: Inventory with 'hostnames' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ properties:
+ - config.name
+ - runtime.powerState
+ hostnames:
+ - 'skip_undefined_empty_none_var'
+ - 'config.name + "_" + runtime.powerState'
+ - name: Test properties option are populate
+ assert:
+ that:
+ - "'config.name' in test_host.value"
+ - "'runtime.powerState' in test_host.value"
+ - "'name' not in test_host.value"
+ - name: Test hostnames option
+ assert:
+ that:
+ - test_host.key == (test_host.value['config.name'] + "_" + test_host.value['runtime.powerState'])
+
+
+ - name: Inventory with 'all' properties
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ properties: ['all']
+ - name: Test properties(all) option are populate
+ assert:
+ that:
+ - "'name' in test_host.value"
+ - "'config.name' in test_host.value"
+
+
+ - name: Inventory with 'config' root properties
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ properties:
+ - config
+ - name: Test properties(config) option are populate
+ assert:
+ that:
+ - "'name' not in test_host.value"
+ - "'config.name' in test_host.value"
+
+
+ - name: Inventory with 'with_path' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_path: true
+ - name: Test path option
+ assert:
+ that:
+ - "'path' in test_host.value"
+
+ - name: Inventory with rooted 'with_path' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_path: my_center
+ - name: Test path option with rooted path
+ assert:
+ that:
+ - "'path' in test_host.value"
+ - "'my_center' in test_host.value.group_names"
+
+ - name: Inventory 'with_nested_properties' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ properties:
+ - config.name
+ - config.uuid
+ with_nested_properties: true
+ - name: Test 'with_nested_properties' option
+ assert:
+ that:
+ - test_host.value.config.name is defined
+
+
+ - name: Inventory 'sanitize_property_name' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ properties:
+ - config.name
+ - config.uuid
+ - runtime.powerState
+
+ with_nested_properties: false
+ with_sanitized_property_name: true
+ - name: Test 'with_nested_properties' option
+ assert:
+ that:
+ - test_host.value.runtime_power_state is defined
+
+
+ - name: Inventory 'Constructable' options - keyed_groups
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - config.name
+ - config.uuid
+ - config.guestId
+ - runtime.powerState
+ keyed_groups:
+ - key: 'config.guestId'
+ separator: ''
+ - key: 'runtime.powerState'
+ separator: ''
+ - name: Test 'Constructable' options - keyed_groups
+ assert:
+ that:
+ - "'poweredOff' in test_host.value.group_names"
+
+
+ - name: Inventory filters options
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - config.name
+ - runtime.powerState
+ filters:
+ - runtime.powerState == "poweredOff"
+ hostnames:
+ - config.name
+ - name: Test filters options
+ assert:
+ that:
+ - "'DC0_H0_VM0' in test_host.value.groups.all"
+
+
+ - name: Inventory 'Constructable' options - compose, groups
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - config.uuid
+ - config.guestId
+ - runtime.powerState
+ - config.name
+ compose:
+ ansible_host: 'config.name'
+ composed_var: 'config.name'
+ groups:
+ VMs: true
+ keyed_groups:
+ - key: 'config.guestId'
+ separator: ''
+ - key: 'runtime.powerState'
+ separator: ''
+ - name: Test 'Constructable' options - compose, groups
+ assert:
+ that:
+ - "'VMs' in test_host.value.group_names"
+ - "'poweredOff' in test_host.value.group_names"
+ - "'ansible_host' in test_host.value"
+ - "'composed_var' in test_host.value"
+ - test_host.value.ansible_host == test_host.value.config.name
+ - test_host.value.composed_var == test_host.value.config.name
+
+
+ - name: Inventory 'with_tag' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: true
+ with_tags: true
+ properties:
+ - config.name
+ - config.uuid
+ - config.guestId
+ - runtime.powerState
+ - name: Test 'with_tags' options
+ assert:
+ that:
+ - "'tags' in test_host.value"
+ - "'categories' in test_host.value"
+ - "'tag_category' in test_host.value"
+
+
+ - name: Inventory with binary values (https://github.com/ansible/awx/issues/7052)
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: true
+ properties:
+ - config.vmxConfigChecksum
+ - config.name
+ - summary.runtime.powerState
+ hostnames:
+ - config.name
+ - name: Test filters options
+ assert:
+ that:
+ - "'DC0_H0_VM0' in test_host.value.groups.all"
+ - test_host.value.config.name is defined
+ - test_host.value.config.vmxConfigChecksum is defined
+
+
+ - name: Inventory 'resources' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ hostnames:
+ - config.name
+ properties:
+ - config.name
+ resources:
+ - datacenter:
+ - DC0
+ resources:
+ - compute_resource:
+ - DC0_C0
+ - name: Test 'resources' options
+ assert:
+ that:
+ - "'DC0_C0_RP0_VM0' in hostvars"
+
+ - name: Inventory 'resources' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ hostnames:
+ - config.name
+ properties:
+ - config.name
+ resources:
+ - datacenter:
+ - DC0
+ resources:
+ - compute_resource:
+ - DC0_C0
+ - DC0_C0_NOT_EXIST
+ - name: Test 'resources' options with 'DC0_C0' and 'DC0_C0_NOT_EXIST'
+ assert:
+ that:
+ - "'DC0_C0_RP0_VM0' in hostvars"
+
+ - name: Inventory 'resources' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ hostnames:
+ - config.name
+ properties:
+ - config.name
+ resources:
+ - datacenter:
+ - DC0
+ resources:
+ - compute_resource:
+ - DC0_C0
+ - datacenter:
+ - DC0
+ resources:
+ - compute_resource:
+ - DC0_C0_NOT_EXIST
+ - name: Test 'resources' options with 'DC0_C0' and 'DC0_C0_NOT_EXIST' using two 'datacenter'
+ assert:
+ that:
+ - "'DC0_C0_RP0_VM0' in hostvars"
+
+ - name: Inventory 'resources' option
+ include_tasks: build_inventory.yml
+ vars:
+ content: |-
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ with_nested_properties: false
+ hostnames:
+ - config.name
+ properties:
+ - config.name
+ resources:
+ - datacenter:
+ - DC0
+ resources:
+ - compute_resource:
+ - DC0_C0_NOT_EXIST
+ - name: Test 'resources' options with 'DC0_C0_NOT_EXIST'
+ assert:
+ that:
+ - hostvars | length == 0
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_vmware_vm_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_vmware_vm_inventory.yml
new file mode 100644
index 00000000..d454ca85
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/playbook/test_vmware_vm_inventory.yml
@@ -0,0 +1,18 @@
+# Test code for the vmware guest dynamic plugin module
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+---
+- name: Test VMware Guest Dynamic Inventroy Plugin
+ hosts: localhost
+ tasks:
+ - name: Check that there is 'all' group present in inventory
+ assert:
+ that:
+ - "'all' in groups"
+
+ - name: Check if Hostname and other details are populated in hostvars
+ assert:
+ that:
+ - hostvars[item].name is defined
+ with_items: "{{ groups['all'] }}" \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/runme.sh b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/runme.sh
new file mode 100755
index 00000000..e9e7a5a9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/inventory_vmware_vm_inventory/runme.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+set -eux
+
+# Envs
+export ANSIBLE_PYTHON_INTERPRETER=${ANSIBLE_TEST_PYTHON_INTERPRETER:-$(command -v python)}
+export ANSIBLE_INVENTORY_ENABLED="community.vmware.vmware_vm_inventory,host_list,ini"
+export ANSIBLE_CACHE_PLUGIN_CONNECTION="${PWD}/inventory_cache"
+export ANSIBLE_CACHE_PLUGIN="jsonfile"
+
+export INVENTORY_DIR="${PWD}/_test/hosts"
+mkdir -p "${INVENTORY_DIR}" 2>/dev/null
+touch "${INVENTORY_DIR}/empty.vmware.yml"
+
+cleanup() {
+ echo "Cleanup"
+ if [ -d "${ANSIBLE_CACHE_PLUGIN_CONNECTION}" ]; then
+ echo "Removing ${ANSIBLE_CACHE_PLUGIN_CONNECTION}"
+ rm -rf "${ANSIBLE_CACHE_PLUGIN_CONNECTION}"
+ fi
+
+ if [ -d "${INVENTORY_DIR}" ]; then
+ echo "Removing ${INVENTORY_DIR}"
+ rm -rf "${INVENTORY_DIR}"
+ fi
+
+ unset ANSIBLE_INVENTORY_ENABLED
+ unset ANSIBLE_CACHE_PLUGIN ANSIBLE_CACHE_PLUGIN_CONNECTION
+ unset INVENTORY_DIR
+
+ echo "Done"
+}
+
+trap cleanup INT TERM EXIT
+
+# Prepare tests
+ansible-playbook playbook/prepare_vmware.yml "$@"
+
+# Test Cache
+# Cache requires jsonfile
+ansible-playbook playbook/build_inventory_with_cache.yml "$@"
+ansible-inventory -i "${INVENTORY_DIR}" --list 1>/dev/null
+ansible-playbook -i "${INVENTORY_DIR}" playbook/test_inventory_cache.yml "$@"
+
+# Test YAML and TOML
+ansible-playbook playbook/install_dependencies.yml "$@"
+ansible-playbook playbook/build_inventory_without_cache.yml "$@"
+ansible-inventory -i "${INVENTORY_DIR}" --list --yaml 1>/dev/null
+if ${ANSIBLE_PYTHON_INTERPRETER} -m pip list 2>/dev/null | grep toml >/dev/null 2>&1; then
+ ansible-inventory -i "${INVENTORY_DIR}" --list --toml 1>/dev/null
+fi
+
+# # Test playbook with the given inventory
+ansible-playbook -i "${INVENTORY_DIR}" playbook/test_vmware_vm_inventory.yml "$@"
+
+# Test options
+ansible-playbook -i "${INVENTORY_DIR}" playbook/test_options.yml "$@"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/meta/main.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/meta/main.yml
new file mode 100644
index 00000000..61d3ffe4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/meta/main.yml
@@ -0,0 +1,2 @@
+---
+allow_duplicates: true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml
new file mode 100644
index 00000000..51c5d34f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/init_real_lab.yml
@@ -0,0 +1,31 @@
+---
+- include_tasks: teardown_with_esxi.yml
+ when: esxi_hosts|length > 0
+- include_tasks: teardown.yml
+
+- when: setup_esxi_instance is not defined
+ block:
+ - include_tasks: setup_datacenter.yml
+ - include_tasks: setup_cluster.yml
+ - include_tasks: setup_attach_hosts.yml
+ when: setup_attach_host is defined
+ - include_tasks: move_host_out_of_cluster.yml
+ when: move_host_out_of_cluster is defined
+ - include_tasks: setup_datastore.yml
+ when: setup_datastore is defined
+ - include_tasks: setup_virtualmachines.yml
+ when: setup_virtualmachines is defined
+ - include_tasks: setup_switch.yml
+ when: setup_switch is defined
+ - include_tasks: setup_dvswitch.yml
+ when: setup_dvswitch is defined
+ - include_tasks: setup_resource_pool.yml
+ when: setup_resource_pool is defined
+ - include_tasks: setup_category.yml
+ when: setup_category is defined
+ - include_tasks: setup_tag.yml
+ when: setup_tag is defined
+ - include_tasks: setup_content_library.yml
+ when: setup_content_library is defined
+ - include_tasks: setup_dvs_portgroup.yml
+ when: setup_dvs_portgroup is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/main.yml
new file mode 100644
index 00000000..5e134588
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+
+- name: load vmware common vars
+ include_vars:
+ file: common.yml
+
+- when: esxi1_hostname is not defined and esxi2_hostname is not defined
+ include_vars:
+ file: vcenter_only.yml
+
+- when: esxi1_hostname is defined and esxi2_hostname is not defined
+ include_vars:
+ file: vcenter_1esxi.yml
+
+- when: esxi1_hostname is defined and esxi2_hostname is defined
+ include_vars:
+ file: vcenter_2esxi.yml
+
+- name: Init lab
+ include_tasks: init_real_lab.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/move_host_out_of_cluster.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/move_host_out_of_cluster.yml
new file mode 100644
index 00000000..d4a68d64
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/move_host_out_of_cluster.yml
@@ -0,0 +1,35 @@
+---
+- name: Enter maintenance mode
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ item }}"
+ state: present
+ with_items: "{{ esxi_hosts }}"
+ ignore_errors: true
+
+- name: Move ESXi out of Cluster
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ dc1 }}/host"
+ esxi_hostname: "{{ item }}"
+ state: reconnect
+ with_items: "{{ esxi_hosts }}"
+ ignore_errors: true
+
+- name: Exit maintenance mode
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ item }}"
+ state: absent
+ with_items: "{{ esxi_hosts }}"
+ ignore_errors: true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml
new file mode 100644
index 00000000..38c8adf3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_attach_hosts.yml
@@ -0,0 +1,54 @@
+- fail:
+ msg: "No ESXi hosts defined. esxi_hosts is empty."
+ when: "esxi_hosts|length == 0"
+
+- name: Add ESXi Hosts to vCenter
+ vmware_host:
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: '{{ item }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ state: add_or_reconnect
+ with_items: "{{ esxi_hosts }}"
+
+- name: Disable the Maintenance Mode
+ vmware_maintenancemode:
+ esxi_hostname: '{{ item }}'
+ state: absent
+ with_items: "{{ esxi_hosts }}"
+
+# A bit of explanation here. Our test VMs will produce some ARP traffic,
+# if we keep the "VM Network" on vSwitch0, the VM MAC address will
+# be visible by the external switch port. Depending on the
+# antispoofing policy in place, the switch may just decide to block
+# the port.
+- name: Remove any potential existing "VM Network" on vSwitch0
+ vmware_portgroup:
+ esxi_hostname: '{{ item }}'
+ switch: vSwitch0
+ portgroup: VM Network
+ validate_certs: false
+ state: absent
+ ignore_errors: true
+ with_items: "{{ esxi_hosts }}"
+
+- name: Add an isolated VMware vSwitch
+ vmware_vswitch:
+ hostname: '{{ item }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ switch: isolated_vSwitch
+ with_items: "{{ esxi_hosts }}"
+
+- name: Add Management Network VM Portgroup
+ vmware_portgroup:
+ esxi_hostname: '{{ esxi_hosts }}'
+ switch: isolated_vSwitch
+ portgroup: VM Network
+ validate_certs: false
+ register: _vm_network_portgroup
+ until: _vm_network_portgroup is succeeded
+ retries: 10
+ delay: 1
+ failed_when: _vm_network_portgroup is failure
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_category.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_category.yml
new file mode 100644
index 00000000..17e3cd81
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_category.yml
@@ -0,0 +1,9 @@
+- name: Create a category for cluster
+ vmware_category:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ category_name: '{{ cluster_category }}'
+ category_description: '{{ cluster_category }} description'
+ state: present
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_cluster.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_cluster.yml
new file mode 100644
index 00000000..608dbdd2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_cluster.yml
@@ -0,0 +1,10 @@
+- name: Create Cluster
+ vmware_cluster:
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+
+- name: Enable DRS on Cluster
+ vmware_cluster_drs:
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ enable: true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_content_library.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_content_library.yml
new file mode 100644
index 00000000..26affd53
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_content_library.yml
@@ -0,0 +1,7 @@
+- name: Create Content Library
+ vmware_content_library_manager:
+ library_name: test-content-lib
+ library_description: 'Library created by the prepare_vmware_tests role'
+ library_type: local
+ datastore_name: '{{ rw_datastore }}'
+ state: present
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml
new file mode 100644
index 00000000..a5f3eafe
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datacenter.yml
@@ -0,0 +1,11 @@
+- name: Create Datacenter
+ vmware_datacenter:
+ datacenter_name: '{{ dc1 }}'
+ state: present
+
+- name: Create a VM folder on given Datacenter
+ vcenter_folder:
+ datacenter: '{{ dc1 }}'
+ folder_name: '{{ f0 }}'
+ folder_type: vm
+ state: present
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml
new file mode 100644
index 00000000..14f5b476
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_datastore.yml
@@ -0,0 +1,42 @@
+---
+- name: Mount NFS (ro_datastore) datastores to ESXi
+ vmware_host_datastore:
+ hostname: '{{ item }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ datastore_name: '{{ ro_datastore }}'
+ datastore_type: '{{ infra.datastores[ro_datastore].type }}'
+ nfs_server: '{{ infra.datastores[ro_datastore].server }}'
+ nfs_path: '{{ infra.datastores[ro_datastore].path }}'
+ nfs_ro: '{{ infra.datastores[ro_datastore].ro }}'
+ state: present
+ validate_certs: false
+ with_items: "{{ esxi_hosts }}"
+
+- name: Mount NFS (rw_datastore) datastores on the ESXi
+ vmware_host_datastore:
+ hostname: '{{ item }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ datastore_name: '{{ rw_datastore }}'
+ datastore_type: '{{ infra.datastores[rw_datastore].type }}'
+ nfs_server: '{{ infra.datastores[rw_datastore].server }}'
+ nfs_path: '{{ infra.datastores[rw_datastore].path }}'
+ nfs_ro: '{{ infra.datastores[rw_datastore].ro }}'
+ state: present
+ validate_certs: false
+ with_items: "{{ esxi_hosts }}"
+
+- vmware_host_scanhba:
+ refresh_storage: true
+ cluster_name: '{{ ccr1 }}'
+
+- name: The vcenter needs a bit of time to refresh the DS list
+ vmware_datastore_info:
+ validate_certs: false
+ cluster: '{{ ccr1 }}'
+ register: setup_datastore_datatstore_info
+ failed_when: setup_datastore_datatstore_info.datastores|selectattr('type', 'equalto', 'NFS')|list|length != 2
+ until: setup_datastore_datatstore_info is succeeded
+ retries: 60
+ delay: 1
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvs_portgroup.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvs_portgroup.yml
new file mode 100644
index 00000000..4d4cf96c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvs_portgroup.yml
@@ -0,0 +1,20 @@
+---
+- name: create basic DVS portgroup
+ vmware_dvs_portgroup:
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: '{{ dvpg1 }}'
+ vlan_id: 0
+ num_ports: 32
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: present
+
+- name: Create the DVS PG with slash in name
+ vmware_dvs_portgroup:
+ portgroup_name: '{{ dvpg_with_slash }}'
+ switch_name: '{{ dvswitch1 }}'
+ vlan_id: 0
+ num_ports: 120
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: present
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvswitch.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvswitch.yml
new file mode 100644
index 00000000..0d589d8c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_dvswitch.yml
@@ -0,0 +1,20 @@
+---
+- name: Create the DVSwitch
+ vmware_dvswitch:
+ datacenter_name: '{{ dc1 }}'
+ switch_name: '{{ dvswitch1 }}'
+ switch_version: 6.6.0
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ state: present
+- name: Attach the hosts to the DVSwitch
+ vmware_dvs_host:
+ esxi_hostname: "{{ item }}"
+ switch_name: '{{ dvswitch1 }}'
+ vmnics:
+ - vmnic1
+ state: present
+ with_items: "{{ esxi_hosts }}"
+ when: setup_attach_host is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml
new file mode 100644
index 00000000..01a17d29
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_resource_pool.yml
@@ -0,0 +1,15 @@
+---
+- name: Add resource pool to vCenter
+ vmware_resource_pool:
+ datacenter: '{{ dc1 }}'
+ cluster: '{{ ccr1 }}'
+ resource_pool: DC0_C0_RP1
+ mem_shares: normal
+ mem_limit: -1
+ mem_reservation: 0
+ mem_expandable_reservations: true
+ cpu_shares: normal
+ cpu_limit: -1
+ cpu_reservation: 0
+ cpu_expandable_reservations: true
+ state: present
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml
new file mode 100644
index 00000000..c63a28c5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_switch.yml
@@ -0,0 +1,7 @@
+---
+- name: Add a VMware vSwitchs
+ vmware_vswitch:
+ esxi_hostname: '{{ item }}'
+ switch_name: "{{ switch1 }}"
+ state: present
+ with_items: "{{ esxi_hosts }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_tag.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_tag.yml
new file mode 100644
index 00000000..31b495c0
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_tag.yml
@@ -0,0 +1,15 @@
+- name: Get Category facts
+ vmware_category_info:
+ register: cat_info
+
+- name: Get Category id for {{ cluster_category }}
+ set_fact:
+ cluster_category_id: "{{ cat_info.tag_category_info[0].category_id }}"
+
+- name: Create a tag for cluster
+ vmware_tag:
+ category_id: '{{ cluster_category_id }}'
+ tag_name: '{{ cluster_tag }}'
+ tag_description: '{{ cluster_tag }} Description'
+ state: present
+ when: cluster_category_id is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml
new file mode 100644
index 00000000..5506fb13
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml
@@ -0,0 +1,47 @@
+---
+- name: Create VMs
+ vmware_guest:
+ datacenter: "{{ dc1 }}"
+ folder: '{{ item.folder }}'
+ name: '{{ item.name }}'
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_mb: 10
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ version: 11
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+ with_items: '{{ virtual_machines }}'
+
+
+- name: Create VMs in cluster
+ vmware_guest:
+ datacenter: "{{ dc1 }}"
+ folder: '{{ item.folder }}'
+ cluster: '{{ item.cluster }}'
+ name: '{{ item.name }}'
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+ with_items: '{{ virtual_machines_in_cluster }}'
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown.yml
new file mode 100644
index 00000000..b5e42118
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown.yml
@@ -0,0 +1,22 @@
+---
+- name: Get a list of all the datacenters
+ vmware.vmware_rest.vcenter_datacenter_info:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ register: existing_datacenters
+- name: Force delete the existing DC
+ vmware.vmware_rest.vcenter_datacenter:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ state: absent
+ datacenter: '{{ item.datacenter }}'
+ force: true
+ with_items: "{{ existing_datacenters.value }}"
+ until: _result is succeeded
+ retries: 10
+ delay: 1
+ register: _result
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown_with_esxi.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown_with_esxi.yml
new file mode 100644
index 00000000..db4c165d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/teardown_with_esxi.yml
@@ -0,0 +1,94 @@
+---
+- name: Collect the list of the existing VM
+ vmware.vmware_rest.vcenter_vm_info:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ register: existing_vms
+ until: existing_vms is not failed
+
+- name: Turn off the VM
+ vmware.vmware_rest.vcenter_vm_power:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ state: stop
+ vm: '{{ item.vm }}'
+ with_items: "{{ existing_vms.value }}"
+ ignore_errors: true
+
+- name: Delete the VMs
+ vmware.vmware_rest.vcenter_vm:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ state: absent
+ vm: '{{ item.vm }}'
+ with_items: "{{ existing_vms.value }}"
+ when:
+ - not item.name.startswith("vCLS")
+
+
+- name: Build a list of local libraries
+ vmware.vmware_rest.content_locallibrary_info:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ register: result
+ retries: 100
+ delay: 3
+ until: result is not failed
+
+- name: Delete all the local libraries
+ vmware.vmware_rest.content_locallibrary:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ library_id: "{{ item.id }}"
+ state: absent
+ with_items: "{{ result.value }}"
+
+- name: Build a list of subscribed libraries
+ vmware.vmware_rest.content_subscribedlibrary_info:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ register: result
+
+- name: Delete all the subscribed libraries
+ vmware.vmware_rest.content_subscribedlibrary:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ library_id: "{{ item.id }}"
+ state: absent
+ with_items: "{{ result.value }}"
+
+- name: Get a list of all the datacenters
+ vmware.vmware_rest.vcenter_datacenter_info:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ register: existing_datacenters
+- name: Force delete the existing DC
+ vmware.vmware_rest.vcenter_datacenter:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ state: absent
+ datacenter: '{{ item.datacenter }}'
+ force: true
+ with_items: "{{ existing_datacenters.value }}"
+ until: _result is succeeded
+ retries: 10
+ delay: 1
+ register: _result
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/common.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/common.yml
new file mode 100644
index 00000000..bfe5a30f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/common.yml
@@ -0,0 +1,12 @@
+---
+dc1: DC0
+ccr1: DC0_C0
+f0: F0
+switch1: switch1
+esxi1: '{{ esxi_hosts[0] }}'
+esxi2: '{{ esxi_hosts[1] }}'
+esxi3: '{{ esxi_hosts[2] }}'
+dvswitch1: DVS0
+esxi_user: root
+dvpg1: DC0_DVPG0
+dvpg_with_slash: DVPG/1
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_1esxi.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_1esxi.yml
new file mode 100644
index 00000000..45e94331
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_1esxi.yml
@@ -0,0 +1,33 @@
+---
+esxi_hosts:
+ - esxi1.test
+rw_datastore: rw_datastore
+ro_datastore: ro_datastore
+esxi_password: '{{ esxi1_password }}'
+esxi_user: '{{ esxi1_username }}'
+infra:
+ datastores:
+ rw_datastore:
+ type: nfs
+ server: datastore.test
+ path: /srv/share/vms
+ ro: false
+ ro_datastore:
+ type: nfs
+ server: datastore.test
+ path: /srv/share/isos
+ ro: true
+virtual_machines:
+ - name: DC0_H0_VM0
+ folder: '{{ f0 }}'
+ - name: DC0_H0_VM1
+ folder: '{{ f0 }}'
+virtual_machines_in_cluster:
+ - name: DC0_C0_RP0_VM0
+ folder: '{{ f0 }}'
+ cluster: '{{ ccr1 }}'
+ - name: DC0_C0_RP0_VM1
+ folder: '{{ f0 }}'
+ cluster: '{{ ccr1 }}'
+cluster_tag: test_cluster_tag_0001
+cluster_category: test_cluster_cat_0001
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_2esxi.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_2esxi.yml
new file mode 100644
index 00000000..6b0203b4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_2esxi.yml
@@ -0,0 +1,34 @@
+---
+esxi_hosts:
+ - esxi1.test
+ - esxi2.test
+rw_datastore: rw_datastore
+ro_datastore: ro_datastore
+esxi_password: '{{ esxi1_password }}'
+esxi_user: '{{ esxi1_username }}'
+infra:
+ datastores:
+ rw_datastore:
+ type: nfs
+ server: datastore.test
+ path: /srv/share/vms
+ ro: false
+ ro_datastore:
+ type: nfs
+ server: datastore.test
+ path: /srv/share/isos
+ ro: true
+virtual_machines:
+ - name: DC0_H0_VM0
+ folder: '{{ f0 }}'
+ - name: DC0_H0_VM1
+ folder: '{{ f0 }}'
+virtual_machines_in_cluster:
+ - name: DC0_C0_RP0_VM0
+ folder: '{{ f0 }}'
+ cluster: '{{ ccr1 }}'
+ - name: DC0_C0_RP0_VM1
+ folder: '{{ f0 }}'
+ cluster: '{{ ccr1 }}'
+cluster_tag: test_cluster_tag_0001
+cluster_category: test_cluster_cat_0001
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_only.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_only.yml
new file mode 100644
index 00000000..58560b56
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/vars/vcenter_only.yml
@@ -0,0 +1,6 @@
+---
+esxi_hosts: []
+infra:
+virtual_machines: []
+virtual_machines_in_cluster: []
+#esxi_password: '' \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/aliases b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/aliases
new file mode 100644
index 00000000..2c3bba96
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/aliases
@@ -0,0 +1,6 @@
+cloud/vcenter
+destructive
+needs/file/contrib/inventory/vmware_inventory.py
+needs/file/contrib/inventory/vmware_inventory.ini
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/runme.sh b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/runme.sh
new file mode 100755
index 00000000..fcfc1c8c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/runme.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
+
+set -euo pipefail
+
+contrib_dir=../../../../contrib/inventory
+
+echo "DEBUG: using ${contrib_dir}"
+
+export ANSIBLE_CONFIG=ansible.cfg
+export VMWARE_SERVER="${VCENTER_HOSTNAME}"
+export VMWARE_USERNAME="${VCENTER_USERNAME}"
+export VMWARE_PASSWORD="${VCENTER_PASSWORD}"
+
+VMWARE_CONFIG=${contrib_dir}/vmware_inventory.ini
+
+
+trap cleanup INT TERM EXIT
+
+# Remove default inventory config file
+if [ -f "${VMWARE_CONFIG}" ];
+then
+ echo "DEBUG: Creating backup of ${VMWARE_CONFIG}"
+ cp "${VMWARE_CONFIG}" "${VMWARE_CONFIG}.bk"
+fi
+
+cat > "${VMWARE_CONFIG}" <<VMWARE_INI
+[vmware]
+server=${VMWARE_SERVER}
+username=${VMWARE_USERNAME}
+password=${VMWARE_PASSWORD}
+validate_certs=False
+VMWARE_INI
+
+function cleanup {
+ # Revert back to previous one
+ if [ -f "${VMWARE_CONFIG}.bk" ]; then
+ echo "DEBUG: Cleanup ${VMWARE_CONFIG}"
+ mv "${VMWARE_CONFIG}.bk" "${VMWARE_CONFIG}"
+ fi
+}
+
+echo "DEBUG: Using ${VCENTER_HOSTNAME} with username ${VCENTER_USERNAME} and password ${VCENTER_PASSWORD}"
+
+echo "Kill all previous instances"
+curl "http://${VCENTER_HOSTNAME}:5000/killall" > /dev/null 2>&1
+
+echo "Start new VCSIM server"
+curl "http://${VCENTER_HOSTNAME}:5000/spawn?datacenter=1&cluster=1&folder=0" > /dev/null 2>&1
+
+echo "Debugging new instances"
+curl "http://${VCENTER_HOSTNAME}:5000/govc_find"
+
+# Get inventory
+ansible-playbook -i ./vmware_inventory.sh "./test_vmware_inventory.yml" --connection=local "$@"
+
+echo "DEBUG: Done"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/test_vmware_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/test_vmware_inventory.yml
new file mode 100644
index 00000000..035d1d16
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/test_vmware_inventory.yml
@@ -0,0 +1,18 @@
+# Test code for the vmware guest contrib inventory
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+---
+- name: Test VMware guest contrib inventroy script
+ hosts: localhost
+ tasks:
+ - name: store the vcenter container ip
+ set_fact:
+ vcsim: "{{ lookup('env', 'VCENTER_HOSTNAME') }}"
+
+ - name: Check that groups present in inventory
+ assert:
+ that:
+ - "'{{item}}' in groups"
+ with_items:
+ - all
diff --git a/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/vmware_inventory.sh b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/vmware_inventory.sh
new file mode 100644
index 00000000..5ec1972e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/script_inventory_vmware_inventory/vmware_inventory.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+python.py "../../../../contrib/inventory/vmware_inventory.py" "$@"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/tasks/main.yml
new file mode 100644
index 00000000..6c7b955f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_domain_user_group_info/tasks/main.yml
@@ -0,0 +1,177 @@
+# Test code for the vcenter_domain_user_group_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Gather all domain user and group of vsphere.local
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: ''
+ register: gather_all_domain_user_group_result
+
+- name: Make sure if domain_user_groups attribute is existing
+ assert:
+ that:
+ - gather_all_domain_user_group_result.domain_user_groups is defined
+ - gather_all_domain_user_group_result.domain_user_groups | length >= 1
+
+- name: Gather all domain user and group included the admin string
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: admin
+ register: gather_domain_user_group_result
+
+- name: Make sure if multiple users are existing and included the admin string
+ assert:
+ that:
+ - >-
+ gather_domain_user_group_result.domain_user_groups
+ | map(attribute='principal')
+ | map('upper')
+ | map('regex_search', 'ADMIN')
+ | select('none')
+ | list
+ | length == 0
+ - gather_domain_user_group_result.domain_user_groups | length >= 2
+
+- name: Gather all domain user of vsphere.local
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: ''
+ find_users: true
+ find_groups: false
+ register: gather_all_domain_user_result
+
+- name: Make sure if the result doesn't include domain groups
+ assert:
+ that:
+ - >-
+ gather_all_domain_user_result.domain_user_groups
+ | map(attribute='group')
+ | select('true')
+ | list
+ | length == 0
+
+- name: Gather all domain group of vsphere.local
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: ''
+ find_users: false
+ find_groups: true
+ register: gather_all_domain_group_result
+
+- name: Make sure if the result doesn't include domain users
+ assert:
+ that:
+ - >-
+ gather_all_domain_group_result.domain_user_groups
+ | map(attribute='group')
+ | select('false')
+ | list
+ | length == 0
+
+- name: Gather administrator user only of domain
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: administrator
+ find_users: true
+ find_groups: false
+ register: gather_administrator_user_only_result
+
+- name: Make sure if the administrator user only is existing in result
+ assert:
+ that:
+ - gather_administrator_user_only_result.domain_user_groups | length == 1
+ - gather_administrator_user_only_result.domain_user_groups.0.principal == "Administrator"
+ - gather_administrator_user_only_result.domain_user_groups.0.group is sameas false
+
+- name: Gather DCAdmins group only of domain
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: DCAdmins
+ find_users: false
+ find_groups: true
+ register: gather_dcadmins_group_only_result
+
+- name: Make sure if the DCAdmins group only is existing in result
+ assert:
+ that:
+ - gather_dcadmins_group_only_result.domain_user_groups | length == 1
+ - gather_dcadmins_group_only_result.domain_user_groups.0.principal == "DCAdmins"
+ - gather_dcadmins_group_only_result.domain_user_groups.0.group is sameas true
+
+- name: Gather administrators included to LicenseService.Administrators group
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: administrators
+ belongs_to_group: LicenseService.Administrators
+ register: gather_administrators_license_service_group_result
+
+- name: Make sure if the administrators a member of LicenseService.Administrtors group is existing
+ assert:
+ that:
+ - gather_administrators_license_service_group_result.domain_user_groups | length == 1
+ - gather_administrators_license_service_group_result.domain_user_groups.0.principal == "Administrators"
+
+- name: Gather LicenseService.Administrators group included to administrators user
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: LicenseService.Administrators
+ belongs_to_user: administrators
+ register: gather_license_service_group_administrator_result
+
+- name: Make sure if the administrators belonging to LicenseService.Administrtors group is existing
+ assert:
+ that:
+ - gather_license_service_group_administrator_result.domain_user_groups | length == 1
+ - gather_license_service_group_administrator_result.domain_user_groups.0.principal == "LicenseService.Administrators"
+
+- name: Gather administrator user by exact match condition
+ vcenter_domain_user_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ domain: vsphere.local
+ search_string: "vsphere.local\\administrator"
+ exact_match: true
+ register: gather_administrator_user_exact_match_result
+
+- name: Make sure if administrator user is existing by exact match
+ assert:
+ that:
+ - gather_administrator_user_exact_match_result.domain_user_groups.0.principal == "VSPHERE.LOCAL\\Administrator"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/meta/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/meta/main.yml
new file mode 100644
index 00000000..828342c2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/tasks/main.yml
new file mode 100644
index 00000000..61eb6ed9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_extension_info/tasks/main.yml
@@ -0,0 +1,13 @@
+- name: Gather info about vCenter Extensions
+ vcenter_extension_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: ext_info
+
+- name: ensure the result is ok
+ assert:
+ that:
+ - ext_info.extension_info| length >= 10
+ - ext_info.extension_info[0]["extension_version"] != ""
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/aliases b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/meta/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/meta/main.yml
new file mode 100644
index 00000000..828342c2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/main.yml
new file mode 100644
index 00000000..1afe2769
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/main.yml
@@ -0,0 +1,214 @@
+# Test code for the vcenter_folder module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create all types of folder in check mode
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "{{ item }}_folder"
+ folder_type: "{{ item }}"
+ state: present
+ register: all_folder_results
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+ check_mode: true
+
+- debug:
+ msg: "{{ all_folder_results }}"
+
+- name: ensure everything for {{ dc1 }}
+ assert:
+ that:
+ - all_folder_results.changed
+
+- name: Create all types of folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "{{ item }}_folder"
+ folder_type: "{{ item }}"
+ state: present
+ register: all_folder_results
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+
+- debug:
+ msg: "{{ all_folder_results }}"
+
+- name: ensure everything for {{ dc1 }}
+ assert:
+ that:
+ - all_folder_results.changed
+
+- name: Create all types of sub folder in check mode
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "sub_{{ item }}_folder"
+ parent_folder: 'vm_folder'
+ state: present
+ register: all_folder_results
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+ check_mode: true
+
+- debug:
+ msg: "{{ all_folder_results }}"
+
+- name: ensure everything for {{ dc1 }}
+ assert:
+ that:
+ - all_folder_results.changed
+
+- name: Create all types of sub folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "sub_{{ item }}_folder"
+ parent_folder: 'vm_folder'
+ state: present
+ register: all_folder_results
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+
+- name: Recreate all types of sub folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "sub_{{ item }}_folder"
+ parent_folder: 'vm_folder'
+ state: present
+ register: recreate_folders
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+
+- name: Create a 3rd level of directory
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: yet_another_level
+ parent_folder: vm_folder/sub_vm_folder
+ state: present
+ register: yet_another_level
+- debug: var=yet_another_level
+
+- name: Recreate a 3rd level of directory
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: yet_another_level
+ parent_folder: vm_folder/sub_vm_folder
+ state: present
+ register: recreate_yet_another_level
+- debug: var=recreate_yet_another_level
+
+- debug:
+ msg: "{{ all_folder_results }}"
+
+- name: ensure everything for {{ dc1 }}
+ assert:
+ that:
+ - all_folder_results.changed
+ - not recreate_folders.changed
+ - not recreate_yet_another_level.changed
+
+- name: Remove a 3rd level of directory
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: yet_another_level
+ parent_folder: vm_folder/sub_vm_folder
+ state: absent
+ register: remove_yet_another_level
+- debug: var=remove_yet_another_level
+
+- name: Delete all types of folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "{{ item }}_folder"
+ folder_type: "{{ item }}"
+ state: absent
+ register: all_folder_results
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+
+- debug: msg="{{ all_folder_results }}"
+
+- name: ensure everything for {{ dc1 }}
+ assert:
+ that:
+ - all_folder_results.changed
+
+- name: Delete all types of folder again
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "{{ item }}_folder"
+ folder_type: "{{ item }}"
+ state: absent
+ register: all_folder_results
+ with_items:
+ - vm
+ - host
+ - datastore
+ - network
+
+- debug: msg="{{ all_folder_results }}"
+
+- name: ensure everything for {{ dc1 }}
+ assert:
+ that:
+ - not all_folder_results.changed
+
+- block:
+ - include_tasks: regression_folder_collision.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/regression_folder_collision.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/regression_folder_collision.yml
new file mode 100644
index 00000000..b9ee548d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_folder/tasks/regression_folder_collision.yml
@@ -0,0 +1,135 @@
+# Test code for the vcenter_folder module.
+# Copyright: (c) 2021, Victor Dvornikov <spacefuryphonk@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create first lvl vm folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "foo"
+ folder_type: "vm"
+ state: present
+ register: creation_result
+
+- debug:
+ msg: "{{ creation_result }}"
+
+- name: Create second lvl vm folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "bar"
+ parent_folder: "foo"
+ folder_type: "vm"
+ state: present
+ register: creation_result
+
+- debug:
+ msg: "{{ creation_result }}"
+
+- name: Create collision third lvl vm folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "collision_folder"
+ parent_folder: "foo/bar"
+ folder_type: "vm"
+ state: present
+ register: creation_result
+
+- debug:
+ msg: "{{ creation_result }}"
+
+- name: Delete missed second lvl vm folder using name collision
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "collision_folder"
+ parent_folder: "foo"
+ folder_type: "vm"
+ state: absent
+ register: deletion_result
+
+- debug:
+ msg: "{{ deletion_result }}"
+
+- name: Assert collision folder wasn't deleted
+ assert:
+ that:
+ - not deletion_result.changed
+
+- name: Check present collision folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "collision_folder"
+ parent_folder: "foo/bar"
+ folder_type: "vm"
+ state: present
+ register: check_present_result
+ check_mode: true
+
+- debug:
+ msg: "{{ check_present_result }}"
+
+- name: Assert collision folder is still present
+ assert:
+ that:
+ - not deletion_result.changed
+
+- name: Delete third lvl folder first time
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "collision_folder"
+ parent_folder: "foo/bar"
+ folder_type: "vm"
+ state: absent
+ register: deletion_result
+
+- debug:
+ msg: "{{ deletion_result }}"
+
+- name: Assert third lvl folder has been successfully deleted
+ assert:
+ that:
+ - deletion_result.changed
+
+- name: Delete third lvl folder again
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "collision_folder"
+ parent_folder: "foo/bar"
+ folder_type: "vm"
+ state: absent
+ register: deletion_result
+
+- debug:
+ msg: "{{ deletion_result }}"
+
+- name: Assert third lvl folder has already been deleted earlier
+ assert:
+ that:
+ - not deletion_result.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/aliases b/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/aliases
new file mode 100644
index 00000000..b268038d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/meta/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/meta/main.yml
new file mode 100644
index 00000000..828342c2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/tasks/main.yml
new file mode 100644
index 00000000..4dba790c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_license/tasks/main.yml
@@ -0,0 +1,25 @@
+# Test code for the vcenter license module.
+# Copyright: (c) 2017, Dag Wieers <dag@wieers.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Add a vCenter evaluation license
+ vcenter_license: &vcenter_lic_data
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ license: 00000-00000-00000-00000-00000
+ state: present
+
+- name: Remove an (unused) vCenter evaluation license
+ vcenter_license:
+ <<: *vcenter_lic_data
+ state: absent
+
+- name: Add an invalid vCenter license
+ vcenter_license:
+ <<: *vcenter_lic_data
+ license: 00000-00000-00000-00000-00001
+ state: present
+ register: vcenter_license_output
+ failed_when: '"is not existing or can not be added" not in vcenter_license_output.msg'
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml
new file mode 100644
index 00000000..94a9941d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml
@@ -0,0 +1,58 @@
+# Test code for the vmware_about_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Get Details about VMware vCenter Server
+ vmware_about_info: &vmware_about_data
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: about
+
+- assert:
+ that:
+ - about.about_info["{{ item }}"] is defined
+ with_items:
+ - api_type
+ - api_version
+ - build
+ - instance_uuid
+ - license_product_name
+ - license_product_version
+ - locale_build
+ - locale_version
+ - os_type
+ - product_full_name
+ - product_line_id
+ - product_name
+ - vendor
+ - version
+
+- name: Get Details about VMware vCenter Server in check mode
+ vmware_about_info:
+ <<: *vmware_about_data
+ register: about
+ check_mode: true
+
+- assert:
+ that:
+ - about.about_info["{{ item }}"] is defined
+ with_items:
+ - api_type
+ - api_version
+ - build
+ - instance_uuid
+ - license_product_name
+ - license_product_version
+ - locale_build
+ - locale_version
+ - os_type
+ - product_full_name
+ - product_line_id
+ - product_name
+ - vendor
+ - version
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml
new file mode 100644
index 00000000..3069f15d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml
@@ -0,0 +1,38 @@
+# Test code for the vmware_category Operations.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create category named {{ category_name }}
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: '{{ category_name }}'
+ category_description: '{{ category_name }}'
+ category_cardinality: 'multiple'
+ associable_object_types:
+ - '{{ category_name }}'
+
+- name: Gather category info
+ vmware_category_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: tag_category_results
+
+- name: Get Category datatype for {{ category_name }}
+ set_fact:
+ category_datatype: "{{ cat_obj.category_associable_types }}"
+ loop: "{{ tag_category_results.tag_category_info | selectattr('category_name', 'equalto', category_name) | list }}"
+ loop_control:
+ loop_var: cat_obj
+
+- debug:
+ msg: "{{ category_datatype }}"
+
+- name: Check if we get correct associable datatype for {{ category_name }}
+ assert:
+ that:
+ - "'{{ expected_result }}' in {{ category_datatype }}" \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_types.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_types.yml
new file mode 100644
index 00000000..1977a015
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_types.yml
@@ -0,0 +1,123 @@
+# Test code for the vmware_category Operations.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Define required data
+ set_fact:
+ cat_data:
+ - name: 'Folder'
+ result: 'Folder'
+ - name: 'Cluster'
+ result: 'ClusterComputeResource'
+ - name: Datacenter
+ result: Datacenter
+ - name: Datastore
+ result: Datastore
+ - name: 'Datastore Cluster'
+ result: 'StoragePod'
+ - name: 'Distributed Port Group'
+ result: 'DistributedVirtualPortgroup'
+ - name: 'Distributed Switch'
+ result: 'VmwareDistributedVirtualSwitch'
+ - name: 'Host'
+ result: 'HostSystem'
+ - name: 'Content Library'
+ result: 'com.vmware.content.Library'
+ - name: 'Library item'
+ result: 'com.vmware.content.library.Item'
+ - name: 'Network'
+ result: 'Network'
+ - name: 'Host Network'
+ result: 'HostNetwork'
+ - name: 'Opaque Network'
+ result: 'OpaqueNetwork'
+ - name: 'Resource Pool'
+ result: 'ResourcePool'
+ - name: 'vApp'
+ result: 'VirtualApp'
+ - name: 'Virtual Machine'
+ result: 'VirtualMachine'
+
+- include_tasks: associable_obj_test.yml
+ vars:
+ category_name: "{{ item.name }}"
+ expected_result: "{{ item.result }}"
+ with_items: "{{ cat_data }}"
+
+- name: Delete different types of category with associable object types
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: '{{ item.name }}'
+ state: absent
+ with_items: "{{ cat_data }}"
+
+- name: Create category with 2 associable object types
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: 'Sample_cate_0001'
+ category_description: 'sample description'
+ associable_object_types:
+ - Datastore
+ - Cluster
+ state: present
+ register: category_change
+
+- name: Assert change is made
+ assert:
+ that:
+ - category_change.changed
+
+- name: Delete category with 2 associable object types
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: 'Sample_cate_0001'
+ state: absent
+ register: category_change
+
+- name: Assert change is made
+ assert:
+ that:
+ - category_change.changed
+
+# Added the test for the PR(https://github.com/ansible-collections/community.vmware/pull/990)
+- name: Create a new category with All objects
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: 'Sample_cate_0002'
+ category_description: 'sample description'
+ associable_object_types:
+ - All objects
+ state: present
+ register: category_change_all_objects
+
+- name: Assert change is made
+ assert:
+ that:
+ - category_change_all_objects.changed
+
+- name: Delete Sample_cate_0002 category
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: 'Sample_cate_0002'
+ state: absent
+ register: category_change
+
+- name: Assert change is made
+ assert:
+ that:
+ - category_change.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml
new file mode 100644
index 00000000..598e9da4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml
@@ -0,0 +1,7 @@
+# Test code for the vmware_category Operations.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+- include: associable_obj_types.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/tasks/main.yml
new file mode 100644
index 00000000..e7e150c8
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cfg_backup/tasks/main.yml
@@ -0,0 +1,33 @@
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Save the ESXi configuration locally by authenticating against the vCenter and selecting the ESXi host
+ community.vmware.vmware_cfg_backup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ dest: /tmp/
+ state: saved
+ register: cfg_backup_vcenter
+
+- name: Ensure config was saved
+ assert:
+ that:
+ - cfg_backup_vcenter is changed
+
+- name: Save the ESXi configuration locally directly from the ESXi host
+ community.vmware.vmware_cfg_backup:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi1_username }}"
+ password: "{{ esxi1_password }}"
+ dest: /tmp/
+ state: saved
+ register: cfg_backup_esxi
+
+- name: Ensure config was saved
+ assert:
+ that:
+ - cfg_backup_esxi is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/tasks/main.yml
new file mode 100644
index 00000000..4da7a6f1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster/tasks/main.yml
@@ -0,0 +1,120 @@
+# Test code for the vmware_cluster module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+# Testcase 0001: Add Cluster
+- &add_cluster
+ name: add cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_0001
+ state: present
+ register: cluster_result_0001
+
+- &ensure_changed
+ name: ensure cluster is present
+ assert:
+ that:
+ - "{{ cluster_result_0001.changed == true }}"
+
+# # Broken by: https://github.com/ansible/ansible/issues/54857
+# - <<: *add_cluster
+# name: add cluster (again)
+
+# - &ensure_unchanged
+# name: ensure cluster is unchanged
+# assert:
+# that:
+# - "{{ cluster_result_0001.changed == false }}"
+
+- &del_cluster
+ name: delete cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_0001
+ state: absent
+ register: cluster_result_0001
+
+- <<: *ensure_changed
+
+- <<: *del_cluster
+ name: delete cluster (again)
+
+#- <<: *ensure_unchanged
+- name: ensure cluster is unchanged
+ assert:
+ that:
+ - "{{ cluster_result_0001.changed == false }}"
+
+- name: Create Cluster with special characters
+ vmware_cluster:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: 'Cluster\/%'
+ state: present
+ register: create_cluster_with_special_characters_result
+
+- assert:
+ that:
+ - create_cluster_with_special_characters_result.changed is sameas true
+
+- name: Create Cluster with special characters(idempotency check)
+ vmware_cluster:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: 'Cluster\/%'
+ state: present
+ register: create_cluster_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - create_cluster_with_special_characters_idempotency_check_result.changed is sameas false
+
+- name: Delete Cluster with special characters
+ vmware_cluster:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: 'Cluster\/%'
+ state: absent
+ register: delete_cluster_with_special_characters_result
+
+- assert:
+ that:
+ - delete_cluster_with_special_characters_result.changed is sameas true
+
+- name: Delete Cluster with special characters(idempotency check)
+ vmware_cluster:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: 'Cluster\/%'
+ state: absent
+ register: delete_cluster_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - delete_cluster_with_special_characters_idempotency_check_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/aliases
new file mode 100644
index 00000000..559d0771
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
+zuul/vmware/govcsim
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/tasks/main.yml
new file mode 100644
index 00000000..6e4c4483
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_dpm/tasks/main.yml
@@ -0,0 +1,62 @@
+# Test code for the vmware_cluster module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+# Setup: Create test cluster
+- name: Create test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_dpm
+ state: present
+
+# Testcase 0001: Enable DPM
+- name: Enable DPM
+ vmware_cluster_dpm:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_dpm
+ enable_dpm: true
+ register: cluster_dpm_result_0001
+
+- name: Ensure DPM is enabled
+ assert:
+ that:
+ - "{{ cluster_dpm_result_0001.changed == true }}"
+
+# Testcase 0002: Disable DPM
+- name: Disable DPM
+ vmware_cluster_dpm:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_dpm
+ enable_dpm: false
+ register: cluster_dpm_result_0002
+
+- name: Ensure DPM is disabled
+ assert:
+ that:
+ - "{{ cluster_dpm_result_0002.changed == true }}"
+
+# Delete test cluster
+- name: Delete test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_dpm
+ state: absent \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/tasks/main.yml
new file mode 100644
index 00000000..3e4b77a4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_drs/tasks/main.yml
@@ -0,0 +1,157 @@
+# Test code for the vmware_cluster module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+# Setup: Create test cluster
+- name: Create test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ state: present
+
+# Testcase 0001: Enable DRS
+- name: Enable DRS
+ vmware_cluster_drs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ enable: true
+ register: cluster_drs_result_0001
+
+- name: Ensure DRS is enabled
+ assert:
+ that:
+ - "{{ cluster_drs_result_0001.changed == true }}"
+
+# Testcase 0002: Disable DRS
+- name: Disable DRS
+ vmware_cluster_drs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ enable: false
+ register: cluster_drs_result_0002
+
+- name: Ensure DRS is disabled
+ assert:
+ that:
+ - "{{ cluster_drs_result_0002.changed == true }}"
+
+- name: Enable DRS for the following tests
+ vmware_cluster_drs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ enable: true
+ register: cluster_drs_result_0001
+
+- name: Change advanced setting "TryBalanceVmsPerHost" (check-mode)
+ vmware_cluster_drs: &change_balance_vms
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ enable: true
+ advanced_settings:
+ 'TryBalanceVmsPerHost': '1'
+ check_mode: true
+ register: change_balance_vms_check
+
+- assert:
+ that:
+ - change_balance_vms_check.changed
+
+- name: Change advanced setting "TryBalanceVmsPerHost"
+ vmware_cluster_drs: *change_balance_vms
+ register: change_balance_vms
+
+- assert:
+ that:
+ - change_balance_vms.changed
+
+- name: Change advanced setting "TryBalanceVmsPerHost" again (idempotency)
+ vmware_cluster_drs: *change_balance_vms
+ register: change_balance_vms_again
+
+- assert:
+ that:
+ - not change_balance_vms_again.changed
+
+- name: Try to deactivate already off predictive drs setting (check-mode)
+ vmware_cluster_drs: &change_predictive_drs_deactivate
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ enable: true
+ predictive_drs: false
+ check_mode: true
+ register: change_predictive_drs_check
+
+- assert:
+ that:
+ - not change_predictive_drs_check.changed
+
+- name: Try to activate predictive drs setting (check-mode)
+ vmware_cluster_drs: &change_predictive_drs_activate
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ enable: true
+ predictive_drs: true
+ check_mode: true
+ register: change_predictive_drs_check
+
+- assert:
+ that:
+ - change_predictive_drs_check.changed
+
+- name: Try to deactivate already off predictive drs setting
+ vmware_cluster_drs: *change_predictive_drs_deactivate
+ register: change_predictive_drs_check
+
+- assert:
+ that:
+ - not change_predictive_drs_check.changed
+
+- name: Try to activate predictive drs setting
+ vmware_cluster_drs: *change_predictive_drs_activate
+ register: change_predictive_drs_check
+
+- assert:
+ that:
+ - change_predictive_drs_check.changed
+
+# Delete test cluster
+- name: Delete test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_drs
+ state: absent
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/tasks/main.yml
new file mode 100644
index 00000000..065394ce
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_ha/tasks/main.yml
@@ -0,0 +1,303 @@
+# Test code for the vmware_cluster module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+# Setup: Create test cluster
+- name: Create test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ state: present
+
+- name: Enable HA
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ register: enable_ha_result
+
+- name: Ensure HA is enabled
+ assert:
+ that:
+ - enable_ha_result.changed
+
+- name: Disable HA
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: false
+ register: disable_ha_result
+
+- name: Ensure HA is disabled
+ assert:
+ that:
+ - disable_ha_result.changed
+
+- name: Change APD response to "restartAggressive" (check-mode)
+ vmware_cluster_ha: &change_apd_response
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ apd_response: 'restartAggressive'
+ check_mode: true
+ register: change_apd_response_check
+
+- assert:
+ that:
+ - change_apd_response_check.changed
+
+- name: Change APD response to "restartAggressive"
+ vmware_cluster_ha: *change_apd_response
+ register: change_apd_response
+
+- assert:
+ that:
+ - change_apd_response.changed
+
+- name: Change APD response to "restartAggressive" again (idempotency)
+ vmware_cluster_ha: *change_apd_response
+ register: change_apd_response_again
+
+- assert:
+ that:
+ - not change_apd_response_again.changed
+
+- name: Change APD response back to default
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+
+- name: Change PDL response to "restartAggressive" (check-mode)
+ vmware_cluster_ha: &change_pdl_response
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ pdl_response: 'restartAggressive'
+ check_mode: true
+ register: change_pdl_response_check
+
+- assert:
+ that:
+ - change_pdl_response_check.changed
+
+- name: Change PDL response to "restartAggressive"
+ vmware_cluster_ha: *change_pdl_response
+ register: change_pdl_response
+
+- assert:
+ that:
+ - change_pdl_response.changed
+
+- name: Change PDL response to "restartAggressive" again
+ vmware_cluster_ha: *change_pdl_response
+ register: change_pdl_response_again
+
+- assert:
+ that:
+ - not change_pdl_response_again.changed
+
+- name: Change PDL response back to default
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+
+- name: Enable Slot based Admission Control
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ slot_based_admission_control:
+ failover_level: 1
+ register: enable_slot_based_admission_control_result
+
+- name: Ensure Admission Cotrol is enabled
+ assert:
+ that:
+ - enable_slot_based_admission_control_result.changed
+
+- name: Enable Cluster resource Percentage based Admission Control
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ reservation_based_admission_control:
+ auto_compute_percentages: false
+ failover_level: 1
+ cpu_failover_resources_percent: 33
+ memory_failover_resources_percent: 33
+ register: enable_percentage_based_admission_control_result
+
+- name: Ensure Admission Cotrol is enabled
+ assert:
+ that:
+ - enable_percentage_based_admission_control_result.changed
+
+- name: Set Isolation Response to powerOff
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ host_isolation_response: 'powerOff'
+ register: isolation_response_poweroff_result
+
+- name: Ensure Isolation Response is enabled
+ assert:
+ that:
+ - isolation_response_poweroff_result.changed
+
+- name: Set Isolation Response to shutdown
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ host_isolation_response: 'shutdown'
+ register: isolation_response_shutdown_result
+
+- name: Ensure Isolation Response is enabled
+ assert:
+ that:
+ - isolation_response_shutdown_result.changed
+
+- name: Change advanced setting "number of heartbeat datastores" (check-mode)
+ vmware_cluster_ha: &change_num_heartbeat_ds
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ advanced_settings:
+ 'das.heartbeatDsPerHost': '4'
+ check_mode: true
+ register: change_num_heartbeat_ds_check
+
+- assert:
+ that:
+ - change_num_heartbeat_ds_check.changed
+
+- name: Change advanced setting "number of heartbeat datastores"
+ vmware_cluster_ha: *change_num_heartbeat_ds
+ register: change_num_heartbeat_ds
+
+- assert:
+ that:
+ - change_num_heartbeat_ds.changed
+
+- name: Change advanced setting "number of heartbeat datastores" again
+ vmware_cluster_ha: *change_num_heartbeat_ds
+ register: change_num_heartbeat_ds_again
+
+- assert:
+ that:
+ - not change_num_heartbeat_ds_again.changed
+
+- name: Change advanced setting "das.includeFTcomplianceChecks" (check-mode)
+ vmware_cluster_ha: &change_includeFTcomplianceChecks
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: true
+ advanced_settings:
+ 'das.includeFTcomplianceChecks': 'False'
+ check_mode: true
+ register: change_includeFTcomplianceChecks_check
+
+- assert:
+ that:
+ - change_includeFTcomplianceChecks_check.changed
+
+- name: Change advanced setting "das.includeFTcomplianceChecks"
+ vmware_cluster_ha: *change_includeFTcomplianceChecks
+ register: change_includeFTcomplianceChecks
+
+- assert:
+ that:
+ - change_includeFTcomplianceChecks.changed
+
+- name: Change advanced setting "das.includeFTcomplianceChecks" again
+ vmware_cluster_ha: *change_includeFTcomplianceChecks
+ register: change_includeFTcomplianceChecks_again
+
+- assert:
+ that:
+ - not change_includeFTcomplianceChecks_again.changed
+
+- name: Disable HA
+ vmware_cluster_ha:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ enable: false
+ register: disable_ha_result
+
+- name: Ensure HA is disabled
+ assert:
+ that:
+ - disable_ha_result.changed
+
+# Delete test cluster
+- name: Delete test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_ha
+ state: absent
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/tasks/main.yml
new file mode 100644
index 00000000..57240619
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_info/tasks/main.yml
@@ -0,0 +1,194 @@
+# Test code for the vmware_cluster_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- &vc_all_data
+ name: gather info about all clusters in the given datacenter
+ vmware_cluster_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ register: all_cluster_result
+
+- &ensure_vc_all_data
+ name: ensure info are gathered for all clusters
+ assert:
+ that:
+ - all_cluster_result.clusters
+ - not all_cluster_result.changed
+
+- name: ensure info are all defined
+ assert:
+ that:
+ - all_cluster_result.clusters[item].datacenter is defined
+ - all_cluster_result.clusters[item].hosts is defined
+ - all_cluster_result.clusters[item].enable_ha is defined
+ - all_cluster_result.clusters[item].ha_failover_level is defined
+ - all_cluster_result.clusters[item].ha_vm_monitoring is defined
+ - all_cluster_result.clusters[item].ha_host_monitoring is defined
+ - all_cluster_result.clusters[item].ha_admission_control_enabled is defined
+ - all_cluster_result.clusters[item].ha_restart_priority is defined
+ - all_cluster_result.clusters[item].ha_vm_tools_monitoring is defined
+ - all_cluster_result.clusters[item].ha_vm_min_up_time is defined
+ - all_cluster_result.clusters[item].ha_vm_max_failures is defined
+ - all_cluster_result.clusters[item].ha_vm_max_failure_window is defined
+ - all_cluster_result.clusters[item].ha_vm_failure_interval is defined
+ - all_cluster_result.clusters[item].enabled_drs is defined
+ - all_cluster_result.clusters[item].drs_enable_vm_behavior_overrides is defined
+ - all_cluster_result.clusters[item].drs_default_vm_behavior is defined
+ - all_cluster_result.clusters[item].drs_vmotion_rate is defined
+ - all_cluster_result.clusters[item].enabled_vsan is defined
+ - all_cluster_result.clusters[item].vsan_auto_claim_storage is defined
+ - all_cluster_result.clusters[item].tags is defined
+ - all_cluster_result.clusters[item].resource_summary is defined
+ - all_cluster_result.clusters[item].moid is defined
+ loop: "{{ all_cluster_result.clusters.keys() }}"
+
+- <<: *vc_all_data
+ name: Gather info about all clusters in the given datacenter in check mode
+ check_mode: true
+
+- debug: msg=all_cluster_result
+
+- <<: *ensure_vc_all_data
+ name: Ensure info is gathered for all clusters in check mode
+
+- &vc_cluster_data
+ name: Gather info about the given cluster
+ vmware_cluster_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: cluster_result
+
+- &ensure_vc_cluster_data
+ name: Ensure info are gathered for the given cluster
+ assert:
+ that:
+ - cluster_result.clusters
+ - not cluster_result.changed
+
+- <<: *vc_cluster_data
+ name: Gather info about the given cluster in check mode
+ check_mode: true
+
+- <<: *ensure_vc_cluster_data
+ name: Ensure info is gathered for the given cluster in check mode
+
+- name: Gather info about all clusters in the given datacenter with properties
+ vmware_cluster_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ schema: vsphere
+ properties:
+ - name
+ - configuration.dasConfig.enabled
+ - summary.totalCpu
+ register: all_cluster_result
+
+- name: Ensure info are gathered for all clusters with properteis
+ assert:
+ that:
+ - all_cluster_result.clusters
+ - all_cluster_result.clusters[item].name == item
+ - all_cluster_result.clusters[item].configuration.dasConfig.enabled is defined
+ - all_cluster_result.clusters[item].summary.totalCpu is defined
+ - not all_cluster_result.changed
+ loop: "{{ all_cluster_result.clusters.keys() }}"
+
+- name: Gather info about the given cluster with properties
+ vmware_cluster_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ schema: vsphere
+ properties:
+ - name
+ - configuration.dasConfig.enabled
+ - summary.totalCpu
+ register: cluster_result
+
+- name: Ensure info are gathered for the given cluster with properties
+ assert:
+ that:
+ - cluster_result.clusters
+ - cluster_result.clusters[item].name == item
+ - cluster_result.clusters[item].configuration.dasConfig.enabled is defined
+ - cluster_result.clusters[item].summary.totalCpu is defined
+ - not cluster_result.changed
+ loop: "{{ cluster_result.clusters.keys() }}"
+
+# Disabled until we get a fix for https://github.com/ansible-collections/vmware/issues/301
+# - import_role:
+# name: prepare_vmware_tests
+# vars:
+# setup_category: true
+# setup_tag: true
+
+# - name: Apply tag to cluster
+# vmware_tag_manager:
+# hostname: "{{ vcenter_hostname }}"
+# username: "{{ vcenter_username }}"
+# password: "{{ vcenter_password }}"
+# validate_certs: false
+# tag_names:
+# - '{{ cluster_category }}:{{ cluster_tag }}'
+# state: present
+# object_name: '{{ ccr1 }}'
+# object_type: ClusterComputeResource
+
+# - name: Get info about cluster
+# vmware_cluster_info:
+# hostname: "{{ vcenter_hostname }}"
+# username: "{{ vcenter_username }}"
+# password: "{{ vcenter_password }}"
+# validate_certs: false
+# show_tag: true
+# cluster_name: "{{ ccr1 }}"
+# register: cluster_info
+
+# - assert:
+# that:
+# - cluster_info is defined
+# - cluster_info.clusters[ccr1].tags is defined
+
+- name: "Prepare a cluster name with character to be URL-encoded"
+ vmware_cluster:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: 'Cluster/\%'
+ state: present
+ register: prepare_cluster_url_encoded_result
+
+- assert:
+ that:
+ - prepare_cluster_url_encoded_result.changed is sameas true
+
+- name: "Gather information about all datacenter"
+ vmware_cluster_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ register: all_cluster_result
+
+- name: "Ensure URL-encoded cluster name"
+ assert:
+ that:
+ - all_cluster_result.clusters['Cluster/\%']
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/aliases
new file mode 100644
index 00000000..13abb2da
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/aliases
@@ -0,0 +1,4 @@
+disabled
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml
new file mode 100644
index 00000000..9143632f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml
@@ -0,0 +1,134 @@
+# Test code for the vmware_cluster module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+# Setup: Create test cluster
+- name: Create test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ state: present
+
+# Testcase 0001: Enable vSAN
+- name: Enable vSAN
+ vmware_cluster_vsan:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ enable: true
+ register: cluster_vsan_result_0001
+
+- name: Ensure vSAN is enabled
+ assert:
+ that:
+ - "{{ cluster_vsan_result_0001.changed == true }}"
+
+# Testcase 0002: Enable vSAN again (check for idempotency)
+- name: Enable vSAN again (check for idempotency)
+ vmware_cluster_vsan:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ enable: true
+ register: cluster_vsan_result_0002
+
+- name: Ensure vSAN is not enabled again
+ assert:
+ that:
+ - "{{ cluster_vsan_result_0002.changed == false }}"
+
+# Testcase 0003: Change object repair timer
+- name: Change object repair timer
+ vmware_cluster_vsan:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ enable: true
+ advanced_options:
+ object_repair_timer: 67
+ register: cluster_vsan_result_0003
+
+- name: Ensure object repair timer is changed
+ assert:
+ that:
+ - "{{ cluster_vsan_result_0003.changed == true }}"
+
+# Testcase 0004: Change object repair timer again (check for idempotency)
+- name: Change object repair timer again (check for idempotency)
+ vmware_cluster_vsan:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ enable: true
+ advanced_options:
+ object_repair_timer: 67
+ register: cluster_vsan_result_0004
+
+- name: Ensure object repair timer is not changed again
+ assert:
+ that:
+ - "{{ cluster_vsan_result_0004.changed == false }}"
+
+# Testcase 0005: Disable vSAN
+- name: Disable vSAN
+ vmware_cluster_vsan:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ enable: false
+ register: cluster_vsan_result_0005
+
+- name: Ensure vSAN is disabled
+ assert:
+ that:
+ - "{{ cluster_vsan_result_0005.changed == true }}"
+
+# Testcase 0006: Disable vSAN again (check for idempotency)
+- name: Disable vSAN again (check for idempotency)
+ vmware_cluster_vsan:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ enable: false
+ register: cluster_vsan_result_0006
+
+- name: Ensure vSAN is not disabled again
+ assert:
+ that:
+ - "{{ cluster_vsan_result_0006.changed == false }}"
+
+# Delete test cluster
+- name: Delete test cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_vsan
+ state: absent
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/aliases
new file mode 100644
index 00000000..a6a5f023
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+unsupported
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/tasks/main.yml
new file mode 100644
index 00000000..bfa783d3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_deploy_template/tasks/main.yml
@@ -0,0 +1,35 @@
+# Test code for the deploy VM from content library template.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+- &deploy_vm_from_content_library_template
+ vmware_content_deploy_template:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ template: '{{ test_vm_temp }}'
+ datastore: '{{ rw_datastore }}'
+ datacenter: '{{ dc1 }}'
+ folder: '{{ f0 }}'
+ host: '{{ esx1 }}'
+ name: 'test_content_deploy_vm'
+ state: poweredon
+ validate_certs: false
+ register: template_deploy
+
+- name: Check VM deployed successfully
+ assert:
+ that:
+ - template_deploy.changed
+
+- <<: *deploy_vm_from_content_library_template
+ name: Deploy VM from template again
+
+- name: Check VM with same name is deployed
+ assert:
+ that:
+ - not template_deploy.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/tasks/main.yml
new file mode 100644
index 00000000..c7d63edf
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_info/tasks/main.yml
@@ -0,0 +1,37 @@
+# Test code for the vmware_content_library_info.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_content_library: true
+
+# Get List of Content Libraries
+- name: Get List of Content Libraries
+ vmware_content_library_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ register: content_library_info
+
+- debug: var=content_library_info
+- set_fact: content_library="{{ content_library_info['content_libs'][0] }}"
+
+# Get Details of content library
+- name: Get facts about Content Library
+ vmware_content_library_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ library_id: '{{ content_library }}'
+ validate_certs: false
+ register: content_lib_info
+
+- name: Check Content Library details
+ assert:
+ that:
+ - '{{ content_lib_info.content_lib_details[0].library_id == content_library }}'
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/tasks/main.yml
new file mode 100644
index 00000000..c12b57b5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_content_library_manager/tasks/main.yml
@@ -0,0 +1,231 @@
+# Test code for the vmware_content_library CRUD Operations.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- &content_lib_delete
+ name: Delete content library if exists
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Library
+ state: absent
+
+- &content_lib_create
+ name: Create content library
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Library
+ library_description: Sample Description
+ datastore_name: '{{ rw_datastore }}'
+ state: present
+ register: content_lib_create_result
+
+- name: Check content library is created
+ assert:
+ that:
+ - content_lib_create_result.changed
+
+- <<: *content_lib_create
+ name: Create content library again
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not content_lib_create_result.changed
+
+# Testcase Update Content Library
+- &update_content_lib
+ name: Update a content library
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Library
+ library_description: Update Sample Description
+ state: present
+ register: content_lib_update_result
+
+- name: Check content library is updated
+ assert:
+ that:
+ - content_lib_update_result.changed
+
+- <<: *update_content_lib
+ name: Update a content library again
+
+- name: Check content library is not updated
+ assert:
+ that:
+ - not content_lib_update_result.changed
+
+# Testcase Delete the content library
+- <<: *content_lib_delete
+ name: Delete content library
+ register: content_lib_delete_result
+
+- name: Check content library is deleted
+ assert:
+ that:
+ - content_lib_delete_result.changed
+
+- <<: *content_lib_delete
+ name: Delete content library again
+ register: content_lib_delete_result
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not content_lib_delete_result.changed
+
+- &subscribed_content_lib_delete
+ name: Delete subscribed content library if exists
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Subscribed_Library
+ library_type: subscribed
+ state: absent
+
+- name: get finger print
+ shell: echo | openssl s_client -connect wp-content.vmware.com:443 |& openssl x509 -fingerprint -noout
+ register: _finger_print
+- debug: var=_finger_print
+
+- &subscribed_content_lib_create
+ name: Create subscribed content library
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Subscribed_Library
+ library_description: Sample Description
+ subscription_url: "https://wp-content.vmware.com/v2/latest/lib.json"
+ update_on_demand: true
+ library_type: subscribed
+ ssl_thumbprint: '{{ _finger_print.stdout.split("=")[1] }}'
+ datastore_name: '{{ rw_datastore }}'
+ state: present
+ register: subscribed_content_lib_create_result
+
+- name: Check content library is created
+ assert:
+ that:
+ - subscribed_content_lib_create_result.changed
+
+- <<: *subscribed_content_lib_create
+ name: Create content library again
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not subscribed_content_lib_create_result.changed
+
+# Testcase Update Content Library
+- &update_subscribed_content_lib
+ name: Update a subscribed content library
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Subscribed_Library
+ library_description: Update Sample Description
+ subscription_url: https://download3.vmware.com/software/vmw-tools/lib.json
+ update_on_demand: true
+ library_type: subscribed
+ ssl_thumbprint: '{{ _finger_print.stdout.split("=")[1] }}'
+ state: present
+ register: subscribed_content_lib_update_result
+
+- name: Check subscribed content library is updated
+ assert:
+ that:
+ - subscribed_content_lib_update_result.changed
+
+- <<: *update_subscribed_content_lib
+ name: Update a subscribed content library again
+
+- name: Check content library is not updated
+ assert:
+ that:
+ - not subscribed_content_lib_update_result.changed
+
+# Testcase Update Subscribed Content Library as a Local Library
+- name: Update a subscribed content library as a local library
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Subscribed_Library
+ library_description: Update Sample Description
+ library_type: local
+ state: present
+ register: subscribed_content_lib_invalid_update_result
+ ignore_errors: true
+
+- name: Check subscribed content library is not updated and errors cleanly
+ assert:
+ that:
+ - not subscribed_content_lib_invalid_update_result.changed
+ - '"cannot be changed to local" in subscribed_content_lib_invalid_update_result.msg'
+
+# Testcase Create Content Library with invalid thumbprint
+- name: Update a subscribed content library with invalid thumbprint
+ vmware_content_library_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ library_name: Sample_Subscribed_Library
+ library_description: Update Sample Description
+ subscription_url: https://download3.vmware.com/software/vmw-tools/lib.json
+ update_on_demand: true
+ library_type: subscribed
+ ssl_thumbprint: aa:bb:cc:d9:ad:d4:53:b5:86:5a:5d:70:36:cf:89:93:d1:6c:f9:63
+ state: present
+ register: subscribed_content_lib_invalid_thumbprint_result
+ ignore_errors: true
+
+- debug:
+ msg: "{{ subscribed_content_lib_invalid_thumbprint_result }}"
+
+- name: Check subscribed content library is not updated and errors cleanly
+ assert:
+ that:
+ - not subscribed_content_lib_invalid_thumbprint_result.changed
+ - '"vCenter Failed to make connection" in subscribed_content_lib_invalid_thumbprint_result.msg'
+
+
+# Testcase Delete the content library
+- <<: *subscribed_content_lib_delete
+ name: Delete subscribed content library
+ register: subscribed_content_lib_delete_result
+
+- name: Check subscribed content library is deleted
+ assert:
+ that:
+ - subscribed_content_lib_delete_result.changed
+
+- <<: *subscribed_content_lib_delete
+ name: Delete subscribed content library again
+ register: subscribed_content_lib_delete_result
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not subscribed_content_lib_delete_result.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/tasks/main.yml
new file mode 100644
index 00000000..b9918d62
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute/tasks/main.yml
@@ -0,0 +1,142 @@
+# Test code for the vmware_custom_attribute module.
+# Copyright: (c) 2022, Mario Lenz <@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: add VM custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: sample_5
+ state: present
+ register: add_attrib_def
+
+- debug: var=add_attrib_def
+
+- assert:
+ that:
+ - add_attrib_def is changed
+
+- name: add VM custom attribute definition again
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: sample_5
+ state: present
+ register: add_attrib_def
+
+- debug: var=add_attrib_def
+
+- assert:
+ that:
+ - not (add_attrib_def is changed)
+
+- name: remove VM custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: sample_5
+ state: absent
+ register: remove_attrib_def
+
+- debug: var=remove_attrib_def
+
+- assert:
+ that:
+ - remove_attrib_def is changed
+
+- name: remove VM custom attribute definition again
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: sample_5
+ state: absent
+ register: remove_attrib_def
+
+- debug: var=remove_attrib_def
+
+- assert:
+ that:
+ - not (remove_attrib_def is changed)
+
+- name: add Global custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: sample_5
+ state: present
+ register: add_attrib_def
+
+- debug: var=add_attrib_def
+
+- assert:
+ that:
+ - add_attrib_def is changed
+
+- name: add Global custom attribute definition again
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: sample_5
+ state: present
+ register: add_attrib_def
+
+- debug: var=add_attrib_def
+
+- assert:
+ that:
+ - not (add_attrib_def is changed)
+
+- name: remove Global custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: sample_5
+ state: absent
+ register: remove_attrib_def
+
+- debug: var=remove_attrib_def
+
+- assert:
+ that:
+ - remove_attrib_def is changed
+
+- name: remove Global custom attribute definition again
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: sample_5
+ state: absent
+ register: remove_attrib_def
+
+- debug: var=remove_attrib_def
+
+- assert:
+ that:
+ - not (remove_attrib_def is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/tasks/main.yml
new file mode 100644
index 00000000..cd212c95
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_custom_attribute_manager/tasks/main.yml
@@ -0,0 +1,288 @@
+# Test code for the vmware_custom_attribute_manager module.
+# Copyright: (c) 2022, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Create custom attributes needed for tests
+ block:
+ - name: Add Global custom attribute
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: global_attribute
+ state: present
+
+ - name: Add VM custom attribute 1
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: vm_attribute_1
+ state: present
+
+ - name: Add VM custom attribute 2
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: vm_attribute_2
+ state: present
+
+ - name: Add ESX custom attribute 1
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: HostSystem
+ custom_attribute: esx_attribute_1
+ state: present
+
+ - name: Add ESX custom attribute 2
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: HostSystem
+ custom_attribute: esx_attribute_2
+ state: present
+
+- name: Add custom attribute to the given virtual machine
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ virtual_machines[0].name }}"
+ object_type: VirtualMachine
+ state: present
+ custom_attributes:
+ - name: 'vm_attribute_1'
+ value: 'vm_attribute_1_value'
+ - name: 'vm_attribute_2'
+ value: 'vm_attribute_2_value'
+ - name: 'global_attribute'
+ value: 'global_attribute_value'
+ register: guest_info_0001
+
+- debug: var=guest_info_0001
+
+- assert:
+ that:
+ - guest_info_0001 is changed
+
+- name: Add custom attribute to the given virtual machine again
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ virtual_machines[0].name }}"
+ object_type: VirtualMachine
+ state: present
+ custom_attributes:
+ - name: 'vm_attribute_1'
+ value: 'vm_attribute_1_value'
+ - name: 'vm_attribute_2'
+ value: 'vm_attribute_2_value'
+ - name: 'global_attribute'
+ value: 'global_attribute_value'
+ register: guest_info_0002
+
+- debug: var=guest_info_0002
+
+- assert:
+ that:
+ - guest_info_0002 is not changed
+
+- name: Remove custom attribute from the given virtual machine
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ virtual_machines[0].name }}"
+ object_type: VirtualMachine
+ state: absent
+ custom_attributes:
+ - name: 'vm_attribute_1'
+ - name: 'vm_attribute_2'
+ - name: 'global_attribute'
+ register: guest_info_0004
+
+- debug: var=guest_info_0004
+
+- assert:
+ that:
+ - guest_info_0004 is changed
+
+- name: Remove custom attribute from the given virtual machine again
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ virtual_machines[0].name }}"
+ object_type: VirtualMachine
+ state: absent
+ custom_attributes:
+ - name: 'vm_attribute_1'
+ - name: 'vm_attribute_2'
+ - name: 'global_attribute'
+ register: guest_info_0005
+
+- debug: var=guest_info_0005
+
+- assert:
+ that:
+ - guest_info_0005 is not changed
+
+- name: Add custom attribute to the given ESXi host
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ esxi_hosts[0] }}"
+ object_type: HostSystem
+ state: present
+ custom_attributes:
+ - name: 'esx_attribute_1'
+ value: 'esx_attribute_1_value'
+ - name: 'esx_attribute_2'
+ value: 'esx_attribute_2_value'
+ register: host_info_0001
+
+- debug: var=host_info_0001
+
+- assert:
+ that:
+ - host_info_0001 is changed
+
+- name: Add custom attribute to the given ESXi host again
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ esxi_hosts[0] }}"
+ object_type: HostSystem
+ state: present
+ custom_attributes:
+ - name: 'esx_attribute_1'
+ value: 'esx_attribute_1_value'
+ - name: 'esx_attribute_2'
+ value: 'esx_attribute_2_value'
+ register: host_info_0002
+
+- debug: var=host_info_0002
+
+- assert:
+ that:
+ - host_info_0002 is not changed
+
+- name: Remove custom attribute from the given ESXi host
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ esxi_hosts[0] }}"
+ object_type: HostSystem
+ state: absent
+ custom_attributes:
+ - name: 'esx_attribute_1'
+ - name: 'esx_attribute_2'
+ register: host_info_0003
+
+- debug: var=host_info_0003
+
+- assert:
+ that:
+ - host_info_0003 is changed
+
+- name: Remove custom attribute from the given ESXi host again
+ community.vmware.vmware_custom_attribute_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_name: "{{ esxi_hosts[0] }}"
+ object_type: HostSystem
+ state: absent
+ custom_attributes:
+ - name: 'esx_attribute_1'
+ - name: 'esx_attribute_2'
+ register: host_info_0004
+
+- debug: var=host_info_0004
+
+- assert:
+ that:
+ - host_info_0004 is not changed
+
+- name: Clean up custom attributes
+ block:
+ - name: Remove Global custom attribute
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: global_attribute
+ state: absent
+
+ - name: Remove VM custom attribute 1
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: vm_attribute_1
+ state: absent
+
+ - name: Remove VM custom attribute 2
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: vm_attribute_2
+ state: absent
+
+ - name: Remove ESX custom attribute 1
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: HostSystem
+ custom_attribute: esx_attribute_1
+ state: absent
+
+ - name: Remove ESX custom attribute 2
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: HostSystem
+ custom_attribute: esx_attribute_2
+ state: absent
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/tasks/main.yml
new file mode 100644
index 00000000..49de53ae
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter/tasks/main.yml
@@ -0,0 +1,104 @@
+# Test code for the vmware_datacenter module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- &add_dc
+ name: Add datacenter
+ vmware_datacenter:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: datacenter_0001
+ state: present
+ register: dc_result
+
+- debug:
+ var: dc_result
+
+- name: Ensure datacenter is present
+ assert:
+ that:
+ - dc_result.changed
+
+- <<: *add_dc
+ name: add datacenter again to check idempotent behavior
+
+- name: Ensure datacenter status is not changed
+ assert:
+ that:
+ - not dc_result.changed
+
+- name: Delete datacenter
+ vmware_datacenter:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: datacenter_0001
+ state: absent
+ register: dc_result_delete
+
+- name: Ensure datacenter is absent
+ assert:
+ that:
+ - dc_result_delete.changed
+
+- name: Create Datacenter with special characters
+ vmware_datacenter:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: 'Datacenter\/%'
+ state: present
+ register: create_datacenter_with_special_characters_result
+
+- assert:
+ that:
+ - create_datacenter_with_special_characters_result.changed is sameas true
+
+- name: Create Datacenter with special characters(idempotency check)
+ vmware_datacenter:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: 'Datacenter\/%'
+ state: present
+ register: create_datacenter_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - create_datacenter_with_special_characters_idempotency_check_result.changed is sameas false
+
+- name: Delete Datacenter with special characters
+ vmware_datacenter:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: 'Datacenter\/%'
+ state: absent
+ register: delete_datacenter_with_special_characters_result
+
+- assert:
+ that:
+ - delete_datacenter_with_special_characters_result.changed is sameas true
+
+- name: Delete Datacenter with special characters(idempotency check)
+ vmware_datacenter:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: 'Datacenter\/%'
+ state: absent
+ register: delete_datacenter_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - delete_datacenter_with_special_characters_idempotency_check_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/tasks/main.yml
new file mode 100644
index 00000000..a01a5987
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datacenter_info/tasks/main.yml
@@ -0,0 +1,74 @@
+# Test code for the vmware_datacenter_info module.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Gather information about all datacenter
+ vmware_datacenter_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: dc_result
+
+- debug:
+ var: dc_result
+
+- name: Ensure datacenter is present
+ assert:
+ that:
+ - dc_result.datacenter_info
+
+- name: Gather information about all datacenter in check mode
+ vmware_datacenter_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: dc_result
+ check_mode: true
+
+- debug:
+ var: dc_result
+
+- name: Ensure datacenter is present
+ assert:
+ that:
+ - dc_result.datacenter_info
+
+- name: Gather information about particular datacenter
+ vmware_datacenter_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc_result.datacenter_info[0]['name'] }}"
+ register: dc_result
+
+- debug:
+ var: dc_result
+
+- name: Ensure datacenter is present
+ assert:
+ that:
+ - dc_result.datacenter_info
+
+- name: Gather information about particular datacenter in check mode
+ vmware_datacenter_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc_result.datacenter_info[0]['name'] }}"
+ register: dc_result
+ check_mode: true
+
+- debug:
+ var: dc_result
+
+- name: Ensure datacenter is present
+ assert:
+ that:
+ - dc_result.datacenter_info
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/tasks/main.yml
new file mode 100644
index 00000000..271a32b8
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore/tasks/main.yml
@@ -0,0 +1,45 @@
+# Test code for the vmware_datastore_info module.
+# Copyright (c) 2022, Mario Lenz <m@riolenz.de>
+# Copyright (c) 2022, Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Configure Storage I/O Control
+ vmware_datastore:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ name: "{{ rw_datastore }}"
+ validate_certs: false
+ storage_io_control: 'enable_io_statistics'
+ congestion_threshold_manual: 30
+ statistic_collection: true
+ register: config_storage_io_control
+
+- assert:
+ that:
+ - config_storage_io_control is changed
+
+- name: Configure Storage I/O Control again (idempotency)
+ vmware_datastore:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ name: "{{ rw_datastore }}"
+ validate_certs: false
+ storage_io_control: 'enable_io_statistics'
+ congestion_threshold_manual: 30
+ statistic_collection: true
+ register: config_storage_io_control_again
+
+- assert:
+ that:
+ - config_storage_io_control_again is not changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/tasks/main.yml
new file mode 100644
index 00000000..3e52478c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster/tasks/main.yml
@@ -0,0 +1,147 @@
+# Test code for the vmware_datastore_cluster module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Add a datastore cluster to datacenter (check-mode)
+ vmware_datastore_cluster: &add_datastore_cluster
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: DSC1
+ enable_sdrs: false
+ state: present
+ check_mode: true
+ register: add_dsc_check
+
+- assert:
+ that:
+ - add_dsc_check.changed
+
+- name: Add a datastore cluster to datacenter
+ vmware_datastore_cluster: *add_datastore_cluster
+ register: add_dsc
+
+- assert:
+ that:
+ - add_dsc.changed
+
+- name: Add a datastore cluster to datacenter again
+ vmware_datastore_cluster: *add_datastore_cluster
+ register: add_dsc
+
+- assert:
+ that:
+ - not add_dsc.changed
+
+- name: Enable SDRS on a datastore cluster (check-mode)
+ vmware_datastore_cluster: &enable_sdrs
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: DSC1
+ enable_sdrs: true
+ state: present
+ check_mode: true
+ register: enable_sdrs_check
+
+- assert:
+ that:
+ - enable_sdrs_check.changed
+
+- name: Enable SDRS on a datastore cluster
+ vmware_datastore_cluster: *enable_sdrs
+ register: enable_sdrs
+
+- assert:
+ that:
+ - enable_sdrs.changed
+
+- name: Enable SDRS on a datastore cluster again
+ vmware_datastore_cluster: *enable_sdrs
+ register: enable_sdrs_again
+
+- assert:
+ that:
+ - not enable_sdrs_again.changed
+
+- name: Create a datastore folder on given Datacenter
+ vcenter_folder:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ folder_name: 'my_datastore_folder'
+ folder_type: datastore
+ state: present
+ validate_certs: false
+ register: my_datastore_folder
+
+- name: Add a datastore cluster using folder
+ vmware_datastore_cluster:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ folder: "{{ my_datastore_folder.result.path }}"
+ datastore_cluster_name: DSC2
+ state: present
+ register: add_dsc_folder_check
+
+- assert:
+ that:
+ - add_dsc_folder_check.changed
+
+- name: Delete a datastore cluster to datacenter (check-mode)
+ vmware_datastore_cluster: &delete_datastore_cluster
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: DSC1
+ state: absent
+ check_mode: true
+ register: delete_dsc_check
+
+- assert:
+ that:
+ - delete_dsc_check.changed
+
+- name: Delete a datastore cluster to datacenter
+ vmware_datastore_cluster: *delete_datastore_cluster
+ register: delete_dsc_check
+
+- assert:
+ that:
+ - delete_dsc_check.changed
+
+- name: Remove SDRS cluster
+ vmware_datastore_cluster:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: '{{ item }}'
+ state: absent
+ with_items:
+ - DSC1
+ - DSC2
+
+- name: Delete the datastore folder
+ vcenter_folder:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ folder_name: 'my_datastore_folder'
+ folder_type: datastore
+ state: absent
+ validate_certs: false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/tasks/main.yml
new file mode 100644
index 00000000..a0315169
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_cluster_manager/tasks/main.yml
@@ -0,0 +1,140 @@
+# Test code for the vmware_datastore_cluster_manager module.
+# Copyright (c) 2017, Tim Rightnour <thegarbledone@gmail.com>
+# Copyright (c) 2018, Ansible Project
+# Copyright (c) 2020, Abhijeet Kasurde
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Get list of info about datastores
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ gather_nfs_mount_info: true
+ register: datastore_info_0001
+
+- set_fact:
+ datastore_name: "{{ datastore_info_0001['datastores'][0]['name'] }}"
+ datastore_cluster_name: "DSC1"
+
+- name: Add a datastore cluster to datacenter
+ vmware_datastore_cluster:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ enable_sdrs: false
+ state: present
+ register: add_dsc
+
+- assert:
+ that:
+ - add_dsc.changed
+
+- name: Add a datastore in the given datastore cluster in check mode
+ vmware_datastore_cluster_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ datastores:
+ - "{{ datastore_name }}"
+ check_mode: true
+ register: check_mode
+
+- assert:
+ that:
+ - check_mode.changed
+
+- name: Add a datastore in the given datastore cluster
+ vmware_datastore_cluster_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ datastores:
+ - "{{ datastore_name }}"
+ register: add_ds
+
+- assert:
+ that:
+ - add_ds.changed
+
+- name: Again add a datastore in the given datastore cluster (idempotency)
+ vmware_datastore_cluster_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ datastores:
+ - "{{ datastore_name }}"
+ register: add_ds
+
+- assert:
+ that:
+ - not add_ds.changed
+
+- name: Remove a datastore from the given datastore cluster
+ vmware_datastore_cluster_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ datastores:
+ - "{{ datastore_name }}"
+ state: absent
+ register: remove_ds
+
+- assert:
+ that:
+ - remove_ds.changed
+
+- name: Again remove a datastore from the given datastore cluster (idempotency)
+ vmware_datastore_cluster_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ datastores:
+ - "{{ datastore_name }}"
+ state: absent
+ register: remove_ds
+
+- assert:
+ that:
+ - not remove_ds.changed
+
+- name: Remove datastore cluster to datacenter
+ vmware_datastore_cluster:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ datastore_cluster_name }}"
+ state: absent
+ register: remove_dsc
+
+- assert:
+ that:
+ - remove_dsc.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/tasks/main.yml
new file mode 100644
index 00000000..726e06a2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_info/tasks/main.yml
@@ -0,0 +1,349 @@
+# Test code for the vmware_datastore_info module.
+# Copyright (c) 2017, Tim Rightnour <thegarbledone@gmail.com>
+# Copyright (c) 2018, Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: get list of info about datastores from the ESXi
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: '{{ item }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ register: info_from_esxi
+ with_items: "{{ esxi_hosts }}"
+- assert:
+ that:
+ - "info_from_esxi.results[0].datastores|selectattr('type', 'equalto', 'NFS')|list|length == 2"
+
+- name: get list of info about datastores
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ gather_nfs_mount_info: true
+ register: info_from_vcenter_with_dc_filter
+
+- name: get list of info about datastores
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ gather_nfs_mount_info: true
+ register: info_from_vcenter_with_no_filter
+
+- assert:
+ that:
+ - "info_from_vcenter_with_dc_filter.datastores|selectattr('type', 'equalto', 'NFS')|list|length == 2"
+ - "info_from_vcenter_with_no_filter.datastores|selectattr('type', 'equalto', 'NFS')|list|length == 2"
+ - "info_from_vcenter_with_no_filter.datastores[0]['capacity'] is defined"
+ - "info_from_vcenter_with_no_filter.datastores[0]['tags'] is not defined"
+
+# Testcase 0002: Get a full list of datastores in a cluster
+- name: get list of info about datastores - no dc
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster: "{{ ccr1 }}"
+ register: datastore_info_0002
+
+- debug:
+ msg: "{{ datastore_info_0002 }}"
+
+- assert:
+ that:
+ - "datastore_info_0002['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0002['datastores'][0]['tags'] is not defined"
+
+# Testcase 0003: Find a specific datastore
+- name: get list of info about one datastore
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ register: datastore_info_0003
+
+- debug:
+ msg: "{{ datastore_info_0003 }}"
+
+- assert:
+ that:
+ - "datastore_info_0003['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0003['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0003['datastores'][0]['tags'] is not defined"
+
+- name: get list of extended info about one datastore
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ gather_nfs_mount_info: true
+ gather_vmfs_mount_info: true
+ register: datastore_info_0004
+
+- debug:
+ msg: "{{ datastore_info_0004 }}"
+
+- assert:
+ that:
+ - "datastore_info_0004['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0004['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0004['datastores'][0]['tags'] is not defined"
+
+- name: get list of info about one datastore in check mode
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ register: datastore_info_0005
+
+- debug:
+ msg: "{{ datastore_info_0005 }}"
+
+- assert:
+ that:
+ - "datastore_info_0005['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0005['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0005['datastores'][0]['tags'] is not defined"
+
+# Testcase with property specify
+- name: get list of info about datastores with properties specify - no dc
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster: "{{ ccr1 }}"
+ schema: vsphere
+ properties:
+ - name
+ register: datastore_info_0006
+
+- debug:
+ msg: "{{ datastore_info_0006 }}"
+
+- assert:
+ that:
+ - "datastore_info_0006['datastores'][0]['name'] is defined"
+ - "datastore_info_0006['datastores'][0]['tags'] is not defined"
+
+- name: get list of info about one datastore with properties specify
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ schema: vsphere
+ properties:
+ - name
+ register: datastore_info_0007
+
+- debug:
+ msg: "{{ datastore_info_0007 }}"
+
+- assert:
+ that:
+ - "datastore_info_0007['datastores'][0]['name'] is defined"
+ - "datastore_info_0007['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0007['datastores'] | length == 1"
+
+- name: get list of info about datastores with multiple properties specify
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ schema: vsphere
+ properties:
+ - name
+ - capability.vsanSparseSupported
+ - overallStatus
+ register: datastore_info_0008
+
+- debug:
+ msg: "{{ datastore_info_0008 }}"
+
+- assert:
+ that:
+ - "datastore_info_0008['datastores'][0]['name'] is defined"
+ - "datastore_info_0008['datastores'][0]['capability']['vsanSparseSupported'] is defined"
+ - "datastore_info_0008['datastores'][0]['overallStatus'] is defined"
+
+
+# Testcase 0009: Get a full list of datastores in a cluster
+- name: get list of info about datastores with tags - no dc
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster: "{{ ccr1 }}"
+ show_tag: true
+ register: datastore_info_0009
+
+- debug:
+ msg: "{{ datastore_info_0009 }}"
+
+- assert:
+ that:
+ - "datastore_info_0009['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0009['datastores'][0]['tags'] is defined"
+
+# Testcase 0010: Find a specific datastore
+- name: get list of info about one datastore
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ show_tag: true
+ register: datastore_info_0010
+
+- debug:
+ msg: "{{ datastore_info_0010 }}"
+
+- assert:
+ that:
+ - "datastore_info_0010['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0010['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0010['datastores'][0]['tags'] is defined"
+
+- name: get list of extended info about one datastore
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ show_tag: true
+ gather_nfs_mount_info: true
+ gather_vmfs_mount_info: true
+ register: datastore_info_0011
+
+- debug:
+ msg: "{{ datastore_info_0011 }}"
+
+- assert:
+ that:
+ - "datastore_info_0011['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0011['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0011['datastores'][0]['tags'] is defined"
+
+- name: get list of info about one datastore in check mode
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ show_tag: true
+ register: datastore_info_0012
+
+- debug:
+ msg: "{{ datastore_info_0012 }}"
+
+- assert:
+ that:
+ - "datastore_info_0012['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0012['datastores'][0]['capacity'] is defined"
+ - "datastore_info_0012['datastores'][0]['tags'] is defined"
+
+# Testcase with property specify
+- name: get list of info about datastores with properties specify - no dc
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster: "{{ ccr1 }}"
+ show_tag: true
+ schema: vsphere
+ properties:
+ - name
+ register: datastore_info_0013
+
+- debug:
+ msg: "{{ datastore_info_0013 }}"
+
+- assert:
+ that:
+ - "datastore_info_0013['datastores'][0]['name'] is defined"
+ - "datastore_info_0013['datastores'][0]['tags'] is defined"
+
+- name: get list of info about one datastore with properties specify
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ show_tag: true
+ schema: vsphere
+ properties:
+ - name
+ register: datastore_info_0014
+
+- debug:
+ msg: "{{ datastore_info_0014 }}"
+
+- assert:
+ that:
+ - "datastore_info_0014['datastores'][0]['name'] is defined"
+ - "datastore_info_0014['datastores'][0]['name'] == ro_datastore"
+ - "datastore_info_0014['datastores'] | length == 1"
+ - "datastore_info_0014['datastores'][0]['tags'] is defined"
+
+- name: get list of info about datastores with multiple properties specify
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ ro_datastore }}"
+ show_tag: true
+ schema: vsphere
+ properties:
+ - name
+ - capability.vsanSparseSupported
+ - overallStatus
+ register: datastore_info_0015
+
+- debug:
+ msg: "{{ datastore_info_0015 }}"
+
+- assert:
+ that:
+ - "datastore_info_0015['datastores'][0]['name'] is defined"
+ - "datastore_info_0015['datastores'][0]['capability']['vsanSparseSupported'] is defined"
+ - "datastore_info_0015['datastores'][0]['overallStatus'] is defined"
+ - "datastore_info_0015['datastores'][0]['tags'] is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/tasks/main.yml
new file mode 100644
index 00000000..52fff585
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_datastore_maintenancemode/tasks/main.yml
@@ -0,0 +1,81 @@
+# Test code for the vmware_datastore_maintenancemode module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Enter datastore in maintenance mode
+ vmware_datastore_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ datastore: "{{ ro_datastore }}"
+ validate_certs: false
+ register: test_result_0001
+
+- debug:
+ var: test_result_0001
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_result_0001 is changed
+
+- name: Enter datastore in maintenance mode again
+ vmware_datastore_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ datastore: "{{ ro_datastore }}"
+ validate_certs: false
+ register: test_result_0002
+
+- debug:
+ var: test_result_0002
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - not (test_result_0002 is changed)
+
+- name: Exit datastores from maintenance mode
+ vmware_datastore_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ datastore: "{{ ro_datastore }}"
+ validate_certs: false
+ register: test_result_0003
+
+- debug:
+ var: test_result_0003
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_result_0003 is changed
+
+- name: Exit datastores from maintenance mode again
+ vmware_datastore_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ datastore: "{{ ro_datastore }}"
+ validate_certs: false
+ register: test_result_0004
+
+- debug:
+ var: test_result_0004
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - not (test_result_0004 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/tasks/main.yml
new file mode 100644
index 00000000..6332ce52
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group/tasks/main.yml
@@ -0,0 +1,73 @@
+# Test code for the vmware_drs_group module
+# Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Create DRS VM group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ # Options
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: TEST_VM_01
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ state: present
+ register: drs_vm_group_01_results
+
+- debug:
+ var: drs_vm_group_01_results
+
+- assert:
+ that:
+ - "drs_vm_group_01_results.changed"
+
+- name: Create DRS Host group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: TEST_HOST_01
+ hosts: "{{ esxi_hosts[0:3] }}"
+ state: present
+ register: drs_host_group_01_results
+
+- debug:
+ var: drs_host_group_01_results
+
+- assert:
+ that:
+ - "drs_host_group_01_results.changed"
+
+- name: Delete DRS Host group
+ vmware_drs_group:
+ # Login creds
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ # Options
+ cluster_name: DC0_C0
+ datacenter_name: DC0
+ group_name: TEST_HOST_01
+ hosts: []
+ state: absent
+ register: drs_host_group_01_delete_results
+
+- debug:
+ var: drs_host_group_01_delete_results
+
+- assert:
+ that:
+ - "drs_host_group_01_delete_results.changed"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/tasks/main.yml
new file mode 100644
index 00000000..ad951a10
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_info/tasks/main.yml
@@ -0,0 +1,42 @@
+# Test code for the vmware_drs_group_info module
+# Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Gather DRS group info from given cluster
+ vmware_drs_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: '{{ ccr1 }}'
+ validate_certs: false
+ register: drs_group_0001_results
+
+- debug:
+ var: drs_group_0001_results
+
+- assert:
+ that:
+ - "drs_group_0001_results.drs_group_info.DC0_C0 is defined"
+ - "not drs_group_0001_results.drs_group_info.DC0_C1 is defined"
+ - "not drs_group_0001_results.changed"
+
+- name: Gather DRS group info from given datacenter
+ vmware_drs_group_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: '{{ dc1 }}'
+ validate_certs: false
+ register: drs_group_0002_results
+
+- debug:
+ var: drs_group_0002_results
+
+- assert:
+ that:
+ - "drs_group_0002_results.drs_group_info.DC0_C0 is defined"
+ - "not drs_group_0002_results.drs_group_info.DC0_C1 is defined"
+ - "not drs_group_0002_results.changed"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/tasks/main.yml
new file mode 100644
index 00000000..a65709a4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_group_manager/tasks/main.yml
@@ -0,0 +1,98 @@
+# Test code for the vmware_drs_group_manager module
+# Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com>
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- set_fact:
+ vm_one: "{{ virtual_machines_in_cluster[0]['name'] }}"
+ vm_two: "{{ virtual_machines_in_cluster[1]['name'] }}"
+
+- name: Create DRS VM group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: TEST_VM_01
+ vms: "{{ vm_one }}"
+ state: present
+ register: drs_vm_group_01_results
+
+- debug:
+ var: drs_vm_group_01_results
+
+- assert:
+ that:
+ - "drs_vm_group_01_results.changed"
+
+- name: Add a VM in an existing DRS VM group
+ vmware_drs_group_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: TEST_VM_01
+ vms:
+ - "{{ vm_two }}"
+ state: present
+ register: drs_vm_group_01_results
+
+- debug:
+ var: drs_vm_group_01_results
+
+- assert:
+ that:
+ - drs_vm_group_01_results.changed
+
+- name: Again add a VM in an existing DRS VM group (idempotency)
+ vmware_drs_group_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: TEST_VM_01
+ vms:
+ - "{{ vm_two }}"
+ state: present
+ register: drs_vm_group_01_results
+
+- debug:
+ var: drs_vm_group_01_results
+
+- assert:
+ that:
+ - not drs_vm_group_01_results.changed
+
+- name: delete DRS VM group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: TEST_VM_01
+ vms: "{{ vm_one }}"
+ state: absent
+ register: drs_vm_group_01_results
+
+
+- debug:
+ var: drs_vm_group_01_results
+
+- assert:
+ that:
+ - drs_vm_group_01_results.changed \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/tasks/main.yml
new file mode 100644
index 00000000..a14fc2be
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_drs_rule_info/tasks/main.yml
@@ -0,0 +1,45 @@
+# Test code for the vmware_drs_rule_info module
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather info about DRS rule from given cluster
+ vmware_drs_rule_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: DC0_C0
+ register: drs_rule_0001_results
+
+- debug:
+ var: drs_rule_0001_results
+
+- assert:
+ that:
+ - "drs_rule_0001_results.drs_rule_info is defined"
+ - "not drs_rule_0001_results.changed"
+
+- name: Gather info about DRS rule from given datacenter
+ vmware_drs_rule_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: DC0
+ register: drs_rule_0001_results
+
+- debug:
+ var: drs_rule_0001_results
+
+- assert:
+ that:
+ - "drs_rule_0001_results.drs_rule_info is defined"
+ - "not drs_rule_0001_results.changed"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/tasks/main.yml
new file mode 100644
index 00000000..23c4eceb
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_host/tasks/main.yml
@@ -0,0 +1,113 @@
+---
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Run tests and clean up
+ block:
+ - name: Create the DVSwitch
+ vmware_dvswitch:
+ datacenter_name: '{{ dc1 }}'
+ switch_name: 'dvs_host_test_switch'
+ switch_version: 6.5.0
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ state: present
+
+ - name: Create LAG
+ vmware_dvswitch_lacp:
+ switch: 'dvs_host_test_switch'
+ support_mode: enhanced
+ link_aggregation_groups:
+ - name: lag1
+ mode: active
+ uplink_number: 2
+ load_balancing_mode: srcDestIpTcpUdpPortVlan
+
+ - name: 'Attach host to the DVSwitch without specifying any vmnics (Issue #185)'
+ vmware_dvs_host:
+ esxi_hostname: '{{ esxi1 }}'
+ switch_name: 'dvs_host_test_switch'
+ state: present
+ register: host_dvs_attachment
+ - assert:
+ that:
+ - host_dvs_attachment is changed
+
+ - name: 'Attach hosts to the DVSwitch without specifying any vmnics again (idempotency)'
+ vmware_dvs_host:
+ esxi_hostname: '{{ esxi1 }}'
+ switch_name: 'dvs_host_test_switch'
+ state: present
+ register: host_dvs_attachment_again
+ - assert:
+ that:
+ - host_dvs_attachment_again is not changed
+
+ - name: 'Add vmnic to uplink'
+ vmware_dvs_host:
+ esxi_hostname: '{{ esxi1 }}'
+ switch_name: 'dvs_host_test_switch'
+ vmnics:
+ - vmnic1
+ state: present
+ register: host_dvs_uplink
+ - assert:
+ that:
+ - host_dvs_uplink is changed
+
+ - name: 'Add vmnic to uplink again (idempotency)'
+ vmware_dvs_host:
+ esxi_hostname: '{{ esxi1 }}'
+ switch_name: 'dvs_host_test_switch'
+ vmnics:
+ - vmnic1
+ state: present
+ register: host_dvs_uplink_again
+ - assert:
+ that:
+ - host_dvs_uplink_again is not changed
+
+ - name: 'Add vmnic to LAG uplink'
+ vmware_dvs_host:
+ esxi_hostname: '{{ esxi1 }}'
+ switch_name: 'dvs_host_test_switch'
+ lag_uplinks:
+ - lag: lag1
+ vmnics:
+ - vmnic1
+ state: present
+ register: host_dvs_lag_uplink
+ - assert:
+ that:
+ - host_dvs_lag_uplink is changed
+
+ - name: 'Add vmnic to LAG uplink again (idempotency)'
+ vmware_dvs_host:
+ esxi_hostname: '{{ esxi1 }}'
+ switch_name: 'dvs_host_test_switch'
+ lag_uplinks:
+ - lag: lag1
+ vmnics:
+ - vmnic1
+ state: present
+ register: host_dvs_lag_uplink_again
+ - assert:
+ that:
+ - host_dvs_lag_uplink_again is not changed
+
+# Cleanup
+ always:
+ - name: 'Cleanup: detaching host from dvs'
+ vmware_dvs_host:
+ esxi_hostname: "{{ esxi1 }}"
+ switch_name: 'dvs_host_test_switch'
+ state: absent
+
+ - name: 'Cleanup: Deleting DVSwitch'
+ vmware_dvswitch:
+ datacenter_name: '{{ dc1 }}'
+ switch_name: 'dvs_host_test_switch'
+ state: absent
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml
new file mode 100644
index 00000000..8e6119f4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml
@@ -0,0 +1,807 @@
+# Test code for the vmware_dvs_portgroup module.
+# Copyright: (c) 2017, Philippe Dellaert <philippe@dellaert.org>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_dvswitch: true
+
+- name: create basic portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0001
+
+- debug:
+ var: dvs_pg_result_0001
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - dvs_pg_result_0001.changed
+
+- name: enable MAC learning
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ mac_learning:
+ enabled: true
+ state: present
+ register: enable_mac_learning_result
+
+- debug:
+ var: enable_mac_learning_result
+
+- name: ensure MAC learning is enabled
+ assert:
+ that:
+ - enable_mac_learning_result.changed
+
+- name: enable MAC learning again (idempotency)
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ mac_learning:
+ enabled: true
+ state: present
+ register: enable_mac_learning_again_result
+
+- debug:
+ var: enable_mac_learning_again_result
+
+- name: ensure MAC learning is not enabled again
+ assert:
+ that:
+ - not enable_mac_learning_again_result.changed
+
+- name: disable MAC learning
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ mac_learning:
+ enabled: false
+ state: present
+ register: disable_mac_learning_result
+
+- debug:
+ var: disable_mac_learning_result
+
+- name: ensure MAC learning is disabled
+ assert:
+ that:
+ - disable_mac_learning_result.changed
+
+- name: disable MAC learning again (idempotency)
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ mac_learning:
+ enabled: false
+ state: present
+ register: disable_mac_learning_again_result
+
+- debug:
+ var: disable_mac_learning_again_result
+
+- name: ensure MAC learning is not disabled again
+ assert:
+ that:
+ - not disable_mac_learning_again_result.changed
+
+- name: create basic VLAN portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-vlan10"
+ vlan_id: 10
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0002
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - dvs_pg_result_0002.changed
+
+- name: create basic trunk portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-trunk"
+ vlan_id: 1-4094
+ vlan_trunk: true
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0003
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - dvs_pg_result_0003.changed
+
+- name: create basic portgroup again
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0004
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - not dvs_pg_result_0004.changed
+
+- name: create basic portgroup with all security and policy settings enabled
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-all-enabled"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: true
+ mac_changes: true
+ port_policy:
+ block_override: true
+ ipfix_override: true
+ live_port_move: true
+ network_rp_override: true
+ port_config_reset_at_disconnect: true
+ security_override: true
+ shaping_override: true
+ traffic_filter_override: true
+ uplink_teaming_override: true
+ vendor_config_override: true
+ vlan_override: true
+ register: dvs_pg_result_0005
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - dvs_pg_result_0005.changed
+
+- name: create basic portgroup with some security and policy settings enabled
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-some-enabled"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: true
+ mac_changes: false
+ port_policy:
+ vlan_override: true
+ register: dvs_pg_result_0006
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - dvs_pg_result_0006.changed
+
+- name: Change forged_transmits to no
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-some-enabled"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: false
+ mac_changes: false
+ port_policy:
+ vlan_override: true
+ register: dvs_pg_result_0007
+
+- name: ensure forged_transmits is changed
+ assert:
+ that:
+ - dvs_pg_result_0007.changed
+
+- name: Change vlan_override to no
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-some-enabled"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: false
+ mac_changes: false
+ port_policy:
+ vlan_override: false
+ register: dvs_pg_result_0008
+
+- name: ensure vlan_override is changed
+ assert:
+ that:
+ - dvs_pg_result_0008.changed
+
+- name: Change num_ports to 16
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-some-enabled"
+ vlan_id: 0
+ num_ports: 16
+ port_binding: static
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: false
+ mac_changes: false
+ port_policy:
+ vlan_override: false
+ register: dvs_pg_result_0009
+
+- name: ensure vlan_override is changed
+ assert:
+ that:
+ - dvs_pg_result_0009.changed
+
+- name: Change portgroup to ephemeral
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-some-enabled"
+ vlan_id: 0
+ num_ports: 16
+ port_binding: ephemeral
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: false
+ mac_changes: false
+ port_policy:
+ vlan_override: false
+ register: dvs_pg_result_0010
+
+- name: ensure vlan_override is changed
+ assert:
+ that:
+ - dvs_pg_result_0010.changed
+
+- name: delete basic portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: absent
+ register: dvs_pg_result_0011
+
+- name: ensure dvs portgroup is removed
+ assert:
+ that:
+ - dvs_pg_result_0011.changed
+
+- name: delete basic portgroup again
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic"
+ vlan_id: 0
+ num_ports: 32
+ port_binding: static
+ state: absent
+ register: dvs_pg_result_0012
+
+- name: ensure dvs portgroup is removed
+ assert:
+ that:
+ - not dvs_pg_result_0012.changed
+
+- name: Check valid VLAN id range in DVS Portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic_trunk_0001"
+ vlan_id: 1-4096
+ vlan_trunk: true
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0013
+ ignore_errors: true
+
+- name: Ensure module fails for invalid VLAN id
+ assert:
+ that:
+ - not dvs_pg_result_0013.changed
+ - "'vlan_id range 1-4096 specified is incorrect. The valid vlan_id range is from 0 to 4094.' == '{{ dvs_pg_result_0013.msg }}'"
+
+- name: Change VLAN on basic VLAN portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-vlan10"
+ vlan_id: 20
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0014
+
+- name: ensure dvs portgroup is changed
+ assert:
+ that:
+ - dvs_pg_result_0014.changed
+
+- name: Change VLAN range on basic trunk portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "basic-trunk"
+ vlan_id: 1000-2000
+ vlan_trunk: true
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0015
+
+- name: ensure dvs portgroup is changed
+ assert:
+ that:
+ - dvs_pg_result_0015.changed
+
+- name: create complex trunk portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "complex-trunk"
+ vlan_id: 1-1000, 1005, 1100-1200
+ vlan_trunk: true
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0016
+
+- name: ensure dvs portgroup is present
+ assert:
+ that:
+ - dvs_pg_result_0016.changed
+
+- name: change complex trunk portgroup
+ community.vmware.vmware_dvs_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "complex-trunk"
+ vlan_id: 1-1000, 1006, 1100-1200
+ vlan_trunk: true
+ num_ports: 32
+ port_binding: static
+ state: present
+ register: dvs_pg_result_0017
+
+- name: ensure dvs portgroup is changed
+ assert:
+ that:
+ - dvs_pg_result_0017.changed
+
+- name: Check fail for missing PVLAN in dvs
+ community.vmware.vmware_dvs_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ portgroup_name: private-vlan-portgroup
+ switch_name: "{{ dvswitch1 }}"
+ vlan_id: 10
+ vlan_private: true
+ num_ports: 12
+ port_binding: static
+ state: present
+ validate_certs: false
+ register: dvs_pg_result_0018
+ ignore_errors: true
+
+- name: Ensure module fails for missing private VLAN in dvs
+ assert:
+ that:
+ - not dvs_pg_result_0018.changed
+ - "'No private vlan with id 10 in distributed vSwitch {{ dvswitch1 }}' == '{{ dvs_pg_result_0018.msg }}'"
+
+- name: Run tests and clean up
+ block:
+ - name: add distributed vSwitch
+ community.vmware.vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_0001
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0001
+
+ - name: ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_result_0001 is changed
+
+ - name: Configure PVLANs to test PVLAN dpg
+ community.vmware.vmware_dvswitch_pvlans:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch: dvswitch_0001
+ primary_pvlans:
+ - primary_pvlan_id: 1
+ secondary_pvlans:
+ - primary_pvlan_id: 1
+ secondary_pvlan_id: 2
+ pvlan_type: isolated
+ validate_certs: false
+ register: pvlans_result
+
+ - name: ensure pvlans were configured
+ assert:
+ that:
+ - pvlans_result is not failed
+
+ - name: Create private vlan portgroup
+ community.vmware.vmware_dvs_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ portgroup_name: private-vlan-portgroup
+ switch_name: dvswitch_0001
+ vlan_id: 1
+ vlan_private: true
+ num_ports: 12
+ port_binding: static
+ state: present
+ validate_certs: false
+ register: dvs_pg_result_0019
+
+ - name: ensure dvs portgroup with pvlan is present
+ assert:
+ that:
+ - dvs_pg_result_0019.changed
+
+ - name: Change private vlan id
+ community.vmware.vmware_dvs_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ portgroup_name: private-vlan-portgroup
+ switch_name: dvswitch_0001
+ vlan_id: 2
+ vlan_private: true
+ num_ports: 12
+ port_binding: static
+ state: present
+ validate_certs: false
+ register: dvs_pg_result_0020
+
+ - name: ensure dvs portgroup pvlan id is changed
+ assert:
+ that:
+ - dvs_pg_result_0020.changed
+
+ - name: Change private vlan to basic vlan portgroup
+ community.vmware.vmware_dvs_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ portgroup_name: private-vlan-portgroup
+ switch_name: dvswitch_0001
+ vlan_id: 5
+ num_ports: 12
+ port_binding: static
+ state: present
+ validate_certs: false
+ register: dvs_pg_result_0021
+
+ - name: ensure dvs portgroup type changed
+ assert:
+ that:
+ - dvs_pg_result_0021.changed
+ always:
+ - name: delete distributed vSwitch
+ community.vmware.vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: absent
+ switch_name: dvswitch_0001
+ register: dvs_result_0001
+
+ - name: Integration test a dvPortGroup name with special characters
+ block:
+ - name: Create dvSwitch with special characters
+ community.vmware.vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: 'dvSwitch\/%'
+ version: 6.5.0
+ mtu: 9000
+ uplink_quantity: 1
+ state: present
+ register: create_dvswitch_with_special_characters_result
+
+ - assert:
+ that:
+ - create_dvswitch_with_special_characters_result.changed is sameas true
+
+ - name: Create dvPortGroup with special characters
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: 'dvSwitch\/%'
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: static
+ state: present
+ register: create_dvportgroup_with_special_characters_result
+
+ - assert:
+ that:
+ - create_dvportgroup_with_special_characters_result.changed is sameas true
+
+ - name: Create dvPortGroup with special characters(idempotency check)
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: 'dvSwitch\/%'
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: static
+ state: present
+ register: create_dvportgroup_with_special_characters_idempotency_check_result
+
+ - assert:
+ that:
+ - create_dvportgroup_with_special_characters_idempotency_check_result.changed is sameas false
+
+ - name: Delete dvPortGroup with special characters
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: 'dvSwitch\/%'
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: static
+ state: absent
+ register: delete_dvportgroup_with_special_characters_result
+
+ - assert:
+ that:
+ - delete_dvportgroup_with_special_characters_result.changed is sameas true
+
+ - name: Delete dvPortGroup with special characters(idempotency check)
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: 'dvSwitch\/%'
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: static
+ state: absent
+ register: delete_dvportgroup_with_special_characters_idempotency_check_result
+
+ - assert:
+ that:
+ - delete_dvportgroup_with_special_characters_idempotency_check_result.changed is sameas false
+
+ - name: Delete dvSwitch with special characters
+ community.vmware.vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: 'dvSwitch\/%'
+ version: 6.5.0
+ mtu: 9000
+ uplink_quantity: 1
+ state: absent
+ register: delete_dvswitch_with_special_characters_result
+
+ - assert:
+ that:
+ - delete_dvswitch_with_special_characters_result.changed is sameas true
+
+ # https://github.com/ansible-collections/community.vmware/issues/637
+ # The test if the vmware_dvs_portgroup has the idempotency when it is configured the multiple VLAN.
+ - name: Create the test dvs port group for the issues 637
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ portgroup_name: "dvpg637"
+ switch_name: "{{ dvswitch1 }}"
+ vlan_id: "1500,1501"
+ vlan_trunk: true
+ num_ports: 120
+ port_binding: static
+ network_policy:
+ inherited: false
+ promiscuous: false
+ forged_transmits: true
+ mac_changes: true
+ state: present
+ register: create_test_dvs_port_group_issues_637_result
+
+ - assert:
+ that:
+ - create_test_dvs_port_group_issues_637_result.changed is sameas true
+
+ - name: Create the test dvs port group for the issues 637(idempotency check)
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ portgroup_name: "dvpg637"
+ switch_name: "{{ dvswitch1 }}"
+ vlan_id: "1500,1501"
+ vlan_trunk: true
+ num_ports: 120
+ port_binding: static
+ network_policy:
+ inherited: false
+ promiscuous: false
+ forged_transmits: true
+ mac_changes: true
+ state: present
+ register: create_test_dvs_port_group_issues_637_idempotency_check_result
+
+ - assert:
+ that:
+ - create_test_dvs_port_group_issues_637_idempotency_check_result.changed is sameas false
+
+ - name: Delete the test dvs port group for the issues 637
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ portgroup_name: "dvpg637"
+ switch_name: "{{ dvswitch1 }}"
+ vlan_id: "1500,1501"
+ vlan_trunk: true
+ num_ports: 120
+ port_binding: static
+ network_policy:
+ inherited: false
+ promiscuous: false
+ forged_transmits: true
+ mac_changes: true
+ state: absent
+ register: delete_test_dvs_port_group_issues_637_idempotency_check_result
+
+ - assert:
+ that:
+ - delete_test_dvs_port_group_issues_637_idempotency_check_result.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/tasks/main.yml
new file mode 100644
index 00000000..7ce2f5f2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_find/tasks/main.yml
@@ -0,0 +1,101 @@
+# Test code for the vmware_dvs_portgroup_find module.
+# Copyright: (c) 2019, David Martinez (@dx0xm)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_dvswitch: true
+ setup_dvs_portgroup: true
+
+- name: get list of portgroups
+ vmware_dvs_portgroup_find:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: dvspg_0001
+
+- debug:
+ var: dvspg_0001
+
+- assert:
+ that:
+ - dvspg_0001.dvs_portgroups is defined
+
+- name: get portgroups by vlanid
+ vmware_dvs_portgroup_find:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ vlanid: "0"
+ register: dvspgvlid_0001
+
+- debug:
+ var: dvspgvlid_0001
+
+- assert:
+ that:
+ - dvspgvlid_0001.dvs_portgroups is defined
+ - dvspgvlid_0001.dvs_portgroups[1] is defined
+ - dvspgvlid_0001.dvs_portgroups | selectattr("vlan_id", "equalto", "0")|map(attribute="vlan_id")|first == "0"
+
+# https://github.com/ansible-collections/community.vmware/pull/648
+- name: Create dvPortGroup with special characters
+ vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: present
+ register: create_dvportgroup_with_special_characters_result
+
+- name: Make sure if the dvportgroup name with special characters is created
+ assert:
+ that:
+ - create_dvportgroup_with_special_characters_result.changed is sameas true
+
+- name: get list of portgroups
+ vmware_dvs_portgroup_find:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: dvspg_0002
+
+- name: Make sure if the dvportgroup name with special characters is created
+ assert:
+ that:
+ - >-
+ dvspg_0002.dvs_portgroups
+ | map(attribute='name')
+ | select('==', 'dvportgroup\/%')
+ | list
+ | length == 1
+
+- name: Delete dvPortGroup with special characters
+ vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: absent
+ register: delete_dvportgroup_with_special_characters_result
+
+- name: Make sure if the dvportgroup is deleted
+ assert:
+ that:
+ - delete_dvportgroup_with_special_characters_result.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml
new file mode 100644
index 00000000..4c8c689c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml
@@ -0,0 +1,110 @@
+# Test code for the vmware_dvs_portgroup_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_dvswitch: true
+
+- &dvs_info
+ name: Gather info about DVS portgroup
+ vmware_dvs_portgroup_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ register: dvs_results
+
+- debug:
+ var: dvs_results
+
+- assert:
+ that:
+ - dvs_results.dvs_portgroup_info is defined
+
+- <<: *dvs_info
+ name: Gather info about DVS portgroup in check mode
+ check_mode: true
+
+- debug:
+ var: dvs_results
+
+- assert:
+ that:
+ - dvs_results.dvs_portgroup_info is defined
+
+# https://github.com/ansible-collections/community.vmware/pull/648
+- name: The test for the dvportgroup with special characters
+ block:
+ - name: Create dvPortGroup with special characters
+ vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: present
+ register: create_dvportgroup_with_special_characters_result
+
+ - name: Make sure if the dvportgroup name with special characters is created
+ assert:
+ that:
+ - create_dvportgroup_with_special_characters_result.changed is sameas true
+
+ - <<: *dvs_info
+
+ - name: Make sure if the dvportgroup name with special characters exists
+ assert:
+ that:
+ - >-
+ dvs_results.dvs_portgroup_info.{{ dvswitch1 }}
+ | map(attribute='portgroup_name')
+ | select('==', 'dvportgroup\/%')
+ | list
+ | length == 1
+
+ - name: Delete dvPortGroup with special characters
+ vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: 'dvportgroup\/%'
+ vlan_id: 1
+ num_ports: 8
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: absent
+ register: delete_dvportgroup_with_special_characters_result
+
+ - name: Make sure if the dvportgroup is deleted
+ assert:
+ that:
+ - delete_dvportgroup_with_special_characters_result.changed is sameas true
+
+# Testcase 0002: Get portgroup info for a given dvswitch
+- name: get info for a given dvswitch
+ vmware_dvs_portgroup_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ dvswitch: "{{ dvswitch1 }}"
+ register: dvs_results_0002
+
+- debug:
+ msg: "{{ dvs_results_0002 }}"
+
+- assert:
+ that:
+ - "dvs_results_0002['dvs_portgroup_info']['DVS0'] is defined"
+ - dvs_results_0002['dvs_portgroup_info']['DVS0'][0].key
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/tasks/main.yml
new file mode 100644
index 00000000..3db1fdc3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch/tasks/main.yml
@@ -0,0 +1,266 @@
+# Test code for the vmware_dvswitch module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+- &dvs_data
+ name: Add distributed vSwitch
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ contact:
+ name: admin
+ description: some_description
+ switch_name: dvswitch_0001
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0001
+
+- name: Ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_result_0001.changed
+
+- name: Create a network folder on given Datacenter
+ vcenter_folder:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ folder_name: network_folder
+ folder_type: network
+ state: present
+ validate_certs: false
+ register:
+ network_folder_result
+
+- name: Add distributed vSwitch using folder
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ network_folder_result.result.path }}"
+ state: present
+ switch_name: dvswitch_0002
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0002
+
+- name: Ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_result_0002.changed
+
+- <<: *dvs_data
+ name: add distributed vSwitch again
+ register: dvs_result_0002
+
+- name: ensure distributed vswitch is present
+ assert:
+ that:
+ - not dvs_result_0002.changed
+
+- name: Add distributed vSwitch with network policy
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_network_policy
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ network_policy:
+ promiscuous: false
+ forged_transmits: false
+ mac_changes: false
+ register: dvs_with_network_policy_result
+
+- name: Ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_with_network_policy_result.changed
+
+- name: Add distributed vSwitch with network policy again (idempotency)
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_network_policy
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ network_policy:
+ promiscuous: false
+ forged_transmits: false
+ mac_changes: false
+ register: dvs_with_network_policy_again_result
+
+- name: Ensure distributed vswitch is present
+ assert:
+ that:
+ - not dvs_with_network_policy_again_result.changed
+
+- name: Change network policy
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_network_policy
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ network_policy:
+ promiscuous: true
+ forged_transmits: false
+ mac_changes: false
+ register: dvs_change_network_policy_result
+
+- name: Ensure network policy is changed
+ assert:
+ that:
+ - dvs_change_network_policy_result.changed
+
+- name: Change network policy again (idempotency)
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_network_policy
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ network_policy:
+ promiscuous: true
+ forged_transmits: false
+ mac_changes: false
+ register: dvs_change_network_policy_again_result
+
+- name: Ensure network policy is not changed
+ assert:
+ that:
+ - not dvs_change_network_policy_again_result.changed
+
+# Testcase 0003: Add Distributed vSwitch
+- name: delete the distributed vSwitch
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: absent
+ switch_name: '{{ item }}'
+ loop:
+ - dvswitch_0001
+ - dvswitch_0002
+ - dvswitch_network_policy
+ register: dvswitch_delete
+- debug: var=dvswitch_delete
+
+- name: Ensure the state has changed
+ assert:
+ that:
+ - dvswitch_delete.results[0] is changed
+ - dvswitch_delete.results[1] is changed
+ - dvswitch_delete.results[2] is changed
+
+- name: Create dvSwitch with special characters
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: 'dvSwitch\/%'
+ version: 6.5.0
+ mtu: 9000
+ uplink_quantity: 1
+ state: present
+ register: create_dvswitch_with_special_characters_result
+
+- assert:
+ that:
+ - create_dvswitch_with_special_characters_result.changed is sameas true
+
+- name: Create dvSwitch with special characters(idempotency check)
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: 'dvSwitch\/%'
+ version: 6.5.0
+ mtu: 9000
+ uplink_quantity: 1
+ state: present
+ register: create_dvswitch_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - create_dvswitch_with_special_characters_idempotency_check_result.changed is sameas false
+
+- name: Delete dvSwitch with special characters
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: 'dvSwitch\/%'
+ version: 6.5.0
+ mtu: 9000
+ uplink_quantity: 1
+ state: absent
+ register: delete_dvswitch_with_special_characters_result
+
+- assert:
+ that:
+ - delete_dvswitch_with_special_characters_result.changed is sameas true
+
+- name: Delete dvSwitch with special characters(idempotency check)
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: 'dvSwitch\/%'
+ version: 6.5.0
+ mtu: 9000
+ uplink_quantity: 1
+ state: absent
+ register: delete_dvswitch_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - delete_dvswitch_with_special_characters_idempotency_check_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/tasks/main.yml
new file mode 100644
index 00000000..7fbf3056
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/tasks/main.yml
@@ -0,0 +1,220 @@
+# Test code for the vmware_dvswitch_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+- name: add distributed vSwitch
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ switch_name: "{{ dvswitch1 }}"
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ state: present
+ register: add_distributed_vswitch_result
+
+- assert:
+ that:
+ - add_distributed_vswitch_result.changed
+
+- name: get list of info about dvswitches - check_mode is enabled
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ check_mode: true
+ register: info_dvswitches_result
+
+- debug: var=info_dvswitches_result
+
+- assert:
+ that:
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
+
+- name: get list of info about all dvswitches
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: info_dvswitches_result
+
+- debug: var=info_dvswitches_result
+
+- assert:
+ that:
+ - info_dvswitches_result.distributed_virtual_switches | length == 1
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
+
+- name: get list of info about dvswitches
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ register: info_dvswitches_result
+
+- debug: var=info_dvswitches_result
+
+- assert:
+ that:
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
+
+- name: get list of info about dvswitches - add folder param
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ dc1 }}/network"
+ switch_name: "{{ dvswitch1 }}"
+ register: info_dvswitches_result
+
+- debug: var=info_dvswitches_result
+
+- assert:
+ that:
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
+ - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
+
+- name: get list of info about one dvswitches with properties specify
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ schema: vsphere
+ properties:
+ - name
+ register: info_dvswitches_with_properties_result
+
+- debug: var=info_dvswitches_with_properties_result
+
+- assert:
+ that:
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name == dvswitch1
+
+- name: get list of info about one dvswitches with properties specify - add folder param
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ dc1 }}/network"
+ switch_name: "{{ dvswitch1 }}"
+ schema: vsphere
+ properties:
+ - name
+ register: info_dvswitches_with_properties_result
+
+- debug: var=info_dvswitches_with_properties_result
+
+- assert:
+ that:
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
+
+- name: get list of info about dvswitches with multiple properties specify
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ schema: vsphere
+ properties:
+ - name
+ - summary.numPorts
+ - config.maxMtu
+ register: info_dvswitches_with_properties_result
+
+- debug: var=info_dvswitches_with_properties_result
+
+- assert:
+ that:
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.summary.numPorts is defined
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.config.maxMtu is defined
+
+- name: get list of info about dvswitches with multiple properties specify - add folder param
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ dc1 }}/network"
+ switch_name: "{{ dvswitch1 }}"
+ schema: vsphere
+ properties:
+ - name
+ - summary.numPorts
+ - config.maxMtu
+ register: info_dvswitches_with_properties_result
+
+- debug: var=info_dvswitches_with_properties_result
+
+- assert:
+ that:
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.summary.numPorts is defined
+ - info_dvswitches_with_properties_result.distributed_virtual_switches.0.config.maxMtu is defined
+
+- name: delete distributed vSwitch
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ switch_name: "{{ dvswitch1 }}"
+ state: absent
+ register: delete_distributed_vswitch_result
+
+- assert:
+ that:
+ - delete_distributed_vswitch_result.changed
+
+- name: get list of info about all dvswitches
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: info_dvswitches_result
+
+- assert:
+ that:
+ - info_dvswitches_result.distributed_virtual_switches | length == 0
+
+- name: get list of when not exist the dvswitch
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "not_exist_the_dvswitch"
+ register: info_dvswitches_result
+
+- assert:
+ that:
+ - info_dvswitches_result.distributed_virtual_switches | length == 0
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/tasks/main.yml
new file mode 100644
index 00000000..0608bf27
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_nioc/tasks/main.yml
@@ -0,0 +1,101 @@
+# Test code for the vmware_dvswitch_nioc module.
+# Copyright: (c) 2018, VMware, Inc.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# SPDX-License-Identifier: GPL-3.0-or-later
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Add distributed vSwitch
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_0001
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0001
+
+- debug:
+ var: dvs_result_0001
+
+- name: ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_result_0001 is changed
+
+- &enable_nioc
+ name: Enable NIOC
+ vmware_dvswitch_nioc:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch: dvswitch_0001
+ version: version3
+ validate_certs: false
+ resources:
+ - name: vmotion
+ limit: -1
+ reservation: 128
+ shares_level: normal
+ - name: vsan
+ limit: -1
+ shares_level: custom
+ shares: 99
+ reservation: 256
+ state: present
+ register: enable_nioc_result
+
+- debug:
+ var: enable_nioc_result
+
+- name: Check if nioc is enabled
+ assert:
+ that:
+ - enable_nioc_result.changed
+
+- <<: *enable_nioc
+ name: Change nioc settings again and make sure it does not change
+ register: enable_nioc_result_2
+
+- name: Check if nioc changes are not made
+ assert:
+ that:
+ - not enable_nioc_result_2.changed
+
+- &disable_nioc
+ name: Disable NIOC
+ vmware_dvswitch_nioc:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch: dvswitch_0001
+ validate_certs: false
+ state: absent
+ register: disable_nioc_result
+
+- debug:
+ var: disable_nioc_result
+
+- name: Check if nioc is disabled
+ assert:
+ that:
+ - disable_nioc_result.changed
+
+- <<: *disable_nioc
+ name: Disable NIOC again
+ register: disable_nioc_result_2
+
+- debug:
+ var: disable_nioc_result_2
+
+- name: Check if nioc is not disabled since it is already disabled
+ assert:
+ that:
+ - not disable_nioc_result_2.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml
new file mode 100644
index 00000000..7cf91a5b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_pvlans/tasks/main.yml
@@ -0,0 +1,72 @@
+# Test code for the vmware_dvswitch_pvlans module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+# Testcase 0001: Add Distributed vSwitch
+- name: add distributed vSwitch
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_0001
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0001
+
+- debug:
+ var: dvs_result_0001
+
+- name: ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_result_0001 is changed
+
+- &pv_data
+ name: Configure PVLANs
+ vmware_dvswitch_pvlans:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch: dvswitch_0001
+ primary_pvlans:
+ - primary_pvlan_id: 1
+ - primary_pvlan_id: 4
+ secondary_pvlans:
+ - primary_pvlan_id: 1
+ secondary_pvlan_id: 2
+ pvlan_type: isolated
+ - primary_pvlan_id: 1
+ secondary_pvlan_id: 3
+ pvlan_type: community
+ - primary_pvlan_id: 4
+ secondary_pvlan_id: 5
+ pvlan_type: community
+ validate_certs: false
+ register: pvlans_result
+
+- debug:
+ var: pvlans_result
+
+- name: ensure pvlans were configured
+ assert:
+ that:
+ - pvlans_result is changed
+
+- <<: *pv_data
+ name: Configure PVLANs in check mode
+ register: pvlans_result_check_mode
+ check_mode: true
+- debug:
+ var: pvlans_result_check_mode
+- name: ensure pvlans were not changed
+ assert:
+ that:
+ - not (pvlans_result_check_mode is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml
new file mode 100644
index 00000000..b3e9b5c4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_uplink_pg/tasks/main.yml
@@ -0,0 +1,73 @@
+# Test code for the vmware_dvswitch_uplink_pg module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+# Testcase 0001: Add Distributed vSwitch
+- name: add distributed vSwitch
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_0001
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0001
+
+- debug:
+ var: dvs_result_0001
+
+- name: ensure distributed vswitch is present
+ assert:
+ that:
+ - dvs_result_0001 is changed
+
+- &uplink_data
+ name: Configure Uplink portgroup in check mode
+ vmware_dvswitch_uplink_pg:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch: dvswitch_0001
+ name: dvswitch_0001-DVUplinks
+ advanced:
+ port_config_reset_at_disconnect: false
+ block_override: false
+ vendor_config_override: false
+ vlan_override: false
+ netflow_override: false
+ traffic_filter_override: false
+ vlan_trunk_range: [ 2-3967, 4049-4092 ]
+ netflow_enabled: true
+ block_all_ports: false
+ validate_certs: false
+ register: uplink_pg_result_check_mode
+ check_mode: true
+
+- debug:
+ var: uplink_pg_result_check_mode
+
+- name: ensure uplink portgroup was changed
+ assert:
+ that:
+ - uplink_pg_result_check_mode is changed
+
+- <<: *uplink_data
+ name: Configure Uplink portgroup
+ register: uplink_pg_result
+ check_mode: false
+
+- debug:
+ var: uplink_pg_result
+
+- name: ensure uplink portgroup was changed
+ assert:
+ that:
+ - uplink_pg_result is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/aliases
new file mode 100644
index 00000000..b268038d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/meta/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/meta/main.yml
new file mode 100644
index 00000000..828342c2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/tasks/main.yml
new file mode 100644
index 00000000..2204df41
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_evc_mode/tasks/main.yml
@@ -0,0 +1,50 @@
+# Test code for the vmware evc mode module.
+# Copyright: (c) 2019, Michael Tipton <mike () ibeta.org>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+- name: add cluster
+ vmware_cluster:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_0001
+ state: present
+
+- &evc_enable_data
+ name: Enable EVC mode on vCenter Cluster
+ vmware_evc_mode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_0001
+ evc_mode: intel-broadwell
+ state: present
+
+- <<: *evc_enable_data
+ name: Enable EVC mode on vCenter cluster in check mode
+ check_mode: true
+
+- &evc_disable_data
+ name: Disable EVC mode on vCenter Cluster
+ vmware_evc_mode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: test_cluster_0001
+ evc_mode: intel-broadwell
+ state: absent
+
+- <<: *evc_disable_data
+ name: Disable EVC mode on vCenter Cluster in check mode
+ check_mode: true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/tasks/main.yml
new file mode 100644
index 00000000..94257cb5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_export_ovf/tasks/main.yml
@@ -0,0 +1,60 @@
+# Test code for the vmware_export_ovf module
+# Copyright: (c) 2019, Diane Wang (Tomorrow9) <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Run tests and clean up
+ block:
+ - name: create temporary build directory
+ tempfile:
+ state: directory
+ suffix: build
+ register: temp_dir
+ - debug: var=temp_dir
+
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+ - name: export VM to ovf template
+ vmware_export_ovf:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines_in_cluster[0].name }}"
+ datacenter: "{{ dc1 }}"
+ export_dir: "{{ temp_dir.path }}"
+ register: ovf_template
+ - debug: var=ovf_template
+ - name: assert the ovf template exported
+ assert:
+ that:
+ - "ovf_template.changed == true"
+ - "ovf_template.instance.device_files | length >= 1"
+
+ - name: export VM to ovf template with timeout set
+ vmware_export_ovf:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines_in_cluster[0].name }}"
+ datacenter: "{{ dc1 }}"
+ export_dir: "{{ temp_dir.path }}"
+ download_timeout: 30
+ register: ovf_template
+ - debug: var=ovf_template
+ - name: assert the ovf template exported
+ assert:
+ that:
+ - "ovf_template.changed == true"
+ - "ovf_template.instance.device_files | length >= 1"
+ always:
+ - name: Clean up the temporary dir
+ file:
+ path: "{{ temp_dir.path }}"
+ state: absent
+ when: temp_dir.path is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/tasks/main.yml
new file mode 100644
index 00000000..0119d33e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk/tasks/main.yml
@@ -0,0 +1,290 @@
+# Test code for the vmware_first_class_disk module.
+# Copyright: (c) 2021, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Create first-class disk through vCenter (check mode)
+ vmware_first_class_disk: &disk_vcenter_create
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ disk_name: "firstclassdisk"
+ size: 1GB
+ datastore_name: "{{ rw_datastore }}"
+ state: present
+ validate_certs: false
+ check_mode: true
+ register: result_create_vcenter_check_mode
+
+- debug:
+ var: result_create_vcenter_check_mode
+
+- name: assert that first-class disk would be created
+ assert:
+ that:
+ - result_create_vcenter_check_mode is changed
+
+- name: Create first-class disk through vCenter
+ vmware_first_class_disk:
+ <<: *disk_vcenter_create
+ register: result_create_vcenter
+
+- debug:
+ var: result_create_vcenter
+
+- name: assert that first-class disk is created
+ assert:
+ that:
+ - result_create_vcenter is changed
+
+- name: Create first-class disk through vCenter again (idempotency)
+ vmware_first_class_disk:
+ <<: *disk_vcenter_create
+ register: result_create_vcenter_again
+
+- debug:
+ var: result_create_vcenter_again
+
+- name: assert that first-class disk would not be created
+ assert:
+ that:
+ - result_create_vcenter_again is not changed
+
+- name: Increase disk size through vCenter (check mode)
+ vmware_first_class_disk: &disk_vcenter_increase
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ disk_name: "firstclassdisk"
+ size: 2GB
+ datastore_name: "{{ rw_datastore }}"
+ state: present
+ validate_certs: false
+ check_mode: true
+ register: result_increase_vcenter_check_mode
+
+- debug:
+ var: result_increase_vcenter_check_mode
+
+- name: assert that disk size would be increased
+ assert:
+ that:
+ - result_increase_vcenter_check_mode is changed
+
+- name: Increase disk size through vCenter
+ vmware_first_class_disk:
+ <<: *disk_vcenter_increase
+ register: result_increase_vcenter
+
+- debug:
+ var: result_increase_vcenter
+
+- name: assert that disk size was increased
+ assert:
+ that:
+ - result_increase_vcenter is changed
+
+- name: Increase disk size through vCenter again (idempotency)
+ vmware_first_class_disk:
+ <<: *disk_vcenter_increase
+ register: result_increase_vcenter_again
+
+- debug:
+ var: result_increase_vcenter_again
+
+- name: assert that disk size would not be increased
+ assert:
+ that:
+ - result_increase_vcenter_again is not changed
+
+- name: Delete first-class disk through vCenter (check mode)
+ vmware_first_class_disk: &disk_vcenter_delete
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ disk_name: "firstclassdisk"
+ datastore_name: "{{ rw_datastore }}"
+ state: absent
+ validate_certs: false
+ check_mode: true
+ register: result_delete_vcenter_check_mode
+
+- debug:
+ var: result_delete_vcenter_check_mode
+
+- name: assert that first-class disk would be deleted
+ assert:
+ that:
+ - result_delete_vcenter_check_mode is changed
+
+- name: Delete first-class disk through vCenter
+ vmware_first_class_disk:
+ <<: *disk_vcenter_delete
+ register: result_delete_vcenter
+
+- debug:
+ var: result_delete_vcenter
+
+- name: assert that first-class disk is deleted
+ assert:
+ that:
+ - result_delete_vcenter is changed
+
+- name: Delete first-class disk through vCenter again (idempotency)
+ vmware_first_class_disk:
+ <<: *disk_vcenter_delete
+ register: result_delete_vcenter_again
+
+- debug:
+ var: result_delete_vcenter_again
+
+- name: assert that first-class disk would not be deleted
+ assert:
+ that:
+ - result_delete_vcenter_again is not changed
+
+- name: Create first-class disk through ESXi (check mode)
+ vmware_first_class_disk: &disk_esxi_create
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ disk_name: "firstclassdisk"
+ size: 1GB
+ datastore_name: "{{ rw_datastore }}"
+ state: present
+ validate_certs: false
+ check_mode: true
+ register: result_create_esxi_check_mode
+
+- debug:
+ var: result_create_esxi_check_mode
+
+- name: assert that first-class disk would be created
+ assert:
+ that:
+ - result_create_esxi_check_mode is changed
+
+- name: Create first-class disk through ESXi
+ vmware_first_class_disk:
+ <<: *disk_esxi_create
+ register: result_create_esxi
+
+- debug:
+ var: result_create_esxi
+
+- name: assert that first-class disk is created
+ assert:
+ that:
+ - result_create_esxi is changed
+
+- name: Create first-class disk through ESXi again (idempotency)
+ vmware_first_class_disk:
+ <<: *disk_esxi_create
+ register: result_create_esxi_again
+
+- debug:
+ var: result_create_esxi_again
+
+- name: assert that first-class disk would not be created
+ assert:
+ that:
+ - result_create_esxi_again is not changed
+
+- name: Increase disk size through ESXi (check mode)
+ vmware_first_class_disk: &disk_esxi_increase
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ disk_name: "firstclassdisk"
+ size: 2GB
+ datastore_name: "{{ rw_datastore }}"
+ state: present
+ validate_certs: false
+ check_mode: true
+ register: result_increase_esxi_check_mode
+
+- debug:
+ var: result_increase_esxi_check_mode
+
+- name: assert that disk size would be increased
+ assert:
+ that:
+ - result_increase_esxi_check_mode is changed
+
+- name: Increase disk size through ESXi
+ vmware_first_class_disk:
+ <<: *disk_esxi_increase
+ register: result_increase_esxi
+
+- debug:
+ var: result_increase_esxi
+
+- name: assert that disk size was increased
+ assert:
+ that:
+ - result_increase_esxi is changed
+
+- name: Increase disk size through ESXi again (idempotency)
+ vmware_first_class_disk:
+ <<: *disk_esxi_increase
+ register: result_increase_esxi_again
+
+- debug:
+ var: result_increase_esxi_again
+
+- name: assert that disk size would not be increased
+ assert:
+ that:
+ - result_increase_esxi_again is not changed
+
+
+- name: Delete first-class disk through ESXi (check mode)
+ vmware_first_class_disk: &disk_esxi_delete
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ disk_name: "firstclassdisk"
+ datastore_name: "{{ rw_datastore }}"
+ state: absent
+ validate_certs: false
+ check_mode: true
+ register: result_delete_esxi_check_mode
+
+- debug:
+ var: result_delete_esxi_check_mode
+
+- name: assert that first-class disk would be deleted
+ assert:
+ that:
+ - result_delete_esxi_check_mode is changed
+
+- name: Delete first-class disk through ESXi
+ vmware_first_class_disk:
+ <<: *disk_esxi_delete
+ register: result_delete_esxi
+
+- debug:
+ var: result_delete_esxi
+
+- name: assert that first-class disk is deleted
+ assert:
+ that:
+ - result_delete_esxi is changed
+
+- name: Delete first-class disk through ESXi again (idempotency)
+ vmware_first_class_disk:
+ <<: *disk_esxi_delete
+ register: result_delete_esxi_again
+
+- debug:
+ var: result_delete_esxi_again
+
+- name: assert that first-class disk would not be deleted
+ assert:
+ that:
+ - result_delete_esxi_again is not changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml
new file mode 100644
index 00000000..51b53f4b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml
@@ -0,0 +1,52 @@
+# Test code for the vmware_folder_info module.
+# Copyright: (c) 2019, David Hewitt (@davidmhewitt) <davidmhewitt@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: create example toplevel folder
+ vcenter_folder:
+ <<: &vcenter_folder_data
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 | basename }}"
+ validate_certs: false
+ folder_name: "toplevel"
+
+- name: create an example child folder
+ vcenter_folder:
+ <<: *vcenter_folder_data
+ folder_name: "child_folder"
+ parent_folder: "toplevel"
+
+# Testcase 0001: Get details about folders
+- name: get info about folders
+ vmware_folder_info:
+ <<: *vcenter_folder_data
+ register: folder_info_0001
+
+- debug: var=folder_info_0001
+
+- assert:
+ that:
+ - "{{ item }} is defined"
+ with_items:
+ - folder_info_0001['folder_info']
+ - folder_info_0001['flat_folder_info']
+ - folder_info_0001['folder_info']['datastoreFolders']
+ - folder_info_0001['folder_info']['hostFolders']
+ - folder_info_0001['folder_info']['vmFolders']
+ - folder_info_0001['folder_info']['networkFolders']
+ - folder_info_0001['folder_info']['vmFolders']['subfolders']['toplevel']
+ - folder_info_0001['folder_info']['vmFolders']['subfolders']['toplevel']['subfolders']['child_folder']
+
+- assert:
+ that:
+ - "folder_info_0001['folder_info']['datastoreFolders']['path'] == \"/{{ dc1 | basename }}/datastore\""
+ - "folder_info_0001['folder_info']['hostFolders']['path'] == \"/{{ dc1 | basename }}/host\""
+ - "folder_info_0001['folder_info']['vmFolders']['path'] == \"/{{ dc1 | basename }}/vm\""
+ - "folder_info_0001['folder_info']['networkFolders']['path'] == \"/{{ dc1 | basename }}/network\""
+ - "folder_info_0001['folder_info']['vmFolders']['subfolders']['toplevel']['path'] == \"/{{ dc1 | basename }}/vm/toplevel\""
+ - "folder_info_0001['folder_info']['vmFolders']['subfolders']['toplevel']['subfolders']['child_folder']['path'] == \"/{{ dc1 | basename }}/vm/toplevel/child_folder\""
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/defaults/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/defaults/main.yml
new file mode 100644
index 00000000..04690fb5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/defaults/main.yml
@@ -0,0 +1,30 @@
+vmware_guest_test_playbooks:
+ - boot_firmware_d1_c1_f0.yml
+ - boot_firmware_d1_c1_f0.yml
+ - cdrom_d1_c1_f0.yml
+ - check_mode.yml
+ - clone_customize_guest_test.yml
+ - clone_d1_c1_f0.yml
+ - clone_resize_disks.yml
+ - clone_with_convert.yml
+ - create_d1_c1_f0.yml
+ - create_guest_invalid_d1_c1_f0.yml
+ - create_nw_d1_c1_f0.yml
+ - create_rp_d1_c1_f0.yml
+ - delete_vm.yml
+ - disk_mode_d1_c1_f0.yml
+ - disk_size_d1_c1_f0.yml
+ - disk_type_d1_c1_f0.yml
+ - mac_address_d1_c1_f0.yml
+ - max_connections.yml
+ - mem_reservation.yml
+ - shares.yml
+ - multiple_disk_controllers_d1_c1_f0.yml
+ - network_negative_test.yml
+ - network_with_device.yml
+ - non_existent_vm_ops.yml
+ - vapp_d1_c1_f0.yml
+ - reconfig_vm_to_latest_version.yml
+ - remove_vm_from_inventory.yml
+ - create_vm_using_special_characters.yml
+ - advanced_settings.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/advanced_settings.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/advanced_settings.yml
new file mode 100644
index 00000000..b60a7ba4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/advanced_settings.yml
@@ -0,0 +1,97 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2021, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create new VM for advance settings
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ f0 }}"
+ register: r
+
+- debug: var=r
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - r is changed
+
+- name: Change advance settings for VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ state: present
+ folder: "{{ f0 }}"
+ advanced_settings:
+ - key: "svga.present"
+ value: "FALSE"
+ register: r
+ check_mode: true
+
+- debug: var=r
+
+- name: Assert that changes would be made
+ assert:
+ that:
+ - r is changed
+
+- name: Change advance settings for VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ state: present
+ folder: "{{ f0 }}"
+ advanced_settings:
+ - key: "svga.present"
+ value: "FALSE"
+ register: r
+
+- debug: var=r
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - r is changed
+
+- name: Again change advance settings for VM (idempotency)
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ state: present
+ folder: "{{ f0 }}"
+ advanced_settings:
+ - key: "svga.present"
+ value: "FALSE"
+ register: r
+
+- debug: var=r
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - r is not changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml
new file mode 100644
index 00000000..d8f65a7a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/boot_firmware_d1_c1_f0.yml
@@ -0,0 +1,111 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs with boot_firmware as 'bios'
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ boot_firmware: "bios"
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: clone_d1_c1_f0
+
+- debug: var=clone_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_d1_c1_f0 is changed
+
+- name: create new VMs again with boot_firmware as 'bios'
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ boot_firmware: "bios"
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: clone_d1_c1_f0
+- debug: var=clone_d1_c1_f0
+- name: assert that changes were not made
+ assert:
+ that:
+ - clone_d1_c1_f0 is changed
+
+- name: create new VMs with boot_firmware as 'efi'
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm3
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ boot_firmware: "efi"
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: clone_d1_c1_f0
+
+- debug: var=clone_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_d1_c1_f0 is changed
+
+- name: create new VMs again with boot_firmware as 'efi'
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm3
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ boot_firmware: "efi"
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: clone_d1_c1_f0
+- debug: var=clone_d1_c1_f0
+- name: assert that changes were not made
+ assert:
+ that:
+ - not (clone_d1_c1_f0 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml
new file mode 100644
index 00000000..abe194fd
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml
@@ -0,0 +1,230 @@
+# this is used to test create and configure VM with a single CDROM
+- name: Create VM with CDROM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] centos.iso"
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Update CDROM to iso for the new VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "vm"
+ name: test_vm1
+ datastore: "{{ rw_datastore }}"
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ state: present
+ register: cdrom_vm
+ check_mode: true
+
+- debug: var=cdrom_vm
+
+- name: assert the VM would be changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Update CDROM to iso for the new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "vm"
+ name: test_vm1
+ datastore: "{{ rw_datastore }}"
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ state: present
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Update CDROM to client for the new VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ type: client
+ state: present
+ register: cdrom_vm
+ check_mode: true
+
+- debug: var=cdrom_vm
+
+- name: assert the VM would be changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Update CDROM to client for the new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ type: client
+ state: present
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: clone vm
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ template: test_vm1
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: vm
+ convert: thin
+
+- name: Update CDROM to none for the new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm2
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ type: none
+ state: present
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Create VM with multiple disks and a CDROM - GitHub issue 38679
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ f0 }}"
+ name: test_vm3
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Again create VM with multiple disks and a CDROM - GitHub issue 38679
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ f0 }}"
+ name: test_vm3
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] base.iso"
+ register: cdrom_vm
+- debug: var=cdrom_vm
+- name: assert the VM was created
+ assert:
+ that:
+ - cdrom_vm is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f1.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f1.yml
new file mode 100644
index 00000000..1a335f42
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f1.yml
@@ -0,0 +1,365 @@
+# this is used to test create and configure VM with multiple CDROMs
+# attached to IDE or SATA
+- name: Create VM with multiple CDROMs attached to IDE
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ cdrom:
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 0
+ type: iso
+ iso_path: "[{{ ro_datastore }}] centos.iso"
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 1
+ type: client
+ - controller_number: 1
+ unit_number: 0
+ type: none
+ - controller_number: 1
+ unit_number: 1
+ type: client
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Remove the last 2 CDROMs and update the first 2 for the new VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 0
+ type: client
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 1
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 0
+ state: absent
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 1
+ state: absent
+ state: present
+ register: cdrom_vm
+ check_mode: true
+
+- debug: var=cdrom_vm
+
+- name: assert the VM would be changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Remove the last 2 CDROMs and update the first 2 for the new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 0
+ type: client
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 1
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 0
+ state: absent
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 1
+ state: absent
+ state: present
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Create VM with multiple CDROMs attached to SATA
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm2
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ cdrom:
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ type: iso
+ iso_path: "[{{ ro_datastore }}] centos.iso"
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 1
+ type: client
+ - controller_type: sata
+ controller_number: 2
+ unit_number: 0
+ type: none
+ - controller_type: sata
+ controller_number: 3
+ unit_number: 1
+ type: client
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Remove the first 2 CDROMs and update the last 2 for the new VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm2
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ state: absent
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 1
+ state: absent
+ - controller_type: sata
+ controller_number: 2
+ unit_number: 0
+ type: client
+ - controller_type: sata
+ controller_number: 3
+ unit_number: 1
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ state: present
+ register: cdrom_vm
+ check_mode: true
+
+- debug: var=cdrom_vm
+
+- name: assert the VM would be changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Remove the first 2 CDROMs and update the last 2 for the new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm2
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ state: absent
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 1
+ state: absent
+ - controller_type: sata
+ controller_number: 2
+ unit_number: 0
+ type: client
+ - controller_type: sata
+ controller_number: 3
+ unit_number: 1
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ state: present
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Create VM with multiple CDROMs attached to IDE and SATA
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm3
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ cdrom:
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 0
+ type: iso
+ iso_path: "[{{ ro_datastore }}] centos.iso"
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ type: client
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 0
+ type: none
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 0
+ type: client
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Remove the 2 CDROMs and update the other 2 for the new VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm3
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 0
+ state: absent
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 0
+ type: client
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 0
+ state: absent
+ state: present
+ register: cdrom_vm
+ check_mode: true
+
+- debug: var=cdrom_vm
+
+- name: assert the VM would be changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
+
+- name: Remove the 2 CDROMs and update the other 2 for the new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ name: test_vm3
+ datacenter: "{{ dc1 }}"
+ cdrom:
+ - controller_type: ide
+ controller_number: 0
+ unit_number: 0
+ state: absent
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ - controller_type: ide
+ controller_number: 1
+ unit_number: 0
+ type: client
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 0
+ state: absent
+ state: present
+ register: cdrom_vm
+
+- debug: var=cdrom_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "cdrom_vm.changed == true"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml
new file mode 100644
index 00000000..2d2ace99
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml
@@ -0,0 +1,85 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create VMs
+ vmware_guest:
+ datacenter: "{{ dc1 }}"
+ folder: '{{ f0 }}'
+ name: DC0_H0_VM0
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_mb: 10
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ version: 11
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- name: Perform all operation in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ state: "{{ item }}"
+ with_items:
+ - absent
+ - present
+ - poweredoff
+ - powered-off
+ - poweredon
+ - powered-on
+ - restarted
+ - suspended
+ - shutdownguest
+ - shutdown-guest
+ - rebootguest
+ - reboot-guest
+ register: check_mode_state
+ check_mode: true
+
+- name: assert that changes were appropriate for an existing powered-off VM
+ assert:
+ that:
+ - "check_mode_state.results|map(attribute='changed') == [true, false, false, false, true, true, true, true, false, false, true, true]"
+ #- "check_mode_state.results|map(attribute='vm_name')|unique|list == [ virtual_machines[0].name ]"
+
+- name: Perform all operation on non-existent VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: non_existent_vm
+ datacenter: "{{ dc1 }}"
+ state: "{{ item }}"
+ with_items:
+ - present
+ - poweredoff
+ - powered-off
+ - poweredon
+ - powered-on
+ - restarted
+ - suspended
+ register: check_mode_state
+ check_mode: true
+
+- debug:
+ var: check_mode_state
+
+- name: assert that changes were made
+ assert:
+ that:
+ - "check_mode_state.results|map(attribute='changed')|unique|list == [true]"
+ - "check_mode_state.results|map(attribute='desired_operation')|unique|list == ['deploy_vm']"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml
new file mode 100644
index 00000000..77a94e2b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml
@@ -0,0 +1,69 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create VMs
+ vmware_guest:
+ datacenter: "{{ dc1 }}"
+ folder: '{{ f0 }}'
+ name: DC0_H0_VM0
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_mb: 10
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ version: 11
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- name: clone vm from template and customize GOS
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ template: DC0_H0_VM0
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ convert: thin
+ register: clone_customize
+
+- debug:
+ var: clone_customize
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_customize is changed
+
+- name: clone vm from template and customize GOS again
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ template: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ virtual_machines[0].folder }}"
+ convert: thin
+ register: clone_customize_again
+
+- debug:
+ var: clone_customize_again
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - not (clone_customize_again is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_d1_c1_f0.yml
new file mode 100644
index 00000000..1b3bbbe1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_d1_c1_f0.yml
@@ -0,0 +1,49 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new linked clone without specifying snapshot_src
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ template: "{{ virtual_machines[0].name }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ linked_clone: true
+ register: linked_clone_d1_c1_f0
+ ignore_errors: true
+
+- debug:
+ var: linked_clone_d1_c1_f0
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - not (linked_clone_d1_c1_f0 is changed)
+
+- name: create new linked clone without specifying linked_clone
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ template: "{{ virtual_machines[0].name }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ snapshot_src: "snap_shot1"
+ register: linked_clone_d1_c1_f0
+ ignore_errors: true
+
+- debug:
+ var: linked_clone_d1_c1_f0
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - not (linked_clone_d1_c1_f0 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_resize_disks.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_resize_disks.yml
new file mode 100644
index 00000000..6f2b4c18
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_resize_disks.yml
@@ -0,0 +1,75 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Noe Gonzalez <noe.a.gonzalez@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: clone_resize_disks_original
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ folder: "{{ f0 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+
+- name: convert to VM template
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: clone_resize_disks_original
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ folder: "{{ f0 }}"
+ is_template: true
+
+- name: clone template and modify disks
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: clone_resize_disks_clone
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ folder: "{{ f0 }}"
+ disk:
+ - size_gb: 2
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ - size_gb: 3
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ template: clone_resize_disks_original
+ state: poweredoff
+ register: l_clone_template_modify_disks
+
+- assert:
+ that:
+ - l_clone_template_modify_disks.changed | bool
+
+- name: delete VM clone & original template
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ item }}"
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ folder: "{{ f0 }}"
+ state: absent
+ with_items:
+ - clone_resize_disks_original
+ - clone_resize_disks_clone
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml
new file mode 100644
index 00000000..50063016
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml
@@ -0,0 +1,88 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Christophe FERREIRA <christophe.ferreira@cnaf.fr>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create VMs
+ vmware_guest:
+ datacenter: "{{ dc1 }}"
+ folder: '{{ f0 }}'
+ name: DC0_H0_VM0
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_mb: 10
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ version: 11
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- name: clone vm from template and convert to thin
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ template: DC0_H0_VM0
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ convert: thin
+ register: clone_thin
+
+- debug: var=clone_thin
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_thin is changed
+
+- name: clone vm from template and convert to thick
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ template: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ virtual_machines[0].folder }}"
+ convert: thick
+ register: clone_thick
+
+- debug: var=clone_thick
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_thick is changed
+
+- name: clone vm from template and convert to eagerzeroedthick
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm3
+ template: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ virtual_machines[0].folder }}"
+ convert: eagerzeroedthick
+ register: clone_eagerzeroedthick
+
+- debug: var=clone_eagerzeroedthick
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_eagerzeroedthick is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml
new file mode 100644
index 00000000..b2421ab3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml
@@ -0,0 +1,162 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ num_cpu_cores_per_socket: 1
+ memory_mb: 128
+ hotadd_memory: true
+ hotadd_cpu: false
+ memory_reservation: 128
+ memory_reservation_lock: false
+ nested_virt: true
+ hotremove_cpu: true
+ mem_limit: 8096
+ mem_reservation: 4096
+ cpu_limit: 8096
+ cpu_reservation: 4096
+ max_connections: 10
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0
+
+- debug: var=clone_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_d1_c1_f0 is changed
+
+- name: create the VM again
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ num_cpu_cores_per_socket: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0_recreate
+
+- debug: var=clone_d1_c1_f0_recreate
+
+- name: assert that no changes were made after re-creating
+ assert:
+ that:
+ - not (clone_d1_c1_f0_recreate is changed)
+
+- name: modify the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 2
+ memory_mb: 128
+ state: present
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0_modify
+
+- debug: var=clone_d1_c1_f0_modify
+
+- name: assert that changes were made with modification
+ assert:
+ that:
+ - clone_d1_c1_f0_modify is changed
+
+- name: re-modify the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 2
+ memory_mb: 128
+ state: present
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0_remodify
+
+- debug: var=clone_d1_c1_f0_remodify
+
+- name: assert that no changes were made when re-modified
+ assert:
+ that:
+ - not (clone_d1_c1_f0_remodify is changed)
+
+- name: delete the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ #guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ state: absent
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0_delete
+
+- debug: var=clone_d1_c1_f0_delete
+
+- name: assert that changes were made with deletion
+ assert:
+ that:
+ - clone_d1_c1_f0_delete is changed
+
+- name: re-delete the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ #guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ state: absent
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0_redelete
+
+- debug: var=clone_d1_c1_f0_redelete
+
+- name: assert that no changes were made with redeletion
+ assert:
+ that:
+ - not (clone_d1_c1_f0_redelete is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_guest_invalid_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_guest_invalid_d1_c1_f0.yml
new file mode 100644
index 00000000..a3ebdb0b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_guest_invalid_d1_c1_f0.yml
@@ -0,0 +1,30 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new virtual machine with invalid guest id
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: invalid_vm
+ guest_id: "invalid_guest_id"
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ f0 }}"
+ register: invalid_guest_0001_d1_c1_f0
+ ignore_errors: true
+- debug: var=invalid_guest_0001_d1_c1_f0
+- name: assert that changes were made
+ assert:
+ that:
+ - "not (invalid_guest_0001_d1_c1_f0 is changed)"
+ - "'configSpec.guestId' in invalid_guest_0001_d1_c1_f0['msg']"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_nw_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_nw_d1_c1_f0.yml
new file mode 100644
index 00000000..dffd8d31
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_nw_d1_c1_f0.yml
@@ -0,0 +1,38 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: 'VM Network'
+ device_type: vmxnet3
+ ip: 192.168.10.1
+ netmask: 255.255.255.0
+ wake_on_lan: true
+ start_connected: true
+ allow_guest_control: true
+ state: poweredoff
+ folder: F0
+ register: clone_d1_c1_f0
+
+- debug: var=clone_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_d1_c1_f0 is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_rp_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_rp_d1_c1_f0.yml
new file mode 100644
index 00000000..ab2992d5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_rp_d1_c1_f0.yml
@@ -0,0 +1,208 @@
+# Create one with the defaults
+- name: create new VM with default resource pool
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ version: 11
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: F0
+ register: clone_rp_d1_c1_f0
+
+- debug: var=clone_rp_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_rp_d1_c1_f0 is changed
+
+- name: delete the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ #guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ state: absent
+ folder: F0
+ register: clone_rp_d1_c1_f0_delete
+
+- debug: var=clone_rp_d1_c1_f0_delete
+
+- name: assert that changes were made with deletion
+ assert:
+ that:
+ - clone_rp_d1_c1_f0_delete is changed
+
+# now create with just a cluster
+- name: create new VM with default resource pool in cluster
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ hardware:
+ version: 11
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: F0
+ register: clone_rpc_d1_c1_f0
+
+- debug: var=clone_rpc_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_rpc_d1_c1_f0 is changed
+
+- name: delete the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ #guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ state: absent
+ folder: F0
+ register: clone_rpc_d1_c1_f0_delete
+
+- debug: var=clone_rpc_d1_c1_f0_delete
+
+- name: assert that changes were made with deletion
+ assert:
+ that:
+ - clone_rpc_d1_c1_f0_delete is changed
+
+# now create with a specific resource pool
+- name: create new VM with specific resource pool in cluster
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: DC0_C0_RP1
+ hardware:
+ version: 11
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: F0
+ register: clone_rpcp_d1_c1_f0
+
+- debug: var=clone_rpcp_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_rpcp_d1_c1_f0 is changed
+
+- name: delete the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ #guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ state: absent
+ folder: F0
+ register: clone_rpcp_d1_c1_f0_delete
+
+- debug: var=clone_rpcp_d1_c1_f0_delete
+
+- name: assert that changes were made with deletion
+ assert:
+ that:
+ - clone_rpcp_d1_c1_f0_delete is changed
+
+# now create with a specific host
+- name: create new VM with specific host
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: F0
+ register: clone_rph_d1_c1_f0
+
+- debug: var=clone_rph_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - clone_rph_d1_c1_f0 is changed
+
+- name: delete the new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ #template: "{{ item|basename }}"
+ #guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ state: absent
+ folder: F0
+ register: clone_rph_d1_c1_f0_delete
+
+- debug: var=clone_rph_d1_c1_f0_delete
+
+- name: assert that changes were made with deletion
+ assert:
+ that:
+ - clone_rph_d1_c1_f0_delete is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_vm_using_special_characters.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_vm_using_special_characters.yml
new file mode 100644
index 00000000..acbe3186
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/create_vm_using_special_characters.yml
@@ -0,0 +1,82 @@
+---
+- name: Create VM with special characters
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ name: 'test_vm\/%'
+ guest_id: debian8_64Guest
+ hardware:
+ memory_mb: 512
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ register: create_vm_with_special_characters_result
+
+- assert:
+ that:
+ - create_vm_with_special_characters_result.changed is sameas true
+
+- name: Create VM with special characters(idempotency check)
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ name: 'test_vm\/%'
+ guest_id: debian8_64Guest
+ hardware:
+ memory_mb: 512
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ register: create_vm_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - create_vm_with_special_characters_idempotency_check_result.changed is sameas false
+
+- name: Delete VM with special characters
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ name: 'test_vm\/%'
+ state: absent
+ register: delete_vm_with_special_characters_result
+
+- assert:
+ that:
+ - delete_vm_with_special_characters_result.changed is sameas true
+
+- name: Delete VM with special characters(idempotency check)
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ name: 'test_vm\/%'
+ state: absent
+ register: delete_vm_with_special_characters_idempotency_check_result
+
+- assert:
+ that:
+ - delete_vm_with_special_characters_idempotency_check_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/delete_vm.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/delete_vm.yml
new file mode 100644
index 00000000..c7944f8b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/delete_vm.yml
@@ -0,0 +1,82 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Delete VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: nothinghere
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_vm
+ ignore_errors: true
+
+- debug: var=delete_vm
+
+- name: assert that changes were made
+ assert:
+ that:
+ - "not delete_vm.changed"
+
+- name: create new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_delete_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ num_cpu_cores_per_socket: 1
+ memory_mb: 128
+ hotadd_memory: true
+ hotadd_cpu: false
+ max_connections: 10
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: '{{ f0 }}'
+ register: clone_d1_c1_f0
+
+- name: Delete VM using different datacenter and folder
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_delete_vm
+ datacenter: "{{ dc1 }}-fake"
+ folder: '{{ f0 }}-fake'
+ state: absent
+ register: delete_vm
+ ignore_errors: true
+
+- name: assert that VM was not deleted
+ assert:
+ that:
+ - not delete_vm.changed
+
+- name: Delete VM using right parameters value
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_delete_vm
+ datacenter: "{{ dc1 }}"
+ folder: '{{ f0 }}'
+ state: absent
+ register: delete_vm
+ ignore_errors: true
+
+- name: assert that VM was deleted
+ assert:
+ that:
+ - delete_vm.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml
new file mode 100644
index 00000000..83da8880
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_mode_d1_c1_f0.yml
@@ -0,0 +1,86 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs with invalid disk mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ disk_mode: 'invalid_disk_mode'
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: test_vm1
+ ignore_errors: true
+
+- debug: var=test_vm1
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - not(test_vm1 is changed)
+
+- name: create new VMs with valid disk mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ disk_mode: 'independent_persistent'
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: test_vm1_2
+
+- debug: var=test_vm1_2
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_vm1_2 is changed
+
+- name: create new VMs with valid disk mode again
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ disk_mode: 'independent_persistent'
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: test_vm1_2
+- debug: var=test_vm1_2
+- name: assert that changes were not made
+ assert:
+ that:
+ - not (test_vm1_2 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_size_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_size_d1_c1_f0.yml
new file mode 100644
index 00000000..f3edea97
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_size_d1_c1_f0.yml
@@ -0,0 +1,31 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs with invalid disk size
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 0gb
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: disk_size_d1_c1_f0
+ ignore_errors: true
+
+- debug: var=disk_size_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - not (disk_size_d1_c1_f0 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_type_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_type_d1_c1_f0.yml
new file mode 100644
index 00000000..a84c61a9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/disk_type_d1_c1_f0.yml
@@ -0,0 +1,33 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: poweredoff
+ folder: F0
+ register: disk_type_d1_c1_f0
+
+- debug: var=disk_type_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - disk_type_d1_c1_f0 is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mac_address_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mac_address_d1_c1_f0.yml
new file mode 100644
index 00000000..a41059cb
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mac_address_d1_c1_f0.yml
@@ -0,0 +1,37 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create new VMs with manual MAC address
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: VM Network
+ ip: 192.168.10.12
+ netmask: 255.255.255.0
+ gateway: 192.168.10.254
+ mac: aa:bb:cc:dd:aa:42
+ state: poweredoff
+ folder: vm
+ register: clone_d1_c1_f0
+
+- debug: var=clone_d1_c1_f0
+
+- name: assert that changes were made
+ assert:
+ that:
+ - "clone_d1_c1_f0['instance']['hw_eth0']['addresstype'] == 'manual'"
+ - "clone_d1_c1_f0['instance']['hw_eth0']['macaddress'] == 'aa:bb:cc:dd:aa:42'"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/main.yml
new file mode 100644
index 00000000..67e4df30
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/main.yml
@@ -0,0 +1,18 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datacenter: true
+ setup_datastore: true
+ setup_dvswitch: true
+ setup_resource_pool: true
+ setup_dvs_portgroup: true
+
+- include_tasks: run_test_playbook.yml
+ with_items: '{{ vmware_guest_test_playbooks }}'
+ loop_control:
+ loop_var: test_playbook
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/max_connections.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/max_connections.yml
new file mode 100644
index 00000000..c46040ff
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/max_connections.yml
@@ -0,0 +1,43 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &add_mk_conn
+ name: Create new VM with max_connections as 4
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ max_connections: 4
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ f0 }}"
+ register: mk_conn_result_0001
+
+- debug: var=mk_conn_result_0001
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - mk_conn_result_0001 is changed
+
+- <<: *add_mk_conn
+ name: Again create new VMs again with max_connections as 4
+ register: mk_conn_result_0002
+
+- debug: var=mk_conn_result_0002
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (mk_conn_result_0002 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mem_reservation.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mem_reservation.yml
new file mode 100644
index 00000000..f23b2de3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/mem_reservation.yml
@@ -0,0 +1,123 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &add_mem_reserve
+ name: Create new VMs with mem_reservation as 0
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ mem_reservation: 0
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ virtual_machines[0].folder }}"
+ register: mem_reserve_result_0001
+
+- debug: var=mem_reserve_result_0001
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - mem_reserve_result_0001 is changed
+
+- <<: *add_mem_reserve
+ name: Again create new VMs with mem_reservation as 0
+ register: mem_reserve_result_0002
+
+- debug: var=mem_reserve_result_0002
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (mem_reserve_result_0002 is changed)
+
+- &add_memory_reserve
+ name: Create new VM with memory_reservation as 0
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ memory_reservation: 0
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ virtual_machines[0].folder }}"
+ register: memory_reserve_result_0003
+
+- debug: var=memory_reserve_result_0003
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - memory_reserve_result_0003 is changed
+
+- <<: *add_memory_reserve
+ name: Again create new VMs with memory_reservation as 0
+ register: memory_reserve_result_0004
+
+- debug: var=memory_reserve_result_0004
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (memory_reserve_result_0004 is changed)
+
+- &no_memory_reserve
+ name: Create new VMs without memory_reservation or mem_reservation
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm3
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ memory_reservation: 0
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ virtual_machines[0].folder }}"
+ register: no_memory_reserve_result_0005
+
+- debug: var=no_memory_reserve_result_0005
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - no_memory_reserve_result_0005 is changed
+
+- <<: *no_memory_reserve
+ name: Again create new VMs without memory_reservation or mem_reservation
+ register: no_memory_reserve_result_0006
+
+- debug: var=no_memory_reserve_result_0006
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (no_memory_reserve_result_0006 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/multiple_disk_controllers_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/multiple_disk_controllers_d1_c1_f0.yml
new file mode 100644
index 00000000..1c783e4a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/multiple_disk_controllers_d1_c1_f0.yml
@@ -0,0 +1,216 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2020, Diane Wang <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- name: create a new VM with multiple scsi controllers
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ folder: vm
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ name: test_vm1
+ guest_id: centos64Guest
+ datastore: "{{ rw_datastore }}"
+ hardware:
+ memory_mb: 512
+ num_cpus: 1
+ disk:
+ - controller_type: lsilogicsas
+ controller_number: 0
+ unit_number: 0
+ size_mb: 512
+ type: thin
+ - controller_type: paravirtual
+ controller_number: 1
+ unit_number: 0
+ size_mb: 256
+ type: eagerzeroedthick
+ register: multi_scsi_disk_vm
+
+- debug: var=multi_scsi_disk_vm
+
+- name: assert that VM was deployed
+ assert:
+ that:
+ - "multi_scsi_disk_vm.changed == true"
+
+- name: reconfigure created VM with multiple scsi controllers
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ folder: vm
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ name: test_vm1
+ datastore: "{{ rw_datastore }}"
+ state: present
+ disk:
+ - controller_type: lsilogicsas
+ controller_number: 0
+ unit_number: 0
+ size_mb: 512
+ disk_mode: independent_persistent
+ - controller_type: paravirtual
+ controller_number: 1
+ unit_number: 0
+ size_mb: 512
+ register: multi_scsi_disk_vm
+
+- debug: var=multi_scsi_disk_vm
+
+- name: assert that VM was configured
+ assert:
+ that:
+ - "multi_scsi_disk_vm.changed == true"
+
+- name: create a new VM with multiple sata controllers
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ name: test_vm2
+ guest_id: centos64Guest
+ datastore: "{{ rw_datastore }}"
+ hardware:
+ memory_mb: 512
+ num_cpus: 1
+ disk:
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ size_mb: 512
+ disk_mode: independent_persistent
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 0
+ size_mb: 256
+ - controller_type: sata
+ controller_number: 2
+ unit_number: 0
+ size_mb: 256
+ register: multi_sata_disk_vm
+
+- debug: var=multi_sata_disk_vm
+
+- name: assert that VM was deployed
+ assert:
+ that:
+ - "multi_sata_disk_vm.changed == true"
+
+- name: reconfigure created new VM with multiple sata controllers
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ name: test_vm2
+ state: present
+ datastore: "{{ rw_datastore }}"
+ disk:
+ - controller_type: sata
+ controller_number: 0
+ unit_number: 0
+ size_mb: 512
+ disk_mode: persistent
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 0
+ size_mb: 512
+ register: multi_sata_disk_vm
+
+- debug: var=multi_sata_disk_vm
+
+- name: assert that VM was deployed
+ assert:
+ that:
+ - "multi_sata_disk_vm.changed == true"
+
+- name: create a new VM with multiple nvme controllers
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ name: test_vm3
+ guest_id: centos64Guest
+ datastore: "{{ rw_datastore }}"
+ hardware:
+ memory_mb: 512
+ num_cpus: 1
+ version: 14
+ disk:
+ - controller_type: nvme
+ controller_number: 0
+ unit_number: 0
+ size_mb: 512
+ - controller_type: nvme
+ controller_number: 1
+ unit_number: 0
+ size_mb: 256
+ type: thin
+ - controller_type: nvme
+ controller_number: 2
+ unit_number: 0
+ size_mb: 256
+ register: multi_nvme_disk_vm
+
+- debug: var=multi_nvme_disk_vm
+
+- name: assert that VM was deployed
+ assert:
+ that:
+ - "multi_nvme_disk_vm.changed == true"
+
+- name: reconfigure created new VM with multiple types of controllers
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: vm
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ name: test_vm3
+ state: present
+ datastore: "{{ rw_datastore }}"
+ disk:
+ - controller_type: nvme
+ controller_number: 0
+ unit_number: 1
+ size_mb: 512
+ - controller_type: sata
+ controller_number: 1
+ unit_number: 0
+ size_mb: 256
+ - controller_type: paravirtual
+ controller_number: 0
+ unit_number: 0
+ size_mb: 256
+ register: multi_nvme_disk_vm
+
+- debug: var=multi_nvme_disk_vm
+
+- name: assert that VM was deployed
+ assert:
+ that:
+ - "multi_nvme_disk_vm.changed == true"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_negative_test.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_negative_test.yml
new file mode 100644
index 00000000..99b9bcbe
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_negative_test.yml
@@ -0,0 +1,339 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- debug: var=f0
+
+- name: create new VMs with non-existent network
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "Non existent VM"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: non_existent_network
+ ignore_errors: true
+
+- debug: var=non_existent_network
+
+- name: assert that no changes were not made
+ assert:
+ that:
+ - not (non_existent_network is changed)
+ - "'does not exist' in non_existent_network.msg"
+
+- name: create new VMs with network and with only IP
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ type: static
+ ip: 10.10.10.10
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: no_netmask
+ ignore_errors: true
+
+- debug: var=no_netmask
+
+- name: assert that no changes were not made
+ assert:
+ that:
+ - "not no_netmask.changed"
+ - "\"'netmask' is required if 'ip' is specified under VM network list.\" in no_netmask.msg"
+
+- name: create new VMs with network and with only netmask
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ type: static
+ netmask: 255.255.255.0
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: no_ip
+ ignore_errors: true
+
+- debug: var=no_ip
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - "not no_ip.changed"
+ - "\"'ip' is required if 'netmask' is specified under VM network list.\" in no_ip.msg"
+
+- name: create new VMs with network and without network name
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - ip: 10.10.10.10
+ netmask: 255.255.255
+ type: static
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: no_network_name
+ ignore_errors: true
+
+- debug: var=no_network_name
+
+- name: assert that no changes were not made
+ assert:
+ that:
+ - "not no_network_name.changed"
+ - "\"Please specify at least a network name or a VLAN name under VM network list.\" in no_network_name.msg"
+
+- name: create new VMs with network and without network name
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - vlan: non_existing_vlan
+ ip: 10.10.10.10
+ netmask: 255.255.255
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: no_network
+ ignore_errors: true
+
+- debug: var=no_network
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - "not no_network.changed"
+ - "\"VLAN 'non_existing_vlan' does not exist.\" in no_network.msg"
+
+- name: create new VMs with invalid device type
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ ip: 10.10.10.10
+ netmask: 255.255.255
+ device_type: abc
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: invalid_device_type
+ ignore_errors: true
+
+- debug: var=invalid_device_type
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - "not invalid_device_type.changed"
+ - "\"Device type specified 'abc' is not valid.\" in invalid_device_type.msg"
+
+- name: create new VMs with invalid device MAC address
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ ip: 10.10.10.10
+ netmask: 255.255.255
+ device_type: e1000
+ mac: abcdef
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: invalid_mac
+ ignore_errors: true
+
+- debug: var=invalid_mac
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - "not invalid_mac.changed"
+ - "\"Device MAC address 'abcdef' is invalid.\" in invalid_mac.msg"
+
+- name: create new VMs with invalid network type
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ ip: 10.10.10.10
+ netmask: 255.255.255
+ device_type: e1000
+ mac: 01:23:45:67:89:ab
+ type: aaaaa
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: invalid_network_type
+ ignore_errors: true
+
+- debug: var=invalid_network_type
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - "not invalid_network_type.changed"
+ - "\"Network type 'aaaaa' is not a valid parameter.\" in invalid_network_type.msg"
+
+- name: create new VMs with IP, netmask and network type as "DHCP"
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: new_vm
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ ip: 10.10.10.10
+ netmask: 255.255.255
+ device_type: e1000
+ mac: 01:23:45:67:89:ab
+ type: dhcp
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: invalid_dhcp_network_type
+ ignore_errors: true
+
+- debug: var=invalid_dhcp_network_type
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - "not invalid_dhcp_network_type.changed"
+ - "\"Static IP information provided for network\" in invalid_dhcp_network_type.msg"
+
+- name: create new VMs with no network type which set network type as "DHCP"
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ disk:
+ - size: 3mb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ networks:
+ - name: "VM Network"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ state: poweredoff
+ folder: "{{ f0 }}"
+ register: no_network_type
+ ignore_errors: true
+
+- debug: var=no_network_type
+
+- name: assert that changes were made
+ assert:
+ that:
+ - "no_network_type.changed"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_with_device.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_with_device.yml
new file mode 100644
index 00000000..307fd1fa
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/network_with_device.yml
@@ -0,0 +1,62 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Testcase to check #38605
+- name: Deploy VM first VM
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ name: test_vm1
+ disk:
+ - size: 10mb
+ datastore: "{{ rw_datastore }}"
+ guest_id: debian8_64Guest
+ hardware:
+ version: 11
+ memory_mb: 128
+ num_cpus: 1
+ networks:
+ - name: 'VM Network'
+ device_type: "vmxnet3"
+ register: vm_result
+
+- debug: var=vm_result
+
+- assert:
+ that:
+ - "vm_result.changed"
+
+- name: Deploy VM again
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ state: poweredoff
+ folder: "{{ f0 }}"
+ name: test_vm1
+ disk:
+ - size: 10mb
+ datastore: "{{ rw_datastore }}"
+ guest_id: debian8_64Guest
+ hardware:
+ version: 11
+ memory_mb: 128
+ num_cpus: 1
+ networks:
+ - name: 'VM Network'
+ device_type: "vmxnet3"
+ register: vm_result_again
+
+- debug: var=vm_result_again
+
+- assert:
+ that:
+ - not (vm_result_again is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/non_existent_vm_ops.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/non_existent_vm_ops.yml
new file mode 100644
index 00000000..fc0c466e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/non_existent_vm_ops.yml
@@ -0,0 +1,23 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Perform operation on non-existent VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "non_existent_vm"
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ state: poweredoff
+ register: non_existent_vm_ops
+ ignore_errors: true
+- debug: var=non_existent_vm_ops
+- name: assert that changes were not made
+ assert:
+ that:
+ - not (non_existent_vm_ops is changed)
+ - "'msg' in non_existent_vm_ops"
+ - "'Unable to find the datastore with given parameters.' in non_existent_vm_ops.msg"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/reconfig_vm_to_latest_version.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/reconfig_vm_to_latest_version.yml
new file mode 100644
index 00000000..a3acc6d1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/reconfig_vm_to_latest_version.yml
@@ -0,0 +1,97 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+# Skipping out idepotency test untill issue fixed in reconfigure_vm() become_method
+
+- name: Create VM with hardware version 12
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: debian8_64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ num_cpus: 1
+ memory_mb: 1028
+ version: 12
+ state: present
+ register: create_vm_with_version_12
+
+- name: assert that changes were made
+ assert:
+ that:
+ - create_vm_with_version_12 is changed
+
+- name: Deploy New VM with latest hardware version
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ guest_id: debian8_64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ num_cpus: 1
+ memory_mb: 1028
+ version: latest
+ state: present
+ register: deploy_vm_to_latest
+
+- name: assert that changes were made
+ assert:
+ that:
+ - deploy_vm_to_latest is changed
+
+- name: Upgrade VM to latest version in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: debian8_64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ num_cpus: 1
+ memory_mb: 1028
+ version: latest
+ state: present
+ register: upgrade_vm
+ check_mode: true
+
+- name: assert that changes would be made
+ assert:
+ that:
+ - upgrade_vm is changed
+
+- name: Upgrade VM to latest version
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: debian8_64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ num_cpus: 1
+ memory_mb: 1028
+ version: latest
+ state: present
+ register: upgrade_vm
+
+- name: assert that changes were made
+ assert:
+ that:
+ - upgrade_vm is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/remove_vm_from_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/remove_vm_from_inventory.yml
new file mode 100644
index 00000000..2dcc6782
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/remove_vm_from_inventory.yml
@@ -0,0 +1,61 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create VM to unregister
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ folder: F0
+ hardware:
+ num_cpus: 1
+ num_cpu_cores_per_socket: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ register: create_vm_for_test
+
+- name: assert that changes were made
+ assert:
+ that:
+ - create_vm_for_test is changed
+
+- name: Remove VM from Inventory
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ delete_from_inventory: true
+ state: absent
+ register: remove_vm_from_inventory
+
+- name: assert that changes were made
+ assert:
+ that:
+ - remove_vm_from_inventory is changed
+
+- name: Remove VM again from Inventory
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ delete_from_inventory: true
+ state: absent
+ register: remove_again_vm_from_inventory
+
+- name: assert that changes were made
+ assert:
+ that:
+ - not (remove_again_vm_from_inventory is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/run_test_playbook.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/run_test_playbook.yml
new file mode 100644
index 00000000..07f9230e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/run_test_playbook.yml
@@ -0,0 +1,32 @@
+- block:
+ - include_tasks: '{{ test_playbook }}'
+ always:
+ - name: Collect the list of the existing VM
+ vmware.vmware_rest.vcenter_vm_info:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ register: existing_vms
+ until: existing_vms is not failed
+ - name: Turn off the VM
+ vmware.vmware_rest.vcenter_vm_power:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ state: stop
+ vm: '{{ item.vm }}'
+ with_items: "{{ existing_vms.value }}"
+ ignore_errors: true
+ - name: Clean up VM
+ vmware.vmware_rest.vcenter_vm:
+ vcenter_hostname: '{{ vcenter_hostname }}'
+ vcenter_username: '{{ vcenter_username }}'
+ vcenter_password: '{{ vcenter_password }}'
+ vcenter_validate_certs: false
+ state: absent
+ vm: '{{ item.vm }}'
+ with_items: "{{ existing_vms.value }}"
+ when:
+ - not item.name.startswith("vCLS")
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/shares.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/shares.yml
new file mode 100644
index 00000000..ff756443
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/shares.yml
@@ -0,0 +1,122 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &add_cpu_shares
+ name: Create new VMs with cpu shares level set to High
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ cpu_shares_level: high
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ virtual_machines[0].folder }}"
+ register: cpu_shares_level_result_0001
+
+- debug: var=cpu_shares_level_result_0001
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - cpu_shares_level_result_0001 is changed
+
+- <<: *add_cpu_shares
+ name: Again create new VMs with CPU shares level set to High
+ register: cpu_shares_level_result_0002
+
+- debug: var=cpu_shares_level_result_0002
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (cpu_shares_level_result_0002 is changed)
+
+- &add_mem_shares
+ name: Create new VM with memory shares level set to High
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ mem_shares_level: high
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ virtual_machines[0].folder }}"
+ register: mem_shares_level_results_0003
+
+- debug: var=mem_shares_level_results_0003
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - mem_shares_level_results_0003 is changed
+
+- <<: *add_mem_shares
+ name: Again create new VMs with memory shares level set to High
+ register: mem_shares_level_results_0004
+
+- debug: var=mem_shares_level_results_0004
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (mem_shares_level_results_0004 is changed)
+
+- &no_shares_levels
+ name: Create new VMs without CPU or Memory Shares level set
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm3
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 128
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ folder: "{{ virtual_machines[0].folder }}"
+ register: no_shares_levels_results_0005
+
+- debug: var=no_shares_levels_results_0005
+
+- name: Assert that changes were made
+ assert:
+ that:
+ - no_shares_levels_results_0005 is changed
+
+- <<: *no_shares_levels
+ name: Again create new VMs without memory_reservation or mem_reservation
+ register: no_shares_levels_result_0006
+
+- debug: var=no_shares_levels_result_0006
+
+- name: Assert that changes were not made
+ assert:
+ that:
+ - not (no_shares_levels_result_0006 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/vapp_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/vapp_d1_c1_f0.yml
new file mode 100644
index 00000000..05b3950f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/vapp_d1_c1_f0.yml
@@ -0,0 +1,96 @@
+# Test code for the vmware_guest module.
+# Copyright: (c) 2018, goshkis
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &vapp_new_vm
+ name: Create test VM with vAPP settings
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "vm"
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: centos64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ vapp_properties:
+ - id: prop_id1
+ category: category
+ label: prop_label1
+ type: string
+ value: prop_value1
+ - id: prop_id2
+ category: category
+ label: prop_label2
+ type: string
+ value: prop_value2
+ register: vapp_vm
+
+- debug: var=vapp_vm
+
+- name: assert the vApp propeties were created
+ assert:
+ that:
+ - "vapp_vm.failed == false"
+ - "vapp_vm.changed == true"
+
+- <<: *vapp_new_vm
+ name: Try to create same VM with same vAPP settings
+ register: vapp_vm_no_change
+
+- debug: var=vapp_vm_no_change
+
+- name: Assert that vApp properties were not changed
+ assert:
+ that:
+ - "vapp_vm_no_change.failed == false"
+ - "not vapp_vm_no_change.changed"
+
+- &vapp_edit_vm
+ name: Edit one vApp property and removing another
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "vm"
+ name: test_vm1
+ datacenter: "{{ dc1 }}"
+ vapp_properties:
+ - id: prop_id1
+ operation: remove
+ - id: prop_id2
+ value: prop_value3
+ state: present
+ register: vapp_vm
+
+- debug: var=vapp_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "vapp_vm.failed == false"
+ - "vapp_vm.changed == true"
+
+- <<: *vapp_edit_vm
+ name: Try to edit VM with vApp settings
+ register: vapp_vm_no_change_edit
+
+- debug: var=vapp_vm_no_change_edit
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - "vapp_vm_no_change_edit.failed == false"
+ - "vapp_vm_no_change_edit.changed == false"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml
new file mode 100644
index 00000000..cd151620
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml
@@ -0,0 +1,119 @@
+- name: Create Windows 10 VM with VBS enabled
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ f0 }}"
+ name: vbs-Test
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: windows9_64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ virt_based_security: true
+ version: 14
+ boot_firmware: efi
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ cdrom:
+ type: client
+ register: vbs_vm
+
+- debug: var=vbs_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "vbs_vm.failed == false"
+ - "vbs_vm.changed == true"
+
+- name: Create Windows Server 2016 VM without VBS enabled
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ f0 }}"
+ name: vbs-Test2
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ resource_pool: Resources
+ guest_id: windows9Server64Guest
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ version: 14
+ boot_firmware: efi
+ scsi: paravirtual
+ disk:
+ - size_mb: 128
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ cdrom:
+ type: client
+ register: vbs_vm
+
+- debug: var=vbs_vm
+
+- name: assert the VM was created
+ assert:
+ that:
+ - "vbs_vm.failed == false"
+ - "vbs_vm.changed == true"
+
+- name: Enable VBS for Windows Server 2016 VM in check mode
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ f0 }}"
+ name: vbs-Test2
+ datacenter: "{{ f0 }}"
+ disk:
+ - size_mb: 256
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ virt_based_security: true
+ state: present
+ register: vbs_vm
+ check_mode: true
+
+- debug: var=vbs_vm
+
+- name: assert the VM would be changed
+ assert:
+ that:
+ - vbs_vm is changed
+
+- name: Enable VBS for Windows Server 2016 VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ folder: "{{ f0 }}"
+ name: vbs-Test2
+ datacenter: "{{ f0 }}"
+ disk:
+ - size_mb: 256
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ virt_based_security: true
+ state: present
+ register: vbs_vm
+
+- debug: var=vbs_vm
+
+- name: assert the VM was changed
+ assert:
+ that:
+ - vbs_vm is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/tasks/main.yml
new file mode 100644
index 00000000..85152475
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_info/tasks/main.yml
@@ -0,0 +1,49 @@
+# Test code for the vmware_guest_boot_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Gather info about VM boot order
+ vmware_guest_boot_info:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ register: vm1_info
+- debug: var=vm1_info
+- name: assert that values are set
+ assert:
+ that:
+ - vm1_info.vm_boot_info.current_boot_delay is defined
+ - vm1_info.vm_boot_info.current_boot_firmware is defined
+ - vm1_info.vm_boot_info.current_boot_order is defined
+ - vm1_info.vm_boot_info.current_boot_retry_delay is defined
+ - vm1_info.vm_boot_info.current_boot_retry_enabled is defined
+ - vm1_info.vm_boot_info.current_enter_bios_setup is defined
+
+- name: Gather info about VM boot order in check mode
+ vmware_guest_boot_info:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ check_mode: true
+ register: vm1_info
+- debug: var=vm1_info
+- name: assert that values are set
+ assert:
+ that:
+ - vm1_info.vm_boot_info.current_boot_delay is defined
+ - vm1_info.vm_boot_info.current_boot_firmware is defined
+ - vm1_info.vm_boot_info.current_boot_order is defined
+ - vm1_info.vm_boot_info.current_boot_retry_delay is defined
+ - vm1_info.vm_boot_info.current_boot_retry_enabled is defined
+ - vm1_info.vm_boot_info.current_enter_bios_setup is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/tasks/main.yml
new file mode 100644
index 00000000..5b7dac53
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_boot_manager/tasks/main.yml
@@ -0,0 +1,190 @@
+# Test code for the vmware_guest_boot_manager module.
+# Copyright: (c) 2022, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Enable Secure Boot
+ community.vmware.vmware_guest_boot_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ boot_firmware: efi
+ secure_boot_enabled: true
+ register: enable_secure_boot
+
+- ansible.builtin.debug: var=enable_secure_boot
+
+- name: Get VM boot info 1
+ community.vmware.vmware_guest_boot_info:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ register: boot_info1
+
+- ansible.builtin.debug: var=boot_info1
+
+- name: assert that Secure Boot is enabled
+ assert:
+ that:
+ - enable_secure_boot.changed
+ - boot_info1.vm_boot_info.current_secure_boot_enabled is true
+
+- name: Issue https://github.com/ansible-collections/community.vmware/issues/1257
+ block:
+ - name: Enter BIOS setup
+ community.vmware.vmware_guest_boot_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ enter_bios_setup: true
+ register: enter_bios_setup
+
+ - ansible.builtin.debug: var=enter_bios_setup
+
+ - name: Get VM boot info 2
+ community.vmware.vmware_guest_boot_info:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ register: boot_info2
+
+ - ansible.builtin.debug: var=boot_info2
+
+ - name: assert that configuration is changed
+ assert:
+ that:
+ - enter_bios_setup.changed
+ - boot_info2.vm_boot_info.current_enter_bios_setup is true
+
+ - name: assert that Secure Boot is still enabled
+ assert:
+ that:
+ - boot_info2.vm_boot_info.current_secure_boot_enabled is true
+
+- name: Get VM disk info 1
+ community.vmware.vmware_guest_disk_info:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ register: disk_info1
+
+- ansible.builtin.debug: var=disk_info1
+
+- name: Add a new disk for boot disk config test
+ block:
+ - name: Add a new disk to VM
+ community.vmware.vmware_guest_disk:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ disk:
+ - size_mb: 10
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ controller_number: "{{ disk_info1.guest_disk_info['0'].controller_bus_number }}"
+ unit_number: "{{ disk_info1.guest_disk_info['0'].unit_number | int + 1 }}"
+ controller_type: "{{ disk_info1.guest_disk_info['0'].controller_type }}"
+ register: add_disk_result
+
+ - ansible.builtin.debug: var=add_disk_result
+
+ - name: assert that new disk is added
+ assert:
+ that:
+ - add_disk_result.changed
+ - add_disk_result.disk_data | length == 2
+ when:
+ - disk_info1 is defined
+ - disk_info1.guest_disk_info is defined
+ - disk_info1.guest_disk_info | length == 1
+
+- name: Get VM disk info 2
+ community.vmware.vmware_guest_disk_info:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ register: disk_info2
+
+- ansible.builtin.debug: var=disk_info2
+
+- name: Get disk with label 'Hard disk 2'
+ ansible.builtin.set_fact:
+ get_hard_disk_2: "{{ item }}"
+ when: item.value.label == 'Hard disk 2'
+ with_dict: "{{ disk_info2.guest_disk_info }}"
+
+- name: assert that 'Hard disk 2' found in disk info
+ assert:
+ that:
+ - get_hard_disk_2 is defined
+
+- ansible.builtin.debug: var=get_hard_disk_2
+
+- name: Set boot disk to 'Hard disk 2'
+ community.vmware.vmware_guest_boot_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ boot_order:
+ - disk
+ - cdrom
+ - ethernet
+ boot_hdd_name: 'Hard disk 2'
+ register: set_boot_hdd_result1
+
+- ansible.builtin.debug: var=set_boot_hdd_result1
+
+- name: assert that boot disk is set to 'Hard disk 2'
+ assert:
+ that:
+ - set_boot_hdd_result1.changed
+ - set_boot_hdd_result1.vm_boot_status.current_boot_disk == 'Hard disk 2'
+
+- name: Set boot disk to 'Hard disk 2' again to test idempotency
+ community.vmware.vmware_guest_boot_manager:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: "{{ virtual_machines[0].name }}"
+ boot_order:
+ - disk
+ - cdrom
+ - ethernet
+ boot_hdd_name: 'Hard disk 2'
+ register: set_boot_hdd_result2
+
+- ansible.builtin.debug: var=set_boot_hdd_result2
+
+- name: assert that task is not changed
+ assert:
+ that:
+ - not set_boot_hdd_result2.changed
+ - set_boot_hdd_result2.vm_boot_status.current_boot_disk == 'Hard disk 2'
+ - set_boot_hdd_result2.vm_boot_status.previous_boot_disk == 'Hard disk 2'
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml
new file mode 100644
index 00000000..790eb4a1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml
@@ -0,0 +1,80 @@
+# Test code for the vmware_guest_controller module
+# Copyright: (c) 2019, Diane Wang (Tomorrow9) <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: gather disk controllers facts of the virtual machine
+ vmware_guest_controller:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ gather_disk_controller_facts: true
+ register: disk_controller_facts
+
+- debug: var=disk_controller_facts
+
+- name: get the number of existing disk controllers
+ set_fact:
+ scsi_num: "{{ disk_controller_facts.disk_controller_data.scsi | length }}"
+- set_fact:
+ sata_num: "{{ disk_controller_facts.disk_controller_data.sata | length }}"
+- set_fact:
+ nvme_num: "{{ disk_controller_facts.disk_controller_data.nvme | length }}"
+
+- name: add new disk controllers to virtual machine
+ vmware_guest_controller:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ sleep_time: 30
+ controllers:
+ - type: sata
+ state: present
+ - type: paravirtual
+ state: present
+ register: add_disk_controller
+
+- debug: var=add_disk_controller
+
+- name: assert the new disk controllers were added to VM
+ assert:
+ that:
+ - "add_disk_controller.changed == true"
+ - "{{ add_disk_controller.disk_controller_data.scsi | length | int }} == {{ scsi_num | int + 1 }}"
+ - "{{ add_disk_controller.disk_controller_data.sata | length | int }} == {{ sata_num | int + 1 }}"
+
+- name: delete specified disk controllers
+ vmware_guest_controller:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ sleep_time: 30
+ controllers:
+ - state: absent
+ type: sata
+ controller_number: "{{ sata_num }}"
+ - state: absent
+ type: paravirtual
+ controller_number: "{{ scsi_num }}"
+ register: del_disk_controller
+
+- debug: var=del_disk_controller
+
+- name: assert the disk controllers were removed
+ assert:
+ that:
+ - "del_disk_controller.changed == true"
+ - "{{ del_disk_controller.disk_controller_data.sata | length | int }} == {{ sata_num | int }}"
+ - "{{ del_disk_controller.disk_controller_data.scsi | length | int }} == {{ scsi_num | int }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/aliases
new file mode 100644
index 00000000..f44f70d8
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+unsupported
+needs/target/prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/tasks/main.yml
new file mode 100644
index 00000000..29a70aad
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_cross_vc_clone/tasks/main.yml
@@ -0,0 +1,160 @@
+# Test code for the vmware_guest_cross_vc_clone Operations.
+# Copyright: (c) 2020, Anusha Hegde <anushah@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+- name: Create VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 512
+ disk:
+ - size: 1gb
+ type: thin
+ autoselect_datastore: true
+ state: present
+ register: create_vm_for_test
+
+- name: Create VM template
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm2
+ is_template: true
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 512
+ disk:
+ - size: 1gb
+ type: thin
+ autoselect_datastore: true
+ state: present
+ register: create_vm_template_for_test
+
+- name: clone a template across VC
+ vmware_guest_cross_vc_clone:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm2"
+ destination_vm_name: "cloned_vm_from_template"
+ destination_vcenter: '{{ destination_vcenter_hostname }}'
+ destination_vcenter_username: '{{ destination_vcenter_username }}'
+ destination_vcenter_password: '{{ destination_vcenter_password }}'
+ destination_host: '{{ destination_esxi }}'
+ destination_datastore: '{{ destination_datastore }}'
+ destination_vm_folder: '{{ destination_vm_folder }}'
+ power_on: false
+ register: cross_vc_clone_from_template
+
+- name: assert that changes were made
+ assert:
+ that:
+ - cross_vc_clone_from_template is changed
+
+- name: clone a VM across VC
+ vmware_guest_cross_vc_clone:
+ hostname: '{{ destination_vcenter_hostname }}'
+ username: '{{ destination_vcenter_username }}'
+ password: "{{ destination_vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ destination_vm_name: "cloned_vm_from_vm"
+ destination_vcenter: '{{ destination_vcenter_hostname }}'
+ destination_vcenter_username: '{{ destination_vcenter_username }}'
+ destination_vcenter_password: '{{ destination_vcenter_password }}'
+ destination_vcenter_port: '{{ destination_vcenter_port }}'
+ destination_vcenter_validate_certs: '{{ destination_vcenter_validate_certs }}'
+ destination_host: '{{ destination_esxi1 }}'
+ destination_datastore: '{{ destination_datastore }}'
+ destination_vm_folder: '{{ destination_vm_folder }}'
+ power_on: true
+ register: cross_vc_clone_from_vm
+
+- name: assert that changes were made
+ assert:
+ that:
+ - cross_vc_clone_from_vm is changed
+
+- name: clone a VM across VC when datastore cluster is specified
+ vmware_guest_cross_vc_clone:
+ hostname: '{{ destination_vcenter_hostname }}'
+ username: '{{ destination_vcenter_username }}'
+ password: "{{ destination_vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ destination_vm_name: "cloned_vm_from_vm"
+ destination_vcenter: '{{ destination_vcenter_hostname }}'
+ destination_vcenter_username: '{{ destination_vcenter_username }}'
+ destination_vcenter_password: '{{ destination_vcenter_password }}'
+ destination_host: '{{ destination_esxi1 }}'
+ destination_datastore: '{{ destination_datastore_cluster }}'
+ destination_vm_folder: '{{ destination_vm_folder }}'
+ power_on: true
+ register: cross_vc_clone_from_vm_with_datastore_cluster
+
+- name: assert that changes were made
+ assert:
+ that:
+ - cross_vc_clone_from_vm_with_datastore_cluster is changed
+
+- name: clone in check mode
+ vmware_guest_cross_vc_clone:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm2"
+ destination_vm_name: "cloned_vm_from_template_in_check_mode"
+ destination_vcenter: '{{ destination_vcenter_hostname }}'
+ destination_vcenter_username: '{{ destination_vcenter_username }}'
+ destination_vcenter_password: '{{ destination_vcenter_password }}'
+ destination_host: '{{ destination_esxi }}'
+ destination_datastore: '{{ destination_datastore }}'
+ destination_vm_folder: '{{ destination_vm_folder }}'
+ power_on: false
+ check_mode: true
+ register: check_mode_clone
+
+- debug:
+ var: check_mode_clone
+
+- name: idempotency check - VM name already exists
+ vmware_guest_cross_vc_clone:
+ hostname: '{{ destination_vcenter_hostname }}'
+ username: '{{ destination_vcenter_username }}'
+ password: "{{ destination_vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ destination_vm_name: "cloned_vm_from_vm"
+ destination_vcenter: '{{ destination_vcenter_hostname }}'
+ destination_vcenter_username: '{{ destination_vcenter_username }}'
+ destination_vcenter_password: '{{ destination_vcenter_password }}'
+ destination_host: '{{ destination_esxi1 }}'
+ destination_datastore: '{{ destination_datastore }}'
+ destination_vm_folder: '{{ destination_vm_folder }}'
+ power_on: true
+ register: idempotency_check
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - idempotency_check is unchanged \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/tasks/main.yml
new file mode 100644
index 00000000..4ded94b2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attribute_defs/tasks/main.yml
@@ -0,0 +1,85 @@
+# Test code for the vmware_guest_custom_attribute_defs module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+- name: remove attribute definition
+ vmware_guest_custom_attribute_defs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ attribute_key: sample_5
+
+- name: add custom attribute definition
+ vmware_guest_custom_attribute_defs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ attribute_key: sample_5
+ register: add_attrib_def
+
+- debug: var=add_attrib_def
+
+- assert:
+ that:
+ - add_attrib_def is changed
+ - "'sample_5' in add_attrib_def.custom_attribute_defs"
+
+- name: add attribute definition again
+ vmware_guest_custom_attribute_defs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ attribute_key: sample_5
+ register: add_attrib_def
+
+- debug: var=add_attrib_def
+
+- assert:
+ that:
+ - not (add_attrib_def is changed)
+
+- name: remove attribute definition
+ vmware_guest_custom_attribute_defs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ attribute_key: sample_5
+ register: remove_attrib_def
+
+- debug: var=remove_attrib_def
+
+- assert:
+ that:
+ - "remove_attrib_def.changed"
+ - "'sample_5' not in remove_attrib_def.custom_attribute_defs"
+
+- name: remove attribute definition
+ vmware_guest_custom_attribute_defs:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ attribute_key: sample_5
+ register: remove_attrib_def
+
+- debug: var=remove_attrib_def
+
+- assert:
+ that:
+ - "not remove_attrib_def.changed"
+ - "'sample_5' not in remove_attrib_def.custom_attribute_defs"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/tasks/main.yml
new file mode 100644
index 00000000..62aad771
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_custom_attributes/tasks/main.yml
@@ -0,0 +1,157 @@
+# Test code for the vmware_guest_custom_attributes module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Add custom attribute to the given virtual machine with check_mode and diff
+ vmware_guest_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ attributes:
+ - name: 'sample_1'
+ value: 'sample_1_value'
+ - name: 'sample_2'
+ value: 'sample_2_value'
+ - name: 'sample_3'
+ value: 'sample_3_value'
+ check_mode: true
+ diff: true
+ register: guest_info_0001_check_mode_diff
+
+- name: Make sure the target could be changed
+ assert:
+ that:
+ - guest_info_0001_check_mode_diff.changed is sameas true
+
+- name: Add custom attribute to the given virtual machine
+ vmware_guest_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ attributes:
+ - name: 'sample_1'
+ value: 'sample_1_value'
+ - name: 'sample_2'
+ value: 'sample_2_value'
+ - name: 'sample_3'
+ value: 'sample_3_value'
+ register: guest_info_0001
+
+- name: Make sure the target is changed
+ assert:
+ that:
+ - guest_info_0001.changed is sameas true
+ - guest_info_0001.custom_attributes.sample_1 == "sample_1_value"
+ - guest_info_0001.custom_attributes.sample_2 == "sample_2_value"
+ - guest_info_0001.custom_attributes.sample_3 == "sample_3_value"
+
+- name: Add custom attribute to the given virtual machine again
+ vmware_guest_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ attributes:
+ - name: 'sample_1'
+ value: 'sample_1_value'
+ - name: 'sample_2'
+ value: 'sample_2_value'
+ - name: 'sample_3'
+ value: 'sample_3_value'
+ register: guest_info_0002
+
+- name: Make sure the task has the idempotency
+ assert:
+ that:
+ - not (guest_info_0002 is changed)
+ - guest_info_0002.custom_attributes | length == 0
+
+- name: Remove custom attribute to the given virtual machine with check_mode and diff
+ vmware_guest_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: absent
+ attributes:
+ - name: 'sample_1'
+ - name: 'sample_2'
+ - name: 'sample_3'
+ check_mode: true
+ diff: true
+ register: guest_info_0004_check_mode_diff
+
+- name: Make sure the target could be changed
+ assert:
+ that:
+ - guest_info_0004_check_mode_diff.changed is sameas true
+
+- name: Remove custom attribute to the given virtual machine
+ vmware_guest_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: absent
+ attributes:
+ - name: 'sample_1'
+ - name: 'sample_2'
+ - name: 'sample_3'
+ register: guest_info_0004
+
+- name: Make sure the target is changed
+ assert:
+ that:
+ - guest_info_0004.changed is sameas true
+ - guest_info_0004.custom_attributes.sample_1 == ""
+ - guest_info_0004.custom_attributes.sample_2 == ""
+ - guest_info_0004.custom_attributes.sample_3 == ""
+
+- name: Remove custom attribute to the given virtual machine again
+ vmware_guest_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: absent
+ attributes:
+ - name: 'sample_1'
+ - name: 'sample_2'
+ - name: 'sample_3'
+ register: guest_info_0005
+
+- name: Make sure the task has the idempotency
+ assert:
+ that:
+ - not (guest_info_0005 is changed)
+ - guest_info_0005.custom_attributes | length == 0
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/tasks/main.yml
new file mode 100644
index 00000000..6e28d7d7
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_customization_info/tasks/main.yml
@@ -0,0 +1,36 @@
+# Test code for the vmware_guest_customization_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- &vm_guest_info
+ name: Gather info about given customization spec
+ vmware_guest_customization_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: vm_custom_spec_info
+
+- debug:
+ var: vm_custom_spec_info
+
+- assert:
+ that:
+ - "not vm_custom_spec_info.changed"
+
+- <<: *vm_guest_info
+ name: Gather info about given customization spec in check module
+
+- debug:
+ var: vm_custom_spec_info
+
+- assert:
+ that:
+ - "not vm_custom_spec_info.changed"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml
new file mode 100644
index 00000000..6e50231e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml
@@ -0,0 +1,610 @@
+# Test code for the vmware_guest_disk_disk module.
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+
+- name: Create VM
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ folder: vm
+ esxi_hostname: "{{ esxi1 }}"
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: local
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ hardware:
+ # vmware_guest_disk need vmx-13 to reconfigure the disks
+ version: 13
+ memory_mb: 1024
+ num_cpus: 1
+ scsi: paravirtual
+ register: vm_create
+
+
+- name: create new disk with invalid disk mode
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "invalid_disk_mode"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 10
+ state: present
+ type: eagerzeroedthick
+ unit_number: 2
+ register: test_create_disk1
+ ignore_errors: true
+
+- debug:
+ msg: "{{ test_create_disk1 }}"
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - not(test_create_disk1 is changed)
+
+- name: create new disk(s) with valid disk mode
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 1
+ state: present
+ type: eagerzeroedthick
+ unit_number: 2
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_nonpersistent"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 1
+ state: present
+ type: eagerzeroedthick
+ unit_number: 3
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "persistent"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 1
+ state: present
+ type: eagerzeroedthick
+ unit_number: 4
+ register: test_create_disk2
+
+- debug:
+ msg: "{{ test_create_disk2 }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_create_disk2 is changed
+
+- name: create new disk with custom shares
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - size_gb: 1
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_nonpersistent"
+ scsi_controller: 1
+ state: present
+ unit_number: 4
+ shares:
+ level: custom
+ level_value: 1300
+ register: test_custom_shares
+
+- debug:
+ msg: "{{ test_custom_shares }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_custom_shares is changed
+
+- name: create new disk with custom IO limits and shares in IO Limits
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - size_gb: 1
+ type: eagerzeroedthick
+ datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_nonpersistent"
+ scsi_controller: 2
+ state: present
+ unit_number: 4
+ iolimit:
+ limit: 1506
+ shares:
+ level: custom
+ level_value: 1305
+ register: test_custom_IoLimit_shares
+
+- debug:
+ msg: "{{ test_custom_IoLimit_shares }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_custom_IoLimit_shares is changed
+
+- name: Update disk for custom IO limits in IO Limits
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - size_gb: 2
+ scsi_controller: 2
+ state: present
+ unit_number: 4
+ iolimit:
+ limit: 1500
+ shares:
+ level: custom
+ level_value: 1305
+ register: test_custom_IoLimit
+
+- debug:
+ msg: "{{ test_custom_IoLimit }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_custom_IoLimit is changed
+
+- name: Update disk for shares of IO limits
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - size_gb: 3
+ scsi_controller: 2
+ state: present
+ unit_number: 4
+ iolimit:
+ limit: 1500
+ shares:
+ level: low
+ register: test_shares_IoLimit
+
+- debug:
+ msg: "{{ test_shares_IoLimit }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_shares_IoLimit is changed
+
+- name: Update disk for shares and IoLimits of IO limits
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - size_gb: 4
+ scsi_controller: 2
+ state: present
+ unit_number: 4
+ iolimit:
+ limit: 1507
+ shares:
+ level: high
+ register: test_shares_IoLimits
+
+- debug:
+ msg: "{{ test_shares_IoLimits }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_shares_IoLimits is changed
+
+- name: remove disks without destroy file
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - state: "absent"
+ scsi_controller: 0
+ unit_number: 2
+ destroy: false
+ register: test_remove_without_destroy
+
+- debug:
+ msg: "{{ test_remove_without_destroy }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_remove_without_destroy is changed
+
+- name: re-create disk with valid disk mode
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "persistent"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 1
+ state: present
+ type: eagerzeroedthick
+ unit_number: 8
+ register: test_recreate_disk
+
+- debug:
+ msg: "{{ test_recreate_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_recreate_disk is changed
+
+- name: create new disk with sharing (multi-writer) mode
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 1
+ state: present
+ type: eagerzeroedthick
+ sharing: true
+ unit_number: 6
+ register: test_create_disk_sharing
+
+- debug:
+ msg: "{{ test_create_disk_sharing }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_create_disk_sharing is changed
+
+- name: create new disk with invalid disk type for sharing (multi-writer) mode
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ scsi_controller: 0
+ scsi_type: 'paravirtual'
+ size_gb: 1
+ state: present
+ type: thin
+ unit_number: 5
+ sharing: true
+ register: test_create_disk_sharing_invalid
+ ignore_errors: true
+
+- debug:
+ msg: "{{ test_create_disk_sharing_invalid }}"
+
+- name: assert that changes were not made
+ assert:
+ that:
+ - not(test_create_disk_sharing_invalid is changed)
+
+- name: remove disk with destroy file
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - state: "absent"
+ scsi_controller: 0
+ unit_number: 3
+ destroy: true
+ - state: "absent"
+ scsi_controller: 0
+ unit_number: 4
+ register: test_remove_with_destroy
+
+- debug:
+ msg: "{{ test_remove_with_destroy }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_remove_with_destroy is changed
+
+- name: create new disk with SATA controller
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ controller_type: 'sata'
+ controller_number: 1
+ unit_number: 3
+ size_gb: 1
+ state: present
+ type: thin
+ register: test_create_sata_disk
+
+- debug:
+ msg: "{{ test_create_sata_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_create_sata_disk is changed
+
+- name: create new disk with NVMe controller
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ controller_type: 'nvme'
+ controller_number: 0
+ unit_number: 1
+ size: 1gb
+ state: present
+ type: thin
+ register: test_create_nvme_disk
+
+- debug:
+ msg: "{{ test_create_nvme_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_create_nvme_disk is changed
+
+- name: create 2 new disks on existing SATA controller and NVMe controller
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ controller_type: 'sata'
+ controller_number: 1
+ unit_number: 6
+ size_gb: 1
+ state: present
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ controller_type: 'nvme'
+ controller_number: 0
+ unit_number: 4
+ size: 1gb
+ state: present
+ type: thin
+ register: test_create_two_disks
+
+- debug:
+ msg: "{{ test_create_two_disks }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_create_two_disks is changed
+
+- name: re-configure SATA disk
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - disk_mode: "independent_nonpersistent"
+ controller_type: 'sata'
+ controller_number: 1
+ unit_number: 3
+ size_gb: 2
+ state: present
+ shares:
+ level: custom
+ level_value: 1200
+ register: test_reconfig_sata_disk
+
+- debug:
+ msg: "{{ test_reconfig_sata_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_reconfig_sata_disk is changed
+
+- name: re-configure NVMe disk
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - controller_type: 'nvme'
+ controller_number: 0
+ unit_number: 1
+ size_gb: 2
+ state: present
+ iolimit:
+ limit: 1507
+ shares:
+ level: custom
+ level_value: 1000
+ register: test_reconfig_nvme_disk
+
+- debug:
+ msg: "{{ test_reconfig_nvme_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_reconfig_nvme_disk is changed
+
+- name: remove SATA and NVMe disks
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - state: "absent"
+ controller_type: 'sata'
+ controller_number: 1
+ unit_number: 3
+ destroy: false
+ - state: "absent"
+ controller_type: 'nvme'
+ controller_number: 0
+ unit_number: 1
+ destroy: true
+ register: test_remove_sata_nvme_disk
+
+- debug:
+ msg: "{{ test_remove_sata_nvme_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_remove_sata_nvme_disk is changed
+
+- name: create new disk with IDE controller
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - datastore: "{{ rw_datastore }}"
+ disk_mode: "independent_persistent"
+ controller_type: 'ide'
+ controller_number: 0
+ unit_number: 1
+ size_gb: 1
+ state: present
+ type: thin
+ shares:
+ level: custom
+ level_value: 1200
+ register: test_create_ide_disk
+
+- debug:
+ msg: "{{ test_create_ide_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_create_ide_disk is changed
+
+- name: remove IDE disk
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - state: "absent"
+ controller_type: 'ide'
+ controller_number: 0
+ unit_number: 1
+ destroy: true
+ register: test_remove_ide_disk
+
+- debug:
+ msg: "{{ test_remove_ide_disk }}"
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_remove_ide_disk is changed \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml
new file mode 100644
index 00000000..decb904f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml
@@ -0,0 +1,73 @@
+# Test code for the vmware_guest_disk_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Create VMs
+ vmware_guest:
+ datacenter: "{{ dc1 }}"
+ folder: '{{ f0 }}'
+ name: DC0_H0_VM0
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_mb: 10
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ version: 11
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- name: set state to poweron the first VM
+ vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: DC0_H0_VM0
+ folder: '{{ f0 }}'
+ state: powered-on
+
+- name: Gather info about virtual machine disks
+ vmware_guest_disk_info: &get_info
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ name: DC0_H0_VM0
+ datacenter: '{{ dc1 }}'
+ register: disk_info
+
+- debug:
+ msg: '{{ disk_info }}'
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - "not disk_info.changed"
+
+- name: Gather info about virtual machine disks in check mode
+ vmware_guest_disk_info:
+ <<: *get_info
+ register: disk_info
+ check_mode: true
+
+- debug:
+ msg: '{{ disk_info }}'
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - "not disk_info.changed"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/tasks/main.yml
new file mode 100644
index 00000000..4ffaec31
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_find/tasks/main.yml
@@ -0,0 +1,60 @@
+# Test code for the vmware_guest_find module.
+# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+- name: find folders for each vm
+ vmware_guest_find:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ item.name }}"
+ with_items: "{{ virtual_machines }}"
+ register: folders
+
+- debug: var=item
+ with_items: "{{ folders.results }}"
+
+# We only care that each VM was found, not that the folder path
+# is completely accurate. Eventually the test should be extended
+# to validate the full path for each VM.
+- assert:
+ that:
+ - "{{ 'folders' in item }}"
+ - "{{ item['folders']|length == 1 }}"
+ with_items: "{{ folders.results }}"
+
+- name: get fact of the first VM
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ register: guest_info_0001
+
+- debug: var=guest_info_0001
+
+- name: find folders for each vm using UUID
+ vmware_guest_find:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ uuid: "{{ guest_info_0001['instance']['hw_product_uuid'] }}"
+ register: folder_uuid
+
+- debug: var=folder_uuid
+
+- assert:
+ that:
+ - "{{ 'folders' in folder_uuid }}"
+ - "{{ folder_uuid['folders']|length == 1 }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/tasks/main.yml
new file mode 100644
index 00000000..4a42b390
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_info/tasks/main.yml
@@ -0,0 +1,247 @@
+# Test code for the vmware_guest_info module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# Copyright: (c) 2018, James E. King III (@jeking3) <jking@apache.org>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+# Testcase 0001: Get details about virtual machines
+- name: get list of info about virtual machines
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ register: guest_info_0001
+
+- debug:
+ var: guest_info_0001
+
+- assert:
+ that:
+ - "guest_info_0001['instance']['hw_name'] == virtual_machines[0].name"
+ - "guest_info_0001['instance']['hw_product_uuid'] is defined"
+ - "guest_info_0001['instance']['hw_cores_per_socket'] is defined"
+ - "guest_info_0001['instance']['hw_datastores'] is defined"
+ - "guest_info_0001['instance']['hw_esxi_host'] is defined"
+ - "guest_info_0001['instance']['hw_files'] is defined"
+ - "guest_info_0001['instance']['hw_guest_ha_state'] is defined"
+ - "guest_info_0001['instance']['hw_is_template'] is defined"
+ - "guest_info_0001['instance']['hw_folder'] is defined"
+ - "guest_info_0001['instance']['guest_question'] is defined"
+ - "guest_info_0001['instance']['guest_consolidation_needed'] is defined"
+ - "guest_info_0001['instance']['moid'] is defined"
+ - "guest_info_0001['instance']['vimref'] is defined"
+ - "'portgroup_portkey' in guest_info_0001['instance']['hw_eth0']"
+ - "'portgroup_key' in guest_info_0001['instance']['hw_eth0']"
+ - "guest_info_0001['instance']['instance_uuid'] is defined"
+
+- set_fact: vm1_uuid="{{ guest_info_0001['instance']['hw_product_uuid'] }}"
+
+- set_fact: vm1_instance_uuid="{{ guest_info_0001['instance']['instance_uuid'] }}"
+
+- set_fact: vm1_moid="{{ guest_info_0001['instance']['moid'] }}"
+
+- debug:
+ var: vm1_uuid
+
+# Testcase 0002: Get details about virtual machines using UUID
+- name: get list of info about virtual machines using UUID
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ uuid: "{{ vm1_uuid }}"
+ register: guest_info_0002
+
+- debug:
+ var: guest_info_0002
+
+- name: Get specific details about virtual machines using the vsphere output schema
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ uuid: "{{ vm1_uuid }}"
+ schema: vsphere
+ properties:
+ - config.hardware.memoryMB
+ - guest
+ - name
+ - summary.runtime.connectionState
+ register: guest_info_0002b
+
+- debug:
+ var: guest_info_0002b
+
+- assert:
+ that:
+ - "guest_info_0002['instance']['hw_name'] == virtual_machines[0].name"
+ - "guest_info_0002['instance']['hw_product_uuid'] is defined"
+ - "guest_info_0002['instance']['hw_product_uuid'] == vm1_uuid"
+ - "guest_info_0002['instance']['hw_cores_per_socket'] is defined"
+ - "guest_info_0002b['instance']['config']['hardware']['memoryMB'] is defined"
+ - "guest_info_0002b['instance']['config']['hardware']['numCoresPerSocket'] is not defined"
+ - "guest_info_0002b['instance']['guest']['toolsVersion'] is defined"
+ - "guest_info_0001['instance']['moid'] is defined"
+ - "guest_info_0001['instance']['vimref'] is defined"
+ - "guest_info_0002b['instance']['overallStatus'] is not defined"
+
+# https://github.com/ansible-collections/vmware/issues/33
+- name: Get specific details about VM using the vsphere output schema
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ uuid: "{{ vm1_uuid }}"
+ schema: vsphere
+ properties:
+ - config.hardware.device.deviceInfo.summary
+ register: guest_info_with_list
+
+- debug:
+ var: guest_info_with_list
+
+- assert:
+ that:
+ - "guest_info_with_list['instance']['config']['hardware']['device'] is defined"
+
+# Testcase 0003: Get details about virtual machines without snapshots using UUID
+- name: get empty list of snapshots from virtual machine using UUID
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ uuid: "{{ vm1_uuid }}"
+ register: guest_info_0003
+
+- debug:
+ var: guest_info_0003
+
+- assert:
+ that:
+ - "guest_info_0003['instance']['snapshots']|length == 0"
+ - "guest_info_0003['instance']['current_snapshot'] is none"
+
+# Testcase 0004: Get details about virtual machines with two snapshots using UUID
+- name: Create first snapshot
+ vmware_guest_snapshot: &vm_snap
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: snap1
+
+- name: Create second snapshot
+ vmware_guest_snapshot:
+ <<: *vm_snap
+ snapshot_name: snap2
+
+- name: get list of snapshots from virtual machine using UUID
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ uuid: "{{ vm1_uuid }}"
+ register: guest_info_0004
+
+- debug:
+ var: guest_info_0004
+
+- assert:
+ that:
+ - "guest_info_0004['instance']['snapshots'] is defined"
+ - "guest_info_0004['instance']['snapshots'][0]['name'] == 'snap1'"
+ - "guest_info_0004['instance']['snapshots'][1]['name'] == 'snap2'"
+ - "guest_info_0004['instance']['current_snapshot']['name'] == 'snap2'"
+ - "guest_info_0004['instance']['hw_folder'] is defined"
+
+# Testcase 0005: Get details about virtual machines using UUID
+- name: get list of info about virtual machines using instance UUID
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ uuid: "{{ vm1_instance_uuid }}"
+ use_instance_uuid: true
+ register: guest_info_0005
+
+- debug:
+ msg: "{{ guest_info_0005 }}"
+
+- assert:
+ that:
+ - "guest_info_0005['instance']['hw_name'] == virtual_machines[0].name"
+ - "guest_info_0005['instance']['hw_product_uuid'] is defined"
+ - "guest_info_0005['instance']['hw_product_uuid'] == vm1_uuid"
+ - "guest_info_0005['instance']['hw_cores_per_socket'] is defined"
+ - "guest_info_0005['instance']['hw_datastores'] is defined"
+ - "guest_info_0005['instance']['hw_esxi_host'] is defined"
+ - "guest_info_0005['instance']['hw_files'] is defined"
+ - "guest_info_0005['instance']['hw_guest_ha_state'] is defined"
+ - "guest_info_0005['instance']['hw_is_template'] is defined"
+ - "guest_info_0005['instance']['hw_folder'] is defined"
+ - "guest_info_0005['instance']['guest_question'] is defined"
+ - "guest_info_0005['instance']['guest_consolidation_needed'] is defined"
+ - "guest_info_0005['instance']['instance_uuid'] is defined"
+ - "guest_info_0005['instance']['instance_uuid'] == vm1_instance_uuid"
+ - "guest_info_0005['instance']['moid'] is defined"
+ - "guest_info_0005['instance']['vimref'] is defined"
+
+# Testcase 0006: Get details about virtual machines using MoID
+- name: get list of information about virtual machines using instance MoID
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ moid: "{{ vm1_moid }}"
+ use_instance_uuid: true
+ register: guest_info_0006
+
+- debug:
+ msg: "{{ guest_info_0006 }}"
+
+- assert:
+ that:
+ - "guest_info_0006['instance']['hw_name'] == virtual_machines[0].name"
+ - "guest_info_0006['instance']['hw_product_uuid'] is defined"
+ - "guest_info_0006['instance']['hw_product_uuid'] == vm1_uuid"
+ - "guest_info_0006['instance']['hw_cores_per_socket'] is defined"
+ - "guest_info_0006['instance']['hw_datastores'] is defined"
+ - "guest_info_0006['instance']['hw_esxi_host'] is defined"
+ - "guest_info_0006['instance']['hw_files'] is defined"
+ - "guest_info_0006['instance']['hw_guest_ha_state'] is defined"
+ - "guest_info_0006['instance']['hw_is_template'] is defined"
+ - "guest_info_0006['instance']['hw_folder'] is defined"
+ - "guest_info_0006['instance']['guest_question'] is defined"
+ - "guest_info_0006['instance']['guest_consolidation_needed'] is defined"
+ - "guest_info_0006['instance']['instance_uuid'] is defined"
+ - "guest_info_0006['instance']['instance_uuid'] == vm1_instance_uuid"
+ - "guest_info_0006['instance']['moid'] is defined"
+ - "guest_info_0006['instance']['vimref'] is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/tasks/main.yml
new file mode 100644
index 00000000..026c89fc
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_instant_clone/tasks/main.yml
@@ -0,0 +1,385 @@
+# Test code for the vmware_guest_instant_clone Operations.
+# Copyright: (c) 2021, Anant Chopra <chopraan@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datacenter: true
+ setup_datastore: true
+ setup_resource_pool: true
+
+- name: Create VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datastore: "{{ rw_datastore }}"
+ esxi_hostname: "{{ esxi1 }}"
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 512
+ version: 11
+ disk:
+ - size: 1gb
+ type: thin
+ autoselect_datastore: true
+ state: poweredon
+ register: create_vm_for_test
+
+- name: Instant Clone a VM with parent VM
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ f0 }}"
+ datastore: "{{ rw_datastore }}"
+ datacenter: "{{ dc1 }}"
+ host: "{{ esxi1 }}"
+ name: "cloned_vm_from_vm"
+ parent_vm: "test_vm1"
+ resource_pool: DC0_C0_RP1
+ register: instant_clone_from_vm_parent
+
+- name: assert that changes were made
+ assert:
+ that:
+ - instant_clone_from_vm_parent is changed
+
+- name: Instant Clone a VM when datastore cluster is specified
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ f0 }}"
+ datastore: "{{ rw_datastore }}"
+ datacenter: "{{ dc1 }}"
+ host: "{{ esxi1 }}"
+ name: "cloned_vm_from_vm_cluster"
+ parent_vm: "test_vm1"
+ resource_pool: DC0_C0_RP1
+ register: instant_clone_from_vm_when_cluster_is_specified
+
+- name: assert that changes were made
+ assert:
+ that:
+ - instant_clone_from_vm_when_cluster_is_specified is changed
+
+- name: set state to poweroff the Cloned VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "cloned_vm_from_vm_cluster"
+ folder: "{{ f0 }}"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_when_cluster
+
+- debug:
+ var: poweroff_instant_clone_from_vm_when_cluster
+
+- name: Clean VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "cloned_vm_from_vm_cluster"
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_instant_clone_from_vm_when_cluster
+ ignore_errors: true
+
+- debug: var=delete_instant_clone_from_vm_when_cluster
+
+- name: Instant Clone a VM when skipping optional params
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "cloned_vm_from_vm_optional"
+ parent_vm: "test_vm1"
+ datacenter: "{{ dc1 }}"
+ datastore: "{{ rw_datastore }}"
+ host: "{{ esxi1 }}"
+ register: instant_clone_from_vm_optional_arguments
+
+- name: assert that changes were made
+ assert:
+ that:
+ - instant_clone_from_vm_optional_arguments is changed
+
+- name: set state to poweroff the Cloned VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "cloned_vm_from_vm_optional"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_optional_arguments
+
+- debug:
+ var: poweroff_instant_clone_from_vm_optional_arguments
+
+- name: Clean VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "cloned_vm_from_vm_optional"
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_instant_clone_from_vm_optional_arguments
+ ignore_errors: true
+
+- debug: var=delete_instant_clone_from_vm_optional_arguments
+
+- name: Instant Clone a VM with moid
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: "{{ rw_datastore }}"
+ host: "{{ esxi1 }}"
+ name: "Instant_cloned_test"
+ moid: "{{ create_vm_for_test.instance.moid }}"
+ resource_pool: DC0_C0_RP1
+ register: instant_clone_from_vm_moid
+
+- name: assert that changes were made
+ assert:
+ that:
+ - instant_clone_from_vm_moid is changed
+
+- name: set state to poweroff the Cloned VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "Instant_cloned_test"
+ folder: "{{ f0 }}"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_moid
+
+- debug:
+ var: poweroff_instant_clone_from_vm_moid
+
+- name: Clean VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "Instant_cloned_test"
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_instant_clone_from_vm_moid
+ ignore_errors: true
+
+- debug: var=delete_instant_clone_from_vm_moid
+
+- name: Instant Clone a VM with instance_uuid
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: "{{ rw_datastore }}"
+ host: "{{ esxi1 }}"
+ name: "Instant_cloned_instance_uuid"
+ use_instance_uuid: true
+ uuid: "{{ create_vm_for_test.instance.instance_uuid }}"
+ resource_pool: DC0_C0_RP1
+ register: instant_clone_from_vm_instance_uuid
+
+- name: assert that changes were made
+ assert:
+ that:
+ - instant_clone_from_vm_instance_uuid is changed
+
+- name: set state to poweroff the Cloned VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "Instant_cloned_instance_uuid"
+ folder: "{{ f0 }}"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_instance_uuid
+
+- debug:
+ var: poweroff_instant_clone_from_vm_instance_uuid
+
+- name: Clean VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "Instant_cloned_instance_uuid"
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_instant_clone_from_vm_instance_uuid
+ ignore_errors: true
+
+- debug: var=delete_instant_clone_from_vm_instance_uuid
+
+- name: Instant Clone a VM with uuid
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ datastore: "{{ rw_datastore }}"
+ host: "{{ esxi1 }}"
+ name: "Instant_cloned_uuid"
+ uuid: "{{ create_vm_for_test.instance.hw_product_uuid }}"
+ resource_pool: DC0_C0_RP1
+ register: instant_clone_from_vm_uuid
+
+- name: assert that changes were made
+ assert:
+ that:
+ - instant_clone_from_vm_uuid is changed
+
+- name: set state to poweroff the VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: Instant_cloned_uuid
+ folder: "{{ f0 }}"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_uuid
+
+- debug:
+ var: poweroff_instant_clone_from_vm_uuid
+
+- name: Clean VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: Instant_cloned_uuid
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_instant_clone_from_vm_uuid
+ ignore_errors: true
+
+- debug: var=delete_instant_clone_from_vm_uuid
+
+- name: Instant clone in check mode
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ f0 }}"
+ datastore: "{{ rw_datastore }}"
+ datacenter: "{{ dc1 }}"
+ host: "{{ esxi1 }}"
+ name: "cloned_vm_from_vm_check"
+ parent_vm: "test_vm1"
+ resource_pool: DC0_C0_RP1
+ check_mode: true
+ register: check_mode_instant_clone
+
+- debug:
+ var: check_mode_instant_clone
+
+- name: idempotency check - VM name already exists
+ community.vmware.vmware_guest_instant_clone:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "cloned_vm_from_vm"
+ parent_vm: "test_vm1"
+ datacenter: "{{ dc1 }}"
+ datastore: "{{ rw_datastore }}"
+ host: "{{ esxi1 }}"
+ resource_pool: DC0_C0_RP1
+ folder: "{{ f0 }}"
+ register: idempotency_check
+
+- debug:
+ var: idempotency_check
+
+- name: set state to poweroff the Cloned VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "cloned_vm_from_vm"
+ folder: "{{ f0 }}"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_parent
+
+- debug:
+ var: poweroff_instant_clone_from_vm_parent
+
+- name: Clean VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "cloned_vm_from_vm"
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: delete_instant_clone_from_vm_parent
+ ignore_errors: true
+
+- debug: var=delete_instant_clone_from_vm_parent
+
+- name: set state to poweroff the parent VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "test_vm1"
+ folder: "{{ f0 }}"
+ state: powered-off
+ register: poweroff_instant_clone_from_vm_parent
+
+- debug:
+ var: poweroff_instant_clone_from_vm_parent
+
+- name: Clean parent VM
+ community.vmware.vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "test_vm1"
+ datacenter: "{{ dc1 }}"
+ state: absent
+ register: clean_parent_vm
+ ignore_errors: true
+
+- debug: var=clean_parent_vm
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/tasks/main.yml
new file mode 100644
index 00000000..d35903a5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_move/tasks/main.yml
@@ -0,0 +1,81 @@
+# Test code for the vmware_guest_move module
+# Copyright: (c) 2018, Jose Angel Munoz <josea.munoz@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Create a VM folder on given Datacenter
+ vcenter_folder:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ folder_name: 'f1'
+ folder_type: vm
+ state: present
+ validate_certs: false
+ register: dest_folder
+
+# Testcase 0001: Move vm and get changed status
+- name: Move VM (Changed)
+ vmware_guest_move:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ name: '{{ virtual_machines[0].name }}'
+ # Depends-On: https://github.com/ansible/ansible/pull/55237
+ dest_folder: '{{ dest_folder.result.path }}'
+ register: vm_info_0001
+
+
+# Testcase 0002: Move vm and get OK status (Already Moved)
+- &vm_move
+ name: Move VM (OK)
+ vmware_guest_move:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ name: '{{ virtual_machines[0].name }}'
+ dest_folder: '{{ dest_folder.result.path }}'
+ register: vm_info_0002
+
+- debug:
+ msg: "{{ vm_info_0001 }}"
+
+- debug:
+ msg: "{{ vm_info_0002 }}"
+
+- name: Make sure changes are done
+ assert:
+ that:
+ - vm_info_0001.changed
+ - not vm_info_0002.changed
+
+- <<: *vm_move
+ name: Move VM in check mode
+ check_mode: true
+ register: vm_move_0003
+
+- name: Make sure changes are not made in check mode
+ assert:
+ that:
+ - vm_move_0003.changed
+
+- name: Delete the f1 VM folder
+ vcenter_folder:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ dc1 }}'
+ folder_name: 'f1'
+ folder_type: vm
+ state: absent
+ validate_certs: false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml
new file mode 100644
index 00000000..cb70cbbd
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml
@@ -0,0 +1,537 @@
+# Test code for the vmware_guest_network module
+# Copyright: (c) 2019, Diane Wang (Tomorrow9) <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_dvs_portgroup: true
+ setup_dvswitch: true
+
+- name: Create VMs
+ community.vmware.vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ folder: '/DC0/vm/F0'
+ name: test_vm1
+ state: poweredon
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ version: 13
+ memory_mb: 1024
+ num_cpus: 1
+ scsi: paravirtual
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- community.vmware.vmware_guest_tools_wait:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ timeout: 600
+ validate_certs: false
+ name: test_vm1
+
+- name: gather network adapters' facts of the virtual machine
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ gather_network_info: true
+ register: netadapter_info
+
+- debug: var=netadapter_info
+
+- name: get number of existing network adapters
+ set_fact:
+ netadapter_num: "{{ netadapter_info.network_data | length }}"
+
+- name: add new network adapters to virtual machine
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "{{ item.network_name }}"
+ device_type: "{{ item.device_type }}"
+ mac_address: "{{ item.mac_address }}"
+ connected: "{{ item.connected }}"
+ state: present
+ loop:
+ - network_name: "VM Network"
+ device_type: e1000e
+ mac_address: "aa:50:56:58:59:60"
+ connected: true
+ - network_name: "VM Network"
+ device_type: vmxnet3
+ mac_address: "aa:50:56:58:59:61"
+ connected: true
+ register: add_netadapter
+
+- debug: var=add_netadapter
+
+- name: assert the new network adapters were added to VM
+ assert:
+ that:
+ - add_netadapter is changed
+ - "{{ add_netadapter.results[1].network_info | length | int }} == {{ netadapter_num | int + 2 }}"
+
+- name: delete one specified network adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ mac_address: "aa:50:56:58:59:60"
+ state: absent
+ register: del_netadapter
+
+- debug: var=del_netadapter
+
+- name: assert the network adapter was removed
+ assert:
+ that:
+ - del_netadapter is changed
+ - "{{ del_netadapter.network_info | length | int }} == {{ netadapter_num | int + 1 }}"
+
+- name: get instance uuid of virtual machines
+ community.vmware.vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ datacenter: '{{ dc1 }}'
+ register: guest_info
+
+- set_fact: vm1_instance_uuid="{{ guest_info['instance']['instance_uuid'] }}"
+
+- name: add new network adapters to virtual machine with instance uuid
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ uuid: '{{ vm1_instance_uuid }}'
+ use_instance_uuid: true
+ network_name: "VM Network"
+ device_type: e1000e
+ mac_address: "bb:50:56:58:59:60"
+ connected: true
+ register: add_netadapter_instanceuuid
+
+- debug: var=add_netadapter_instanceuuid
+
+- name: assert the new network adapters were added to VM
+ assert:
+ that:
+ - add_netadapter_instanceuuid is changed
+ - "{{ add_netadapter_instanceuuid.network_info | length | int }} == {{ netadapter_num | int + 2 }}"
+
+- name: delete one specified network adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ mac_address: "bb:50:56:58:59:60"
+ state: absent
+ register: del_netadapter
+
+- name: assert the network adapter was removed
+ assert:
+ that:
+ - del_netadapter is changed
+ - "{{ del_netadapter.network_info | length | int }} == {{ netadapter_num | int + 1 }}"
+
+- name: delete again one specified network adapter (idempotency)
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ mac_address: "bb:50:56:58:59:60"
+ state: absent
+ register: del_again_netadapter
+
+- debug: var=del_again_netadapter
+
+- name: assert no change (idempotency)
+ assert:
+ that:
+ - not (del_again_netadapter is changed)
+ - "{{ del_again_netadapter.network_info | length | int }} == {{ netadapter_num | int + 1 }}"
+
+- name: disable DirectPath I/O on a Vmxnet3 adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "test_vm1"
+ state: present
+ mac_address: "aa:50:56:58:59:61"
+ directpath_io: false
+ register: disable_directpath_io
+
+- debug: var=disable_directpath_io
+
+- name: enable DirectPath I/O on a Vmxnet3 adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "test_vm1"
+ state: present
+ mac_address: "aa:50:56:58:59:61"
+ directpath_io: true
+ register: enable_directpath_io
+
+- debug: var=enable_directpath_io
+
+- name: disconnect one specified network adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ state: present
+ mac_address: "aa:50:56:58:59:61"
+ connected: false
+ register: disc_netadapter
+
+- debug: var=disc_netadapter
+
+- name: assert the network adapter was disconnected
+ assert:
+ that:
+ - disc_netadapter is changed
+ - "{{ disc_netadapter.network_info[netadapter_num | int]['connected'] }} == false"
+
+- name: Check if network does not exists
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: non-existing-nw
+ mac_address: "aa:50:56:11:22:33"
+ state: present
+ register: no_nw_details
+ ignore_errors: true
+
+- debug: var=no_nw_details
+
+- name: Check if network does not exists
+ assert:
+ that:
+ - not (no_nw_details is changed)
+ - no_nw_details.failed
+
+- name: Change portgroup to dvPortgroup
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "{{ dvpg1 }}"
+ label: "Network adapter 1"
+ connected: false
+ start_connected: true
+ state: present
+ register: change_netaddr_dvp
+
+- debug: var=change_netaddr_dvp
+
+- name: Check changed to dvPortgroup from PortGroup
+ assert:
+ that:
+ - change_netaddr_dvp.changed is sameas true
+
+- name: Change portgroup to dvPortgroup
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "{{ dvpg1 }}"
+ label: "Network adapter 1"
+ connected: false
+ start_connected: true
+ state: present
+ register: change_netaddr_dvp
+
+- debug: var=change_netaddr_dvp
+
+- name: Check not changed of dvPortgroup
+ assert:
+ that:
+ - change_netaddr_dvp.changed is sameas false
+
+- name: Change dvPortgroup to PortGroup
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "VM Network"
+ label: "Network adapter 1"
+ connected: false
+ start_connected: true
+ state: present
+ register: change_netaddr_pg
+
+- debug: var=change_netaddr_pg
+
+- name: Check changed to dvPortgroup from PortGroup
+ assert:
+ that:
+ - change_netaddr_pg.changed is sameas true
+ - change_netaddr_pg.network_info[0].network_name == "VM Network"
+
+- name: Change dvPortgroup to PortGroup
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "VM Network"
+ label: "Network adapter 1"
+ connected: false
+ start_connected: true
+ state: present
+ register: change_netaddr_pg
+
+- debug: var=change_netaddr_pg
+
+- name: Check not changed of PortGroup
+ assert:
+ that:
+ - change_netaddr_pg.changed is sameas false
+ - change_netaddr_pg.network_info[0].network_name == "VM Network"
+
+# https://github.com/ansible/ansible/issues/65968
+- name: Create a network with dvPortgroup
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "{{ dvpg1 }}"
+ label: "Network adapter 2"
+ connected: true
+ start_connected: true
+ state: present
+ register: create_netaddr_pg
+
+- debug: var=create_netaddr_pg
+
+- name: Check if network is created with dvpg
+ assert:
+ that:
+ - create_netaddr_pg.changed is sameas true
+
+- name: gather network adapters' facts of the virtual machine
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ gather_network_info: true
+ register: nic_info
+
+- name: check that nic_info includes network_info
+ assert:
+ that:
+ - nic_info.network_info is defined
+
+- name: Remove all network interfaces with loop
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ mac_address: "{{ item.mac_address }}"
+ state: absent
+ loop: "{{ nic_info.network_info }}"
+
+- name: gather network adapters' facts of the virtual machine
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ gather_network_info: true
+ register: nic_info2
+
+- name: check that there's no adapters left
+ assert:
+ that:
+ - "{{ nic_info2.network_info | length | int }} == 0"
+
+- name: add new adapter(s)
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "VM Network"
+ state: present
+ register: new_nic
+
+- name: check that nic was created
+ assert:
+ that:
+ - "{{ new_nic.network_info | length | int }} > 0"
+
+- name: add new PVRDMA adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "{{ dvpg1 }}"
+ device_type: pvrdma
+ state: present
+ register: new_nic_pvrdma
+
+- name: check that PVRDMA nic was created
+ assert:
+ that:
+ - "{{ new_nic_pvrdma.network_info | length | int }} == {{ new_nic.network_info | length | int + 1 }}"
+
+- name: remove PVRDMA adapter
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ mac_address: "{{ (new_nic_pvrdma.diff.after | difference(new_nic_pvrdma.diff.before))[0] }}"
+ state: absent
+ register: remove_nic_pvrdma
+
+- name: check that PVRDMA nic was removed
+ assert:
+ that:
+ - "{{ new_nic_pvrdma.network_info | length | int - 1 }} == {{ remove_nic_pvrdma.network_info | length | int }}"
+
+# https://github.com/ansible-collections/community.vmware/issues/204
+- name: "Change a dvpg with in same DVS(integration test for 204)"
+ block:
+ - name: "Prepare the integration test for 204"
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: 204dvpg
+ num_ports: 8
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ vlan_id: 1
+ state: present
+ register: prepare_integration_test_204_result
+
+ - assert:
+ that:
+ - prepare_integration_test_204_result.changed is sameas true
+
+ - name: "Change a port group to a dvport group"
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: "{{ dvpg1 }}"
+ label: "Network adapter 1"
+ state: present
+ register: change_port_group_result
+
+ - assert:
+ that:
+ - change_port_group_result.changed is sameas true
+
+ - name: "Change a dvport group with in same DVS"
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: 204dvpg
+ label: Network adapter 1
+ state: present
+ register: change_dvport_group_result
+
+ - assert:
+ that:
+ - change_dvport_group_result.changed is sameas true
+
+ - name: "Revert a dvport group to port group"
+ community.vmware.vmware_guest_network:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ network_name: VM Network
+ label: "Network adapter 1"
+ state: present
+ register: revert_dvport_group_result
+
+ - assert:
+ that:
+ - revert_dvport_group_result.changed is sameas true
+
+ - name: "Delete a dvport group for 204 integration test"
+ community.vmware.vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: 204dvpg
+ num_ports: 8
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ vlan_id: 1
+ state: absent
+ register: delete_integration_test_204_result
+
+ - assert:
+ that:
+ - delete_integration_test_204_result.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml
new file mode 100644
index 00000000..04847096
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml
@@ -0,0 +1,87 @@
+# Test code for the vmware_guest_powerstate module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Create a VM with the state poweredoff
+ community.vmware.vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ folder: '{{ f0 }}'
+ name: test_vm1
+ state: poweredoff
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ memory_mb: 128
+ num_cpus: 1
+ scsi: paravirtual
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- name: set state to poweroff the first VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ folder: '{{ f0 }}/' # Test with a trailing / because of issue 1238
+ state: powered-off
+ register: poweroff_d1_c1_f0
+
+- debug:
+ var: poweroff_d1_c1_f0
+
+- name: make sure change was made
+ assert:
+ that:
+ - not (poweroff_d1_c1_f0 is changed)
+
+- name: set state to poweroff the first VM with datacenter
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: test_vm1
+ folder: '{{ f0 }}'
+ state: powered-off
+ register: poweroff_d1_c1_f0_datacenter
+
+- name: make sure change was made
+ assert:
+ that:
+ - not (poweroff_d1_c1_f0_datacenter is changed)
+
+- name: Set a schedule task for first VM
+ community.vmware.vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ folder: '{{ f0 }}'
+ scheduled_at: "10/10/2030 10:10"
+ state: powered-on
+ register: poweron_d1_c1_f0
+
+- name: Check that task is schedule
+ assert:
+ that:
+ - poweron_d1_c1_f0 is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/tasks/main.yml
new file mode 100644
index 00000000..d80e497e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_register_operation/tasks/main.yml
@@ -0,0 +1,359 @@
+# Test code for the vmware_guest_register_operation module
+# Copyright: (c) 2019, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_cluster: true
+ setup_virtualmachines: true
+ setup_resource_pool: true
+
+- name: gather facts of vm
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ name: "{{ virtual_machines[0].name }}"
+ register: vm_facts
+
+- name: get a vm vmx file path
+ set_fact: vm_vmx_file_path="{{ vm_facts.instance.hw_files[0] }}"
+
+- name: Powered off the vm
+ vmware_guest_powerstate:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: /vm
+ name: "{{ virtual_machines[0].name }}"
+ state: powered-off
+
+- name: Unregister VM from inventory with check_mode
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ state: absent
+ check_mode: true
+ register: unregister_vm_inventory_check_mode_result
+
+- name: Make sure the changed occurred
+ assert:
+ that:
+ - unregister_vm_inventory_check_mode_result.changed is sameas true
+
+- name: Unregister VM from inventory
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ state: absent
+ register: unregister_vm_inventory_result1
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | map(attribute='guest_name')
+ | list
+ | length == 0
+ - unregister_vm_inventory_result1.changed is sameas true
+
+- assert:
+ that:
+ - item.guest_name != virtual_machines[0].name
+ loop: "{{ vms.virtual_machines }}"
+
+- name: Register VM to inventory with check_mode
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ esxi_hostname: "{{ esxi1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ path: "{{ vm_vmx_file_path }}"
+ state: present
+ check_mode: true
+ register: register_vm_inventory_check_mode_result
+
+- name: Make sure the changed occurred
+ assert:
+ that:
+ - register_vm_inventory_check_mode_result.changed is sameas true
+
+- name: Register VM to inventory
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ esxi_hostname: "{{ esxi1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ path: "{{ vm_vmx_file_path }}"
+ state: present
+ register: register_vm_inventory_result
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | selectattr('esxi_hostname', 'equalto', esxi1)
+ | map(attribute='guest_name')
+ | list
+ | length == 1
+ - register_vm_inventory_result.changed is sameas true
+
+- name: Unregister VM from inventory
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ state: absent
+ register: unregister_vm_inventory_result2
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | map(attribute='guest_name')
+ | list
+ | length == 0
+ - unregister_vm_inventory_result2.changed is sameas true
+
+- name: Register VM in Cluster with check_mode
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ path: "{{ vm_vmx_file_path }}"
+ state: present
+ check_mode: true
+ register: register_vm_cluster_check_mode_result
+
+- name: Make sure the changed occurred
+ assert:
+ that:
+ - register_vm_cluster_check_mode_result.changed is sameas true
+
+- name: Register VM in Cluster
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ path: "{{ vm_vmx_file_path }}"
+ state: present
+ register: register_vm_cluster_result
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | selectattr('cluster', 'equalto', ccr1)
+ | map(attribute='guest_name')
+ | list
+ | length == 1
+ - register_vm_cluster_result.changed is sameas true
+
+- name: Unregister VM from inventory
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ state: absent
+ register: unregister_vm_inventory_result3
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | map(attribute='guest_name')
+ | list
+ | length == 0
+ - unregister_vm_inventory_result3.changed is sameas true
+
+- name: Register VM in Resource pool with check_mode
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ resource_pool: DC0_C0_RP1
+ name: "{{ virtual_machines[0].name }}"
+ path: "{{ vm_vmx_file_path }}"
+ state: present
+ check_mode: true
+ register: register_vm_resource_pool_check_mode_result
+
+- name: Make sure the changed occurred
+ assert:
+ that:
+ - register_vm_resource_pool_check_mode_result.changed is sameas true
+
+- name: Register VM in Resource pool
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ resource_pool: DC0_C0_RP1
+ name: "{{ virtual_machines[0].name }}"
+ path: "{{ vm_vmx_file_path }}"
+ state: present
+ register: register_vm_resource_pool_result
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | map(attribute='guest_name')
+ | list
+ | length == 1
+ - register_vm_resource_pool_result.changed is sameas true
+
+- name: Gather facts of vm
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ name: "{{ virtual_machines[0].name }}"
+ register: vm_facts
+
+- name: Get a vm uuid
+ set_fact: vm_uuid="{{ vm_facts.instance.hw_product_uuid }}"
+
+- name: Unregister VM from inventory with uuid parameter
+ vmware_guest_register_operation:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "/vm"
+ cluster: "{{ ccr1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ uuid: "{{ vm_uuid }}"
+ state: absent
+ register: unregister_vm_inventory_result4
+
+- name: Gather all registered virtual machines
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: vms
+
+- assert:
+ that:
+ - >-
+ vms.virtual_machines
+ | selectattr('guest_name', 'equalto', virtual_machines[0].name)
+ | map(attribute='guest_name')
+ | list
+ | length == 0
+ - unregister_vm_inventory_result4.changed is sameas true \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/tasks/main.yml
new file mode 100644
index 00000000..70b0d3f4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_screenshot/tasks/main.yml
@@ -0,0 +1,52 @@
+# Test code for the vmware_guest_screenshot module
+# Copyright: (c) 2019, Diane Wang (Tomorrow9) <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: set VM state to powered on
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ name: "{{ virtual_machines[0].name }}"
+ state: poweredon
+
+- name: take screenshot of virtual machine's console
+ vmware_guest_screenshot:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ register: take_screenshot
+- debug: var=take_screenshot
+- name: assert the screenshot captured
+ assert:
+ that:
+ - "take_screenshot.changed == true"
+
+- name: take screenshot of virtual machine's console and download to local
+ vmware_guest_screenshot:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ local_path: "/tmp/screenshot_test.png"
+ datacenter: "{{ dc1 }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ register: take_screenshot
+- debug: var=take_screenshot
+- name: assert the screenshot captured
+ assert:
+ that:
+ - "take_screenshot.changed == true"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/aliases
new file mode 100644
index 00000000..ef436f37
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi_with_nest
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/tasks/main.yml
new file mode 100644
index 00000000..4113a706
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_sendkey/tasks/main.yml
@@ -0,0 +1,53 @@
+# Test code for the vmware_guest_sendkey module
+# Copyright: (c) 2017, Diane Wang (Tomorrow9) <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: set state to poweron the first VM
+ vmware_guest_powerstate:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: '{{ f0 }}'
+ state: powered-on
+
+- name: send keys to virtual machine
+ vmware_guest_sendkey:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ keys_send:
+ - DOWNARROW
+ - DOWNARROW
+ - ENTER
+ register: send_key
+- debug: var=send_key
+- name: assert the keys were sent to VM
+ assert:
+ that:
+ - "send_key.changed == true"
+
+- name: send string to virtual machine
+ vmware_guest_sendkey:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ string_send: "test-user"
+ register: send_string
+- debug: var=send_string
+- name: assert the string was sent to VM
+ assert:
+ that:
+ - "send_string.changed == true"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/tasks/main.yml
new file mode 100644
index 00000000..76826cf1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_serial_port/tasks/main.yml
@@ -0,0 +1,590 @@
+# Test code for the vmware_guest_serial_port Operations.
+# Copyright: (c) 2019, Anusha Hegde <anushah@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Create VM
+ vmware_guest:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: test_vm1
+ guest_id: centos64Guest
+ datacenter: "{{ dc1 }}"
+ folder: "{{ f0 }}"
+ hardware:
+ num_cpus: 1
+ memory_mb: 512
+ disk:
+ - size: 1gb
+ type: thin
+ datastore: "{{ rw_datastore }}"
+ state: present
+ register: create_vm_for_test
+
+- name: assert that changes were made
+ assert:
+ that:
+ - create_vm_for_test is changed
+
+- name: "Create a new serial port for pipe type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ register: create_serial_port_pipe_type
+
+- assert:
+ that:
+ - create_serial_port_pipe_type.changed is sameas true
+
+- name: "Create a new serial port for pipe type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ register: create_serial_port_pipe_type_idempotency_check
+
+- assert:
+ that:
+ - create_serial_port_pipe_type_idempotency_check.changed is sameas false
+
+- name: "Update serial port for pipe type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: server
+ no_rx_loss: false
+ register: update_serial_port_pipe_type
+
+- assert:
+ that:
+ - update_serial_port_pipe_type.changed is sameas true
+
+- name: "Remove serial port for pipe type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: server
+ no_rx_loss: false
+ state: absent
+ register: remove_serial_port_pipe_type
+
+- assert:
+ that:
+ - remove_serial_port_pipe_type.changed is sameas true
+
+- name: "Remove serial port for pipe type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: server
+ no_rx_loss: false
+ state: absent
+ register: remove_serial_port_pipe_type_idempotency_check
+
+- assert:
+ that:
+ - remove_serial_port_pipe_type_idempotency_check.changed is sameas false
+
+- name: "Create a new serial port for network type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: network
+ service_uri: tcp://6000
+ direction: client
+ register: create_serial_port_network_type
+
+- assert:
+ that:
+ - create_serial_port_network_type.changed is sameas true
+
+- name: "Create a new serial port for network type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: network
+ service_uri: tcp://6000
+ direction: client
+ register: create_serial_port_network_type_idempotency_check
+
+- assert:
+ that:
+ - create_serial_port_network_type_idempotency_check.changed is sameas false
+
+- name: "Update serial port for network type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: network
+ service_uri: tcp://6000
+ direction: server
+ register: update_serial_port_network_type
+
+- assert:
+ that:
+ - update_serial_port_network_type.changed is sameas true
+
+- name: "Remove serial port for network type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: network
+ service_uri: tcp://6000
+ direction: server
+ state: absent
+ register: remove_serial_network_pipe_type
+
+- assert:
+ that:
+ - remove_serial_network_pipe_type.changed is sameas true
+
+- name: "Remove serial port for network type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: network
+ service_uri: tcp://6000
+ direction: server
+ state: absent
+ register: remove_serial_port_network_type_idempotency_check
+
+- assert:
+ that:
+ - remove_serial_port_network_type_idempotency_check.changed is sameas false
+
+- name: "Create a new serial port for device type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: device
+ device_name: /dev/char/serial/uart0
+ register: create_serial_port_device_type
+
+- assert:
+ that:
+ - create_serial_port_device_type.changed is sameas true
+
+- name: "Create a new serial port for device type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: device
+ device_name: /dev/char/serial/uart0
+ register: create_serial_port_device_type_idempotency_check
+
+- assert:
+ that:
+ - create_serial_port_device_type_idempotency_check.changed is sameas false
+
+- name: "Update serial port for device type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: device
+ device_name: /dev/char/serial/uart1
+ register: update_serial_port_device_type
+
+- assert:
+ that:
+ - update_serial_port_device_type.changed is sameas true
+
+- name: "Remove serial port for device type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: device
+ device_name: /dev/char/serial/uart1
+ state: absent
+ register: remove_serial_network_device_type
+
+- assert:
+ that:
+ - remove_serial_network_device_type.changed is sameas true
+
+- name: "Remove serial port for device type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: device
+ device_name: /dev/char/serial/uart1
+ state: absent
+ register: remove_serial_port_device_type_idempotency_check
+
+- assert:
+ that:
+ - remove_serial_port_device_type_idempotency_check.changed is sameas false
+
+- name: "Create a new serial port for file type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: file
+ file_path: "[{{ rw_datastore }}] file1"
+ register: create_serial_port_file_type
+
+- assert:
+ that:
+ - create_serial_port_file_type.changed is sameas true
+
+- name: "Create a new serial port for file type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: file
+ file_path: "[{{ rw_datastore }}] file1"
+ register: create_serial_port_file_type_idempotency_check
+
+- assert:
+ that:
+ - create_serial_port_file_type_idempotency_check.changed is sameas false
+
+- name: "Update serial port for file type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: file
+ file_path: "[{{ rw_datastore }}] file2"
+ register: update_serial_port_file_type
+
+- assert:
+ that:
+ - update_serial_port_file_type.changed is sameas true
+
+- name: "Remove serial port for file type"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: file
+ file_path: "[{{ rw_datastore }}] file2"
+ state: absent
+ register: remove_serial_network_file_type
+
+- assert:
+ that:
+ - remove_serial_network_file_type.changed is sameas true
+
+- name: "Remove serial port for file type(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: file
+ file_path: "[{{ rw_datastore }}] file2"
+ state: absent
+ register: remove_serial_port_file_type_idempotency_check
+
+- assert:
+ that:
+ - remove_serial_port_file_type_idempotency_check.changed is sameas false
+
+- name: "Create a new serial port for pipe type using yield_on_poll param"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ yield_on_poll: true
+ register: create_serial_port_pipe_type_using_yield_on_poll
+
+- assert:
+ that:
+ - create_serial_port_pipe_type_using_yield_on_poll.changed is sameas true
+
+- name: "Create a new serial port for pipe type using yield_on_poll param(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ yield_on_poll: true
+ register: create_serial_port_pipe_type_using_yield_on_poll_idempotency_check
+
+- assert:
+ that:
+ - create_serial_port_pipe_type_using_yield_on_poll_idempotency_check.changed is sameas false
+
+- name: "Update serial port for pipe type using yield_on_poll param"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ yield_on_poll: false
+ register: update_serial_port_pipe_type_using_yield_on_poll
+
+- assert:
+ that:
+ - update_serial_port_pipe_type_using_yield_on_poll.changed is sameas true
+
+- name: "Remove serial port for pipe type using yield_on_poll param"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ yield_on_poll: false
+ state: absent
+ register: remove_serial_port_pipe_type_using_yield_on_poll
+
+- assert:
+ that:
+ - remove_serial_port_pipe_type_using_yield_on_poll.changed is sameas true
+
+- name: "Remove serial port for pipe type using yield_on_poll param(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: pipe
+ pipe_name: test_pipe
+ endpoint: client
+ no_rx_loss: true
+ yield_on_poll: false
+ state: absent
+ register: remove_serial_port_pipe_type_using_yield_on_poll_idempotency_check
+
+- assert:
+ that:
+ - remove_serial_port_pipe_type_using_yield_on_poll_idempotency_check.changed is sameas false
+
+- name: "Create multiple serial ports with Backing type - network, pipe, device and file"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: 'network'
+ direction: 'client'
+ service_uri: 'tcp://6000'
+ yield_on_poll: true
+ - type: 'pipe'
+ pipe_name: 'serial_pipe'
+ endpoint: 'client'
+ no_rx_loss: true
+ - type: 'device'
+ device_name: '/dev/char/serial/uart0'
+ - type: 'file'
+ file_path: '[{{ rw_datastore }}] file1'
+ yield_on_poll: true
+ register: create_multiple_ports
+
+- name: assert that changes were made
+ assert:
+ that:
+ - create_multiple_ports.changed is sameas true
+
+- name: "Create multiple serial ports with Backing type - network, pipe, device and file(idempotency check)"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "test_vm1"
+ backings:
+ - type: 'network'
+ direction: 'client'
+ service_uri: 'tcp://6000'
+ yield_on_poll: true
+ - type: 'pipe'
+ pipe_name: 'serial_pipe'
+ endpoint: 'client'
+ no_rx_loss: true
+ - type: 'device'
+ device_name: '/dev/char/serial/uart0'
+ - type: 'file'
+ file_path: '[{{ rw_datastore }}] file1'
+ yield_on_poll: true
+ register: create_multiple_ports_idempotency_check
+
+- name: assert that changes were made
+ assert:
+ that:
+ - create_multiple_ports_idempotency_check.changed is sameas false
+
+- name: "Modify existing serial port with Backing type - network"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: 'test_vm1'
+ backings:
+ - type: 'network'
+ state: 'present'
+ direction: 'server'
+ service_uri: 'tcp://6000'
+ register: modify_network_port
+
+- name: assert that changes were made
+ assert:
+ that:
+ - modify_network_port.changed is sameas true
+
+- name: "Remove serial port with Backing type - pipe"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: 'test_vm1'
+ backings:
+ - type: 'pipe'
+ pipe_name: 'serial_pipe'
+ state: 'absent'
+ register: remove_pipe_port
+
+- name: assert that changes were made
+ assert:
+ that:
+ - remove_pipe_port.changed is sameas true
+
+- name: "Remove all serial ports"
+ vmware_guest_serial_port:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: 'test_vm1'
+ backings:
+ - type: network
+ service_uri: 'tcp://6000'
+ state: absent
+ - type: device
+ device_name: '/dev/char/serial/uart0'
+ state: absent
+ - type: file
+ file_path: '[{{ rw_datastore }}] file1'
+ state: absent
+ register: remove_all_serial_ports
+
+- assert:
+ that:
+ - remove_all_serial_ports.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
new file mode 100644
index 00000000..622a69c7
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
@@ -0,0 +1,172 @@
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+# Test0001: Try to delete the non-existent snapshot
+- name: 0001 - Delete non-existent snapshot
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: absent
+ snapshot_name: snap_a
+
+# Test0002: Create two snapshots
+- name: 0002 - Create snapshot
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: "snap_{{item}}"
+ description: "snap named {{item}}"
+ with_items:
+ - a
+ - b
+
+# Test0003: Reanme a to c
+- name: 0003 - Rename snapshot
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: snap_a
+ new_snapshot_name: snap_c
+
+# Test0004: Create snap_a again
+- name: 0004 - Re-create snapshot a
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: snap_a
+ description: "snap named a"
+
+# Test0005: Change description of snap_c
+- name: 0005 - Change description of snap_c
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: snap_c
+ new_description: "renamed to snap_c from snap_a"
+
+# Test0006: Delete snap_b with child remove
+- name: 0006 - Delete snap_b with child remove
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: absent
+ snapshot_name: snap_b
+ remove_children: true
+
+# Test0007: Delete all snapshots
+- name: 0007 - Delete all snapshots
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: remove_all
+
+# Test0008: Create snap_a again and revert to it
+- name: 0008 - Re-create snapshot a
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: snap_a
+ description: "snap named a"
+
+- name: 0008 - Revert to snap_a
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: revert
+ snapshot_name: snap_a
+
+# Test0009: Create snap_a and check in result
+- name: 0009 - create snapshot a
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: snap_a
+ description: "snap named a"
+ register: snapshot_details
+
+- debug: var=snapshot_details
+
+- name: Check if snapshot details available or not
+ assert:
+ that:
+ - "snapshot_details['msg'] == 'Snapshot named [snap_a] already exists and is current.'"
+
+# Test0011: Failure sceanrios - when name and UUID is not specified
+- name: 0011 - name and UUID is missing
+ vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ state: present
+ snapshot_name: snap_a
+ description: "snap named a"
+ register: snapshot_failure_details
+ ignore_errors: true
+
+- name: Check if error is shown
+ assert:
+ that:
+ - "'one of the following is required: name, uuid' in snapshot_failure_details['msg']"
+ - "snapshot_failure_details.changed == false"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/tasks/main.yml
new file mode 100644
index 00000000..eacb50af
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot_info/tasks/main.yml
@@ -0,0 +1,27 @@
+# Test code for the vmware_host_dns_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Gather snapshot info about given virtual machine
+ vmware_guest_snapshot_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ register: vm_snapshot_info
+
+- debug: var=vm_snapshot_info
+
+- assert:
+ that:
+ - '"guest_snapshots" in vm_snapshot_info'
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/tasks/main.yml
new file mode 100644
index 00000000..fb0fbfa9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_storage_policy/tasks/main.yml
@@ -0,0 +1,209 @@
+# Test code for the vmware_guest_storage_policy module.
+# Copyright: (c) 2020, @tgates81 <tgates81@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Run tests and clean up
+ block:
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+ - name: "Setup: find existing storage profile(s) for later rollback"
+ vmware_vm_storage_policy_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: existing_profiles
+
+ - name: "Setup: Create category"
+ vmware_category:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ category_name: "{{ category }}"
+ category_cardinality: "multiple"
+ state: "present"
+ register: category_create
+
+ - name: "Setup: Set category id"
+ set_fact:
+ category_id: "{{ category_create['category_results']['category_id'] }}"
+
+ - name: "Setup: Create tag"
+ vmware_tag:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ tag_name: "{{ tag }}"
+ category_id: "{{ category_id }}"
+ state: "present"
+ register: tag_create
+
+ - name: "Setup: Create vSphere tag-based storage policy: {{ storage_policy }}"
+ vmware_vm_storage_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "{{ storage_policy }}"
+ description: "test storage policy for vmware_guest_storage_policy"
+ tag_category: "{{ category }}"
+ tag_name: "{{ tag }}"
+ tag_affinity: true
+ state: "present"
+ register: new_sp
+
+ - name: "001: Assign storage policy to VM check_mode test"
+ vmware_guest_storage_policy: &vm_home_args
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "{{ virtual_machines[0].name }}"
+ vm_home: "{{ storage_policy }}"
+ register: vm_home_sp_cm
+ check_mode: true
+
+ - name: "001: assert that changes were made"
+ assert:
+ that:
+ - vm_home_sp_cm is changed
+
+ - name: "001: assert that changed_policies.vm_home is properly set"
+ assert:
+ that:
+ - vm_home_sp_cm.changed_policies.vm_home == storage_policy
+
+ - name: "002: Assign storage policy to VM"
+ vmware_guest_storage_policy:
+ <<: *vm_home_args
+ register: vm_home_sp
+
+ - name: "002: assert that changes were made"
+ assert:
+ that:
+ - vm_home_sp is changed
+
+ - name: "002: assert that changed_policies.vm_home is properly set"
+ assert:
+ that:
+ - vm_home_sp.changed_policies.vm_home == storage_policy
+
+
+ - name: "003: Assign storage policy to VM idempotence test"
+ vmware_guest_storage_policy:
+ <<: *vm_home_args
+ register: vm_home_sp_idp
+
+ - name: "003: assert that changes were not made"
+ assert:
+ that:
+ - vm_home_sp_idp is not changed
+
+ - name: "003: assert that changed_policies.vm_home is not set"
+ assert:
+ that:
+ - vm_home_sp_idp.changed_policies.vm_home == ""
+
+ - name: "004: Assign storage policy to controller number {{ controller_number}} disk unit {{ unit_number }} check_mode test"
+ vmware_guest_storage_policy: &disk_args
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "{{ virtual_machines[0].name }}"
+ disk:
+ - unit_number: "{{ unit_number }}"
+ controller_number: "{{ controller_number }}"
+ policy: "{{ storage_policy }}"
+ register: disk_sp_cm
+ check_mode: true
+
+ - name: "004: assert that changes were made"
+ assert:
+ that:
+ - disk_sp_cm is changed
+
+ - name: "004: assert that changed_policies.disk is properly set"
+ assert:
+ that:
+ - disk_sp_cm.changed_policies.disk[0].unit_number == unit_number
+ - disk_sp_cm.changed_policies.disk[0].controller_number == controller_number
+ - disk_sp_cm.changed_policies.disk[0].policy == storage_policy
+
+ - name: "005: Assign storage policy to disk unit {{ unit_number }}"
+ vmware_guest_storage_policy:
+ <<: *disk_args
+ register: disk_sp
+
+ - name: "005: assert that changes were made"
+ assert:
+ that:
+ - disk_sp is changed
+
+ - name: "005: assert that changed_policies.disk is properly set"
+ assert:
+ that:
+ - disk_sp.changed_policies.disk[0].unit_number == unit_number
+ - disk_sp.changed_policies.disk[0].controller_number == controller_number
+ - disk_sp.changed_policies.disk[0].policy == storage_policy
+
+ - name: "006: Assign storage policy to disk unit {{ unit_number }} idempotence test"
+ vmware_guest_storage_policy:
+ <<: *disk_args
+ register: disk_sp_idp
+
+ - name: "006: assert that changes were not made"
+ assert:
+ that:
+ - disk_sp_idp is not changed
+
+ - name: "006: assert that changed_policies.disk is not set"
+ assert:
+ that:
+ - disk_sp_idp.changed_policies.disk == []
+
+ always:
+ - name: "Cleanup: Delete Tag"
+ vmware_tag:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ tag_name: "{{ tag }}"
+ category_id: "{{ category_id }}"
+ state: "absent"
+ register: delete_tag
+
+ - name: "Cleanup: Delete Category"
+ vmware_category:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ category_name: "{{ category }}"
+ state: "absent"
+ register: delete_category
+
+ - name: "Cleanup: Remove storage policy"
+ vmware_vm_storage_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "{{ storage_policy }}"
+ state: "absent"
+ register: policy_delete
+
+ vars:
+ storage_policy: "vm_guest_storage_profile_policy001"
+ category: "vm_guest_storage_profile_cat001"
+ tag: "vm_guest_storage_profile_tag001"
+ unit_number: 0
+ controller_number: 0
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/tasks/main.yml
new file mode 100644
index 00000000..d16fd2d0
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_info/tasks/main.yml
@@ -0,0 +1,51 @@
+# Test code for the vmware_guest_tools_info module
+# Copyright: (c) 2019, Diane Wang (Tomorrow9) <dianew@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: get instance uuid of virtual machine
+ vmware_guest_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ register: guest_info
+- debug: var=guest_info
+
+- name: get VMware tools info of virtual machine by instance uuid
+ vmware_guest_tools_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ uuid: "{{ guest_info['instance']['instance_uuid'] }}"
+ use_instance_uuid: true
+ register: vmtools_info
+- debug: var=vmtools_info
+- name: assert VMware tools info returned
+ assert:
+ that:
+ - "vmtools_info.vmtools_info.vm_tools_install_status != ''"
+
+- name: get VMware tools info of virtual machine by name
+ vmware_guest_tools_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ datacenter: "{{ dc1 }}"
+ register: vmtools_info
+- debug: var=vmtools_info
+- name: assert VMware tools info returned
+ assert:
+ that:
+ - "vmtools_info.vmtools_info.vm_tools_install_status != ''"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml
new file mode 100644
index 00000000..2b3a2326
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml
@@ -0,0 +1,45 @@
+# Test code for the vmware_guest_tools_wait module.
+# Copyright: (c) 2017 Philippe Dellaert <philippe@dellaert.org>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_dvs_portgroup: true
+ setup_dvswitch: true
+
+- name: Create VMs
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ folder: '/DC0/vm/F0'
+ name: test_vm1
+ state: poweredon
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ version: 11
+ memory_mb: 1024
+ num_cpus: 1
+ scsi: paravirtual
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ networks:
+ - name: VM Network
+
+- vmware_guest_tools_wait:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ timeout: 800
+ validate_certs: false
+ name: test_vm1
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host/aliases
new file mode 100644
index 00000000..d1d14d22
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_2esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host/tasks/main.yml
new file mode 100644
index 00000000..2f83dc29
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host/tasks/main.yml
@@ -0,0 +1,253 @@
+# Test code for the vmware_host module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+# Testcase: Add Host
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+# NOTE: prepare_vmware_tests should have already done that
+- name: Add first ESXi Host to vCenter
+ vmware_host:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: '{{ esxi1 }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ state: present
+ validate_certs: false
+ register: readd_host_result
+
+- name: Add first ESXi Host to vCenter (again)
+ vmware_host:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: '{{ esxi1 }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ state: present
+ validate_certs: false
+ register: readd_host_result
+
+- name: ensure precend task didn't changed anything
+ assert:
+ that:
+ - not ( readd_host_result is changed)
+
+- name: add second host via add_or_reconnect
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi2 }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: "{{ ccr1 }}"
+ state: add_or_reconnect
+ register: add_or_reconnect_host_result
+- name: ensure host system is present
+ assert:
+ that:
+ - add_or_reconnect_host_result is changed
+
+- name: disconnect host 2
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi2 }}'
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: "{{ ccr1 }}"
+ fetch_ssl_thumbprint: false
+ state: absent
+
+- name: remove host again
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi2 }}'
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: "{{ ccr1 }}"
+ state: absent
+ register: reremove_host_result
+- name: ensure precend task didn't changed anything
+ assert:
+ that:
+ - not ( reremove_host_result is changed)
+
+
+## Testcase: Add Host to folder
+- name: Create host folder
+ vcenter_folder:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder_name: "Staging"
+ folder_type: host
+ state: present
+ register: folder_results
+
+- debug: msg="{{ folder_results }}"
+
+- name: ensure folder is present
+ assert:
+ that:
+ - folder_results.changed
+
+- name: Add host to folder in check mode
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi2 }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ datacenter_name: "{{ dc1 }}"
+ folder_name: "/{{ dc1 }}/host/Staging"
+ state: present
+ register: add_host_to_folder_result
+ check_mode: true
+
+- name: ensure host system is not present
+ assert:
+ that:
+ - add_host_to_folder_result is changed
+
+- name: Add host to folder
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi2 }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ datacenter_name: "{{ dc1 }}"
+ folder_name: "/{{ dc1 }}/host/Staging"
+ state: present
+ register: add_host_to_folder_result
+
+- name: ensure host system is present
+ assert:
+ that:
+ - add_host_to_folder_result is changed
+
+- name: reconnect host
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi2 }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ datacenter_name: "{{ dc1 }}"
+ cluster_name: "{{ ccr1 }}"
+ state: reconnect
+ register: reconnect_host_result
+
+- name: ensure host system has been reconnected
+ assert:
+ that:
+ - reconnect_host_result is changed
+ # it would be a good idea to check the events on the host to see the reconnect
+ # https://github.com/vmware/govmomi/blob/master/govc/USAGE.md#events
+ # "govc events ..." need to be callable from
+ # https://github.com/ansible/vcenter-test-container/flask_control.py
+
+## Testcase: Disconnect Host
+- name: disconnect host with check_mode
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: disconnected
+ check_mode: true
+ register: disconnect_host_check_mode_result
+
+- name: ensure to occur the changed
+ assert:
+ that:
+ - disconnect_host_check_mode_result.changed is true
+
+- name: disconnect host
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: disconnected
+ register: disconnect_host_result
+
+- name: ensure host system has been disconnected
+ assert:
+ that:
+ - disconnect_host_result.changed is true
+
+- name: disconnect host(idempotency)
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: disconnected
+ register: disconnect_host_idempotency_result
+
+- name: ensure not to occur the changed
+ assert:
+ that:
+ - disconnect_host_idempotency_result.changed is false
+
+- name: disconnect host with check_mode again
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: disconnected
+ check_mode: true
+ register: disconnect_host_check_mode_again_result
+
+- name: ensure not to occur the changed
+ assert:
+ that:
+ - disconnect_host_check_mode_again_result.changed is false
+
+- name: reconnect host
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: reconnect
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml
new file mode 100644
index 00000000..9d3352e6
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml
@@ -0,0 +1,39 @@
+# Test code for the vmware_host_acceptance module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Change acceptance level of given hosts
+ vmware_host_acceptance:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ acceptance_level: community
+ state: present
+ register: host_acceptance_info
+- debug: var=host_acceptance_info
+- assert:
+ that:
+ - host_acceptance_info.facts is defined
+
+- name: Change acceptance level of given hosts in check mode
+ vmware_host_acceptance:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ acceptance_level: community
+ state: present
+ register: host_acceptance_info_check_mode
+ check_mode: true
+- debug: var=host_acceptance_info_check_mode
+- assert:
+ that:
+ - host_acceptance_info_check_mode.facts is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/aliases
new file mode 100644
index 00000000..ad593838
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/tasks/main.yml
new file mode 100644
index 00000000..19236c5b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_active_directory/tasks/main.yml
@@ -0,0 +1,85 @@
+# Test code for the vmware_host_active_directory module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Active Directory domain isn't available
+
+- when: active_directory_domain is defined
+ block:
+ - name: Join an AD domain in check mode
+ vmware_host_active_directory:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ad_domain: '{{ active_directory_domain }}'
+ ad_user: '{{ active_directory_user }}'
+ ad_password: '{{ active_directory_password }}'
+ ad_state: present
+ validate_certs: false
+ register: host_active_directory_info_check_mode
+ check_mode: true
+
+ - debug: var=host_active_directory_info_check_mode
+
+ - assert:
+ that:
+ - host_active_directory_info_check_mode is defined
+ - host_active_directory_info_check_mode.changed
+
+ - name: Join an AD domain
+ vmware_host_active_directory:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ad_domain: example.local
+ ad_user: adjoin
+ ad_password: Password123$
+ ad_state: present
+ validate_certs: false
+ register: host_active_directory_info
+ ignore_errors: true
+
+ - debug: var=host_active_directory_info
+
+ - assert:
+ that:
+ - host_active_directory_info is defined
+ - host_active_directory_info.changed
+
+ - name: Leave AD domain in check mode
+ vmware_host_active_directory:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ad_state: absent
+ validate_certs: false
+ register: host_active_directory_info_2_check_mode
+ check_mode: true
+
+ - debug: var=host_active_directory_info_2_check_mode
+
+ - assert:
+ that:
+ - host_active_directory_info_2_check_mode is defined
+ - host_active_directory_info_2_check_mode.changed
+
+ - name: Leave AD domain
+ vmware_host_active_directory:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ad_state: absent
+ validate_certs: false
+ register: host_active_directory_info_2
+ ignore_errors: true
+
+ - debug: var=host_active_directory_info_2
+
+ - assert:
+ that:
+ - host_active_directory_info_2 is defined
+ - host_active_directory_info_2.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/aliases
new file mode 100644
index 00000000..e40a2181
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+skip/python2.6
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/esxi_auto_start_ops.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/esxi_auto_start_ops.yml
new file mode 100644
index 00000000..d2e6d8cb
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/esxi_auto_start_ops.yml
@@ -0,0 +1,368 @@
+# Test code for the vmware_vmware_host_auto_start.
+# Copyright: (c) 2019, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+
+- name: Update enabled param of autoStart defaults parameters for ESXi.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ system_defaults:
+ enabled: true
+ register: changed_system_defaults_result
+
+- name: Check return parameters.
+ assert:
+ that:
+ - changed_system_defaults_result.system_defaults_config.enabled is sameas true
+ - changed_system_defaults_result.system_defaults_config.start_delay == 120
+ - changed_system_defaults_result.system_defaults_config.stop_action == 'powerOff'
+ - changed_system_defaults_result.system_defaults_config.start_delay == 120
+ - changed_system_defaults_result.system_defaults_config.wait_for_heartbeat is sameas false
+
+- name: Gather facts for autoStart defaults parameters from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check system default parameters.
+ assert:
+ that:
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.enabled is sameas true
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.startDelay == 120
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopAction == 'powerOff'
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopDelay == 120
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.waitForHeartbeat is sameas false
+
+- name: Update all param of autoStart defaults parameters for ESXi.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ system_defaults:
+ enabled: true
+ start_delay: 200
+ stop_action: guestShutdown
+ stop_delay: 300
+ wait_for_heartbeat: true
+
+- name: Gather facts for autoStart defaults parameters from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check system default parameters.
+ assert:
+ that:
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.enabled is sameas true
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.startDelay == 200
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopAction == 'guestShutdown'
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopDelay == 300
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.waitForHeartbeat is sameas true
+
+- name: Gather facts summary propertie from VM.
+ vmware_guest_info:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ datacenter: ha-datacenter
+ name: test_vm1
+ schema: vsphere
+ properties:
+ - summary.vm
+ register: vm_summary_result
+
+- name: Update start_action parameters of autoStart powerInfo parameters for VM.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm1
+ power_info:
+ start_action: powerOn
+ register: changed_vm_power_info_result
+
+- name: Check return parameters.
+ assert:
+ that:
+ - changed_vm_power_info_result.power_info_config.start_action == 'powerOn'
+ - changed_vm_power_info_result.power_info_config.start_delay == -1
+ - changed_vm_power_info_result.power_info_config.start_order == -1
+ - changed_vm_power_info_result.power_info_config.stop_action == 'systemDefault'
+ - changed_vm_power_info_result.power_info_config.stop_delay == -1
+ - changed_vm_power_info_result.power_info_config.wait_for_heartbeat == 'systemDefault'
+
+- name: Gather facts for autoStart config of VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check VM powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == -1
+ - item.startOrder == -1
+ - item.stopAction == 'systemDefault'
+ - item.stopDelay == -1
+ - item.waitForHeartbeat == 'systemDefault'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Update all parameters of autoStart powerInfo parameters for VM.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm1
+ power_info:
+ start_action: powerOn
+ start_delay: 200
+ start_order: 1
+ stop_action: suspend
+ stop_delay: 250
+ wait_for_heartbeat: "yes"
+
+- name: Gather facts for autoStart config of VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 200
+ - item.startOrder == 1
+ - item.stopAction == 'suspend'
+ - item.stopDelay == 250
+ - item.waitForHeartbeat == 'yes'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Gather facts summary propertie from VM.
+ vmware_guest_info:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ datacenter: ha-datacenter
+ name: test_vm2
+ schema: vsphere
+ properties:
+ - summary.vm
+ register: vm_summary_result
+
+- name: Update all parameters of autoStart powerInfo parameters for other VM.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm2
+ power_info:
+ start_action: powerOn
+ start_delay: 100
+ start_order: 2
+ stop_action: suspend
+ stop_delay: 20
+ wait_for_heartbeat: "no"
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 100
+ - item.startOrder == 2
+ - item.stopAction == 'suspend'
+ - item.stopDelay == 20
+ - item.waitForHeartbeat == 'no'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Check the operation of check_mode and diff.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm2
+ power_info:
+ start_action: powerOn
+ start_delay: 100
+ start_order: -1
+ stop_action: suspend
+ stop_delay: 20
+ check_mode: true
+ diff: true
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 100
+ - item.startOrder == 2
+ - item.stopAction == 'suspend'
+ - item.stopDelay == 20
+ - item.waitForHeartbeat == 'no'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Gather facts instanceUuid and moid propertie from VM.
+ vmware_guest_info:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ name: test_vm2
+ schema: vsphere
+ properties:
+ - config.instanceUuid
+ - _moId
+ register: vm_instanceUuid_and_moid_result
+
+- name: Update all parameters of autoStart powerInfo parameters for VM using instanceUuid via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ uuid: "{{ vm_instanceUuid_and_moid_result.instance.config.instanceUuid }}"
+ use_instance_uuid: true
+ power_info:
+ start_action: powerOn
+ start_delay: 300
+ start_order: 1
+ stop_action: none
+ stop_delay: 20
+ wait_for_heartbeat: "no"
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 300
+ - item.startOrder == 1
+ - item.stopAction == 'none'
+ - item.stopDelay == 20
+ - item.waitForHeartbeat == 'no'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Update all parameters of autoStart powerInfo parameters for VM using moid via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ moid: "{{ vm_instanceUuid_and_moid_result.instance._moId }}"
+ power_info:
+ start_action: powerOn
+ start_delay: 200
+ start_order: 1
+ stop_action: powerOff
+ stop_delay: 300
+ wait_for_heartbeat: "yes"
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 200
+ - item.startOrder == 1
+ - item.stopAction == 'powerOff'
+ - item.stopDelay == 300
+ - item.waitForHeartbeat == 'yes'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml
new file mode 100644
index 00000000..7e5369e1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml
@@ -0,0 +1,57 @@
+# Test code for the vmware_host_auto_start Operations.
+# Copyright: (c) 2019, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Run tests and clean up
+ block:
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+ - name: Move the ESXi hosts out of the cluster
+ vmware_host:
+ datacenter_name: '{{ dc1 }}'
+ esxi_hostname: '{{ item }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ folder: '/DC0/host'
+ state: present
+ with_items: "{{ esxi_hosts }}"
+
+ - name: Disable the Maintenance Mode
+ vmware_maintenancemode:
+ esxi_hostname: '{{ item }}'
+ state: absent
+ with_items: "{{ esxi_hosts }}"
+
+ - name: Create VM on esxi1
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: '{{ item }}'
+ folder: vm
+ esxi_hostname: "{{ esxi1 }}"
+ state: present
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ version: 11
+ memory_mb: 1024
+ num_cpus: 1
+ scsi: paravirtual
+ with_items: ['test_vm1', 'test_vm2']
+
+ - include_tasks: reset_auto_start_config.yml
+ - include: vcenter_auto_start_ops.yml
+ - include_tasks: reset_auto_start_config.yml
+ - include: esxi_auto_start_ops.yml
+ always:
+ - include_tasks: reset_auto_start_config.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/reset_auto_start_config.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/reset_auto_start_config.yml
new file mode 100644
index 00000000..76990231
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/reset_auto_start_config.yml
@@ -0,0 +1,35 @@
+# Test code for the vmware_host_auto_start Operations.
+# Copyright: (c) 2019, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: "Reset powerInfo for autoStart parameters of {{ test_vm1 }}."
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm1
+ power_info:
+ start_action: none
+
+- name: "Reset powerInfo for autoStart parameters of {{ test_vm2 }}"
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm2
+ power_info:
+ start_action: none
+
+- name: Reset autoStart defaults parameters.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ system_defaults:
+ enabled: false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/vcenter_auto_start_ops.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/vcenter_auto_start_ops.yml
new file mode 100644
index 00000000..ed5095ff
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/vcenter_auto_start_ops.yml
@@ -0,0 +1,367 @@
+# Test code for the vmware_vmware_host_auto_start.
+# Copyright: (c) 2019, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Update enabled param of autoStart defaults parameters for ESXi via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ system_defaults:
+ enabled: true
+ register: changed_system_defaults_result
+
+- name: Check return parameters.
+ assert:
+ that:
+ - changed_system_defaults_result.system_defaults_config.enabled is sameas true
+ - changed_system_defaults_result.system_defaults_config.start_delay == 120
+ - changed_system_defaults_result.system_defaults_config.stop_action == 'powerOff'
+ - changed_system_defaults_result.system_defaults_config.start_delay == 120
+ - changed_system_defaults_result.system_defaults_config.wait_for_heartbeat is sameas false
+
+- name: Gather facts for autoStart defaults parameters from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check system default parameters.
+ assert:
+ that:
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.enabled is sameas true
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.startDelay == 120
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopAction == 'powerOff'
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopDelay == 120
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.waitForHeartbeat is sameas false
+
+- name: Update all param of autoStart defaults parameters for ESXi via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ system_defaults:
+ enabled: true
+ start_delay: 200
+ stop_action: guestShutdown
+ stop_delay: 300
+ wait_for_heartbeat: true
+
+- name: Gather facts for autoStart defaults parameters from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check system default parameters.
+ assert:
+ that:
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.enabled is sameas true
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.startDelay == 200
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopAction == 'guestShutdown'
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.stopDelay == 300
+ - auto_start_defaults_result.ansible_facts.config.autoStart.defaults.waitForHeartbeat is sameas true
+
+- name: Gather facts summary propertie from VM.
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ name: test_vm1
+ schema: vsphere
+ properties:
+ - summary.vm
+ register: vm_summary_result
+
+- name: Update start_action parameters of autoStart powerInfo parameters for VM via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm1
+ power_info:
+ start_action: powerOn
+ register: changed_vm_power_info_result
+
+- name: Check return parameters.
+ assert:
+ that:
+ - changed_vm_power_info_result.power_info_config.start_action == 'powerOn'
+ - changed_vm_power_info_result.power_info_config.start_delay == -1
+ - changed_vm_power_info_result.power_info_config.start_order == -1
+ - changed_vm_power_info_result.power_info_config.stop_action == 'systemDefault'
+ - changed_vm_power_info_result.power_info_config.stop_delay == -1
+ - changed_vm_power_info_result.power_info_config.wait_for_heartbeat == 'systemDefault'
+
+- name: Gather facts for autoStart config of VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check VM powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == -1
+ - item.startOrder == -1
+ - item.stopAction == 'systemDefault'
+ - item.stopDelay == -1
+ - item.waitForHeartbeat == 'systemDefault'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Update all parameters of autoStart powerInfo parameters for VM via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm1
+ power_info:
+ start_action: powerOn
+ start_delay: 200
+ start_order: 1
+ stop_action: suspend
+ stop_delay: 250
+ wait_for_heartbeat: "yes"
+
+- name: Gather facts for autoStart config of VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 200
+ - item.startOrder == 1
+ - item.stopAction == 'suspend'
+ - item.stopDelay == 250
+ - item.waitForHeartbeat == 'yes'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Gather facts summary propertie from VM.
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ name: test_vm2
+ schema: vsphere
+ properties:
+ - summary.vm
+ register: vm_summary_result
+
+- name: Update all parameters of autoStart powerInfo parameters for other VM via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm2
+ power_info:
+ start_action: powerOn
+ start_delay: 100
+ start_order: 2
+ stop_action: suspend
+ stop_delay: 20
+ wait_for_heartbeat: "no"
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 100
+ - item.startOrder == 2
+ - item.stopAction == 'suspend'
+ - item.stopDelay == 20
+ - item.waitForHeartbeat == 'no'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Check the operation of check_mode and diff.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ name: test_vm2
+ power_info:
+ start_action: powerOn
+ start_delay: 100
+ start_order: -1
+ stop_action: suspend
+ stop_delay: 20
+ check_mode: true
+ diff: true
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 100
+ - item.startOrder == 2
+ - item.stopAction == 'suspend'
+ - item.stopDelay == 20
+ - item.waitForHeartbeat == 'no'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Gather facts instanceUuid and moid propertie from VM.
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ name: test_vm2
+ schema: vsphere
+ properties:
+ - config.instanceUuid
+ - _moId
+ register: vm_instanceUuid_and_moid_result
+
+- name: Update all parameters of autoStart powerInfo parameters for VM using instanceUuid via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ uuid: "{{ vm_instanceUuid_and_moid_result.instance.config.instanceUuid }}"
+ use_instance_uuid: true
+ power_info:
+ start_action: powerOn
+ start_delay: 300
+ start_order: 1
+ stop_action: none
+ stop_delay: 20
+ wait_for_heartbeat: "no"
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 300
+ - item.startOrder == 1
+ - item.stopAction == 'none'
+ - item.stopDelay == 20
+ - item.waitForHeartbeat == 'no'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
+
+- name: Update all parameters of autoStart powerInfo parameters for VM using moid via vCenter.
+ vmware_host_auto_start:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ moid: "{{ vm_instanceUuid_and_moid_result.instance._moId }}"
+ power_info:
+ start_action: powerOn
+ start_delay: 200
+ start_order: 1
+ stop_action: powerOff
+ stop_delay: 300
+ wait_for_heartbeat: "yes"
+
+- name: Gather facts for autoStart config of other VM from ESXi.
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.autoStart
+ register: auto_start_defaults_result
+
+- name: After update parameters, check other VM all powerInfo parameters.
+ assert:
+ that:
+ - item.startAction == 'powerOn'
+ - item.startDelay == 200
+ - item.startOrder == 1
+ - item.stopAction == 'powerOff'
+ - item.stopDelay == 300
+ - item.waitForHeartbeat == 'yes'
+ when: item.key == vm_summary_result.instance.summary.vm
+ loop: "{{ auto_start_defaults_result.ansible_facts.config.autoStart.powerInfo }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/tasks/main.yml
new file mode 100644
index 00000000..cdeaab0b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_capability_info/tasks/main.yml
@@ -0,0 +1,38 @@
+# Test code for the vmware_host_capability_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather capability info for all ESXi host from given cluster
+ vmware_host_capability_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: capability_0001_results
+- assert:
+ that:
+ - not (capability_0001_results is changed)
+ - capability_0001_results.hosts_capability_info is defined
+ - capability_0001_results.hosts_capability_info[esxi1].checkpointFtSupported is defined
+ - capability_0001_results.hosts_capability_info[esxi1].checkpointFtCompatibilityIssues is defined
+
+- name: Gather capability info for ESXi host
+ vmware_host_capability_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: capability_0002_results
+- assert:
+ that:
+ - not (capability_0002_results is changed)
+ - capability_0002_results.hosts_capability_info is defined
+ - capability_0002_results.hosts_capability_info[esxi1].checkpointFtSupported is defined
+ - capability_0002_results.hosts_capability_info[esxi1].checkpointFtCompatibilityIssues is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/tasks/main.yml
new file mode 100644
index 00000000..895dec15
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_info/tasks/main.yml
@@ -0,0 +1,66 @@
+# Test code for the vmware_host_config_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: gather info about all hosts in given cluster
+ vmware_host_config_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: all_hosts_result
+
+- debug:
+ var: all_hosts_result
+
+- name: ensure info are gathered for all hosts
+ assert:
+ that:
+ - all_hosts_result.hosts_info
+
+- name: gather info about all hosts in given cluster in check mode
+ vmware_host_config_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: all_hosts_result_check_mode
+ check_mode: true
+
+- name: ensure info are gathered for all hosts
+ assert:
+ that:
+ - all_hosts_result_check_mode.hosts_info
+
+- name: gather info about a given host in check mode
+ vmware_host_config_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: single_hosts_result_check_mode
+ check_mode: true
+- name: ensure info are gathered for all hosts
+ assert:
+ that:
+ - single_hosts_result_check_mode.hosts_info
+
+- name: gather info about a given host
+ vmware_host_config_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: single_hosts_result
+- name: ensure info are gathered for all hosts
+ assert:
+ that:
+ - single_hosts_result.hosts_info
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/tasks/main.yml
new file mode 100644
index 00000000..9bf67d1d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_config_manager/tasks/main.yml
@@ -0,0 +1,123 @@
+# Test code for the vmware_host_config_manager module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Change an invalid key
+ vmware_host_config_manager:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ options:
+ 'This.Is.No.Where': 'verbose'
+ failed_when: false
+ register: invalid_key
+- debug: var=invalid_key
+- name: ensure we raise the correct error
+ assert:
+ that:
+ - '"Unsupported option This.Is.No.Where" in invalid_key.msg'
+
+- name: Change info about all hosts in given cluster
+ vmware_host_config_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ options:
+ 'Config.HostAgent.log.level': 'verbose'
+ validate_certs: false
+
+- name: Change info about a given host
+ vmware_host_config_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ options:
+ 'Config.HostAgent.log.level': 'info'
+ validate_certs: false
+ register: host_result
+
+- debug: var=host_result
+
+- name: ensure change was applied
+ assert:
+ that:
+ - host_result is changed
+
+- name: Change info about all hosts in given cluster in check mode
+ vmware_host_config_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ options:
+ 'Config.HostAgent.log.level': 'verbose'
+ validate_certs: false
+ register: all_hosts_result_check_mode
+ check_mode: true
+
+- name: ensure changes are done to all hosts
+ assert:
+ that:
+ - all_hosts_result_check_mode.changed
+
+- name: Change info about a given host in check mode
+ vmware_host_config_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ options:
+ 'Config.HostAgent.log.level': 'info'
+ validate_certs: false
+ register: host_result_check_mode
+ check_mode: true
+
+- name: ensure changes are done to given hosts
+ assert:
+ that:
+ - all_hosts_result_check_mode.changed
+
+# Test that PR 332 doesn't break boolean settings for this module.
+- name: Change a boolean setting for a given host (check-mode)
+ vmware_host_config_manager: &change_logDirUnique
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ options:
+ 'Syslog.global.logDirUnique': true
+ validate_certs: false
+ check_mode: true
+ register: change_logDirUnique_check
+
+- name: ensure changes would be done to given host
+ assert:
+ that:
+ - change_logDirUnique_check.changed
+
+- name: Change a boolean setting for a given host
+ vmware_host_config_manager: *change_logDirUnique
+ register: change_logDirUnique
+
+- name: ensure changes are done to given host
+ assert:
+ that:
+ - change_logDirUnique.changed
+
+- name: Change a boolean setting for a given host again
+ vmware_host_config_manager: *change_logDirUnique
+ register: change_logDirUnique_again
+
+- name: ensure changes are not done to given host
+ assert:
+ that:
+ - not change_logDirUnique_again.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/tasks/main.yml
new file mode 100644
index 00000000..f2dd4bb2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_custom_attributes/tasks/main.yml
@@ -0,0 +1,94 @@
+# Test code for the vmware_host_custom_attributes module.
+# Copyright: (c) 2021, Hunter Christain (@exp-hc)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Add custom attribute to the given ESXi host
+ vmware_host_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ state: present
+ attributes:
+ - name: 'sample_1'
+ value: 'sample_1_value'
+ - name: 'sample_2'
+ value: 'sample_2_value'
+ - name: 'sample_3'
+ value: 'sample_3_value'
+ register: host_info_0001
+
+- debug: var=host_info_0001
+
+- assert:
+ that:
+ - host_info_0001 is changed
+
+- name: Add custom attribute to the given ESXi host again
+ vmware_host_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ state: present
+ attributes:
+ - name: 'sample_1'
+ value: 'sample_1_value'
+ - name: 'sample_2'
+ value: 'sample_2_value'
+ - name: 'sample_3'
+ value: 'sample_3_value'
+ register: host_info_0002
+
+- debug: var=host_info_0002
+
+- assert:
+ that:
+ - not (host_info_0002 is changed)
+
+- name: Remove custom attribute to the given ESXi host
+ vmware_host_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ state: absent
+ attributes:
+ - name: 'sample_1'
+ - name: 'sample_2'
+ - name: 'sample_3'
+ register: host_info_0003
+
+- debug: msg="{{ host_info_0003 }}"
+
+- assert:
+ that:
+ - host_info_0003 is changed
+
+- name: Remove custom attribute to the given ESXi host again
+ vmware_host_custom_attributes:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ state: absent
+ attributes:
+ - name: 'sample_1'
+ - name: 'sample_2'
+ - name: 'sample_3'
+ register: host_info_0004
+
+- debug: var=host_info_0004
+
+- assert:
+ that:
+ - not (host_info_0004 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/tasks/main.yml
new file mode 100644
index 00000000..0b3c3f10
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_datastore/tasks/main.yml
@@ -0,0 +1,80 @@
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Mount NFS (ro_datastore) datastores without esxi_hostname
+ vmware_host_datastore:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datastore_name: '{{ ro_datastore }}'
+ datastore_type: '{{ infra.datastores[ro_datastore].type }}'
+ nfs_server: '{{ infra.datastores[ro_datastore].server }}'
+ nfs_path: '{{ infra.datastores[ro_datastore].path }}'
+ nfs_ro: '{{ infra.datastores[ro_datastore].ro }}'
+ state: present
+ validate_certs: false
+ ignore_errors: true
+ register: mount_vmware_host_datastore
+- debug: var=mount_vmware_host_datastore
+- assert:
+ that:
+ - mount_vmware_host_datastore is failed
+ - mount_vmware_host_datastore.msg == "esxi_hostname is mandatory with a vcenter"
+
+- name: Mount NFS (ro_datastore) datastores with non existing host in esxi_hostname
+ vmware_host_datastore:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: 'nohost'
+ datastore_name: '{{ ro_datastore }}'
+ datastore_type: '{{ infra.datastores[ro_datastore].type }}'
+ nfs_server: '{{ infra.datastores[ro_datastore].server }}'
+ nfs_path: '{{ infra.datastores[ro_datastore].path }}'
+ nfs_ro: '{{ infra.datastores[ro_datastore].ro }}'
+ state: present
+ validate_certs: false
+ ignore_errors: true
+ register: mount_vmware_host_datastore
+- debug: var=mount_vmware_host_datastore
+- assert:
+ that:
+ - mount_vmware_host_datastore is failed
+ - mount_vmware_host_datastore.msg == "Failed to find ESXi hostname nohost"
+
+# note: datastore is already mounted
+- name: Mount NFS (ro_datastore) datastores on esxi1 using esxi_hostname
+ vmware_host_datastore:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ datastore_name: '{{ ro_datastore }}'
+ datastore_type: '{{ infra.datastores[ro_datastore].type }}'
+ nfs_server: '{{ infra.datastores[ro_datastore].server }}'
+ nfs_path: '{{ infra.datastores[ro_datastore].path }}'
+ nfs_ro: '{{ infra.datastores[ro_datastore].ro }}'
+ state: present
+ validate_certs: false
+ register: mount_vmware_host_datastore
+- debug: var=mount_vmware_host_datastore
+
+- name: Mount NFS (ro_datastore) datastores to ESXi directly
+ vmware_host_datastore:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ datastore_name: '{{ ro_datastore }}'
+ datastore_type: '{{ infra.datastores[ro_datastore].type }}'
+ nfs_server: '{{ infra.datastores[ro_datastore].server }}'
+ nfs_path: '{{ infra.datastores[ro_datastore].path }}'
+ nfs_ro: '{{ infra.datastores[ro_datastore].ro }}'
+ state: present
+ validate_certs: false
+ register: mount_vmware_host_datastore
+- debug: var=mount_vmware_host_datastore
+- assert:
+ that:
+ - not (mount_vmware_host_datastore is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/tasks/main.yml
new file mode 100644
index 00000000..50566cad
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_disk_info/tasks/main.yml
@@ -0,0 +1,35 @@
+# Test code for the vmware_guest_info module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# Copyright: (c) 2018, James E. King III (@jeking3) <jking@apache.org>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+# Testcase 0001: Get disk info for a host
+- name: get list of disks from a single host
+ vmware_host_disk_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ register: host_disk_info
+
+- debug:
+ var: host_disk_info
+
+# Testcase 0002: Get disk info for all hosts in a cluster
+- name: get list of disks from all hosts in a cluster
+ vmware_host_disk_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ register: host_disk_info
+
+- debug:
+ var: host_disk_info
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/aliases
new file mode 100644
index 00000000..ad593838
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/dhcp.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/dhcp.yml
new file mode 100644
index 00000000..dfd0b569
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/dhcp.yml
@@ -0,0 +1,303 @@
+- name: Tests when the hosts have a DHCP DNS config
+ block:
+ # Testcase 0001: Ensure DNS config directly on the host is idempotent for DHCP
+ - name: Ensure DHCP config is idempotent when done directly on the host
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'dhcp'
+ device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}"
+ register: vmware_host_dns_result_0001
+
+ - name: Ensure DNS config wasn't changed
+ assert:
+ that:
+ - vmware_host_dns_result_0001 is not changed
+
+ # Testcase 0002: Change DNS config directly on the host from DHCP to static
+ - name: Change DNS config from DHCP to static directly on the host
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['host_name'] }}"
+ domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}"
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0002
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0002 is changed
+
+ # Testcase 0003: Ensure DNS config directly on the host is idempotent for static
+ - name: Ensure static DNS config is idempotent when done directly on the host
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['host_name'] }}"
+ domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}"
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0003
+
+ - name: Ensure DNS config wasn't changed
+ assert:
+ that:
+ - vmware_host_dns_result_0003 is not changed
+
+ # Testcase 0004: Ensure changing the hostname directly on the host works
+ - name: Ensure changing the hostname directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: newname
+ domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}"
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0004
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0004 is changed
+
+ # Testcase 0005: Ensure changing the domain directly on the host works
+ - name: Ensure changing the domain directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: newname
+ domain: new.domain
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0005
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0005 is changed
+
+ # Testcase 0006: Ensure changing the DNS servers directly on the host works
+ - name: Ensure changing the domain directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: newname
+ domain: new.domain
+ dns_servers:
+ - 1.2.3.4
+ - 5.6.7.8
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0006
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0006 is changed
+
+ # Testcase 0007: Ensure changing the search domain directly on the host works
+ - name: Ensure changing the domain directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: newname
+ domain: new.domain
+ dns_servers:
+ - 1.2.3.4
+ - 5.6.7.8
+ search_domains:
+ - subdomain.example.local
+ - example.local
+ register: vmware_host_dns_result_0007
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0007 is changed
+
+ # Testcase 0008: Change DNS config directly on the host from static to DHCP
+ - name: Change DNS config from static to DHCP directly on the host
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'dhcp'
+ device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}"
+ register: vmware_host_dns_result_0008
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0008 is changed
+
+ # Testcase 0009: Ensure DNS config on the cluster is idempotent for DHCP
+ - name: Ensure DHCP config is idempotent when done on the cluster
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'dhcp'
+ device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}"
+ register: vmware_host_dns_result_0009
+
+ - name: Ensure DNS config wasn't changed
+ assert:
+ that:
+ - vmware_host_dns_result_0009 is not changed
+
+ # Testcase 0010: Ensure changing DNS config on the cluster from DHCP to static works
+ - name: Ensure changing DNS config on the cluster from DHCP to static works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}"
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0010
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0010 is changed
+
+ # Testcase 0011: Ensure DNS config on the cluster is idempotent for static
+ - name: Ensure static DNS config is idempotent when done on the cluster
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}"
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0011
+
+ - name: Ensure DNS config wasn't changed
+ assert:
+ that:
+ - vmware_host_dns_result_0011 is not changed
+
+ # Testcase 0012: Ensure changing the domain on the cluster works
+ - name: Ensure changing the domain on the cluster works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: new.domain
+ dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}"
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0012
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0012 is changed
+
+ # Testcase 0013: Ensure changing the DNS servers on the cluster works
+ - name: Ensure changing the DNS servers on the cluster works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: new.domain
+ dns_servers:
+ - 1.2.3.4
+ - 5.6.7.8
+ search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}"
+ register: vmware_host_dns_result_0013
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0013 is changed
+
+ # Testcase 0014: Ensure changing the search domains on the cluster works
+ - name: Ensure changing the search domains on the cluster works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: new.domain
+ dns_servers:
+ - 1.2.3.4
+ - 5.6.7.8
+ search_domains:
+ - subdomain.example.local
+ - example.local
+ register: vmware_host_dns_result_0014
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0014 is changed
+
+ # Testcase 0015: Ensure changing DNS config on the cluster from static to DHCP works
+ - name: Ensure changing DNS config on the cluster from static to DHCP works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'dhcp'
+ device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}"
+ register: vmware_host_dns_result_0015
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0015 is changed
+
+ always:
+ # Revert to original DNS configuration
+ - name: Revert to original DNS configuration
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ item }}"
+ validate_certs: false
+ type: 'dhcp'
+ device: "{{ dns['results'][index]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}"
+ loop: "{{ esxi_hosts }}"
+ loop_control:
+ index_var: index
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/main.yml
new file mode 100644
index 00000000..36748149
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/main.yml
@@ -0,0 +1,26 @@
+# Test code for the vmware_host_dns module.
+# Copyright: (c) 2019, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# This tests assume that all ESXi hosts either have a static or a dynamic DNS
+# configuration. They probably will fail if on host is 'static' and the other
+# is 'dhcp' configured.
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather DNS facts about ESXi Host
+ vmware_host_dns_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ item }}"
+ validate_certs: false
+ loop: "{{ esxi_hosts }}"
+ register: dns
+
+- include_tasks: dhcp.yml
+ when: dns['results'][0]['hosts_dns_info'][esxi1]['dhcp']
+- include_tasks: static.yml
+ when: not dns['results'][0]['hosts_dns_info'][esxi1]['dhcp']
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/static.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/static.yml
new file mode 100644
index 00000000..630fe4d7
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/static.yml
@@ -0,0 +1,223 @@
+- name: Tests when the hosts have a static DNS config
+ block:
+ # Testcase 0001: Ensure DNS config directly on the host is idempotent for static
+ - name: Ensure static DNS config is idempotent when done directly on the host
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['host_name'] }}"
+ register: vmware_host_dns_result_0001
+ - name: Ensure DNS config wasn't changed
+ assert:
+ that:
+ - vmware_host_dns_result_0001 is not changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0002: Ensure changing the hostname directly on the host works
+ - name: Ensure changing the hostname directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ host_name: newname
+ register: vmware_host_dns_result_0002
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0002 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0003: Ensure changing the domain directly on the host works
+ - name: Ensure changing the domain directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ domain: new.domain
+ register: vmware_host_dns_result_0003
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0003 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0004: Ensure changing the DNS servers directly on the host works
+ - name: Ensure changing the domain directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ dns_servers:
+ - 1.2.3.4
+ - 5.6.7.8
+ register: vmware_host_dns_result_0004
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0004 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0005: Ensure changing the search domain directly on the host works
+ - name: Ensure changing the domain directly on the host works
+ vmware_host_dns:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ type: 'static'
+ search_domains:
+ - subdomain.example.local
+ - example.local
+ register: vmware_host_dns_result_0005
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0005 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0006: Ensure DNS config on the cluster is idempotent for static
+ - name: Apply configuration on a cluster
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ search_domains: "different-search-domain"
+ register: vmware_host_dns_result_0006
+
+ - name: Ensure configuration has changed
+ assert:
+ that:
+ - vmware_host_dns_result_0006 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0007: Ensure changing the domain on the cluster works
+ - name: Ensure changing the domain on the cluster works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: new.domain
+ register: vmware_host_dns_result_0007
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0007 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0008: Ensure changing the DNS servers on the cluster works
+ - name: Ensure changing the DNS servers on the cluster works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ dns_servers:
+ - 1.2.3.4
+ - 5.6.7.8
+ register: vmware_host_dns_result_0008
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0008 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ # Testcase 0009: Ensure changing the search domains on the cluster works
+ - name: Ensure changing the search domains on the cluster works
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ search_domains:
+ - subdomain.example.local
+ - example.local
+ register: vmware_host_dns_result_0009
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0009 is changed
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ - name: Remove all the DNS servers
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ dns_servers: []
+ register: vmware_host_dns_result_0010
+
+ - name: Ensure DNS config was changed
+ assert:
+ that:
+ - vmware_host_dns_result_0010 is changed
+
+ - name: Remove the domain
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ type: 'static'
+ domain: ''
+ register: vmware_host_dns_result_0011
+
+ - name: Ensure the server has no domain
+ assert:
+ that:
+ - vmware_host_dns_result_0011 is changed
+
+
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
+
+ always:
+ - name: Revert to original DNS configuration
+ include_tasks: teardown.yaml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/teardown.yaml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/teardown.yaml
new file mode 100644
index 00000000..1ddfbec2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns/tasks/teardown.yaml
@@ -0,0 +1,15 @@
+- name: Revert to original DNS configuration
+ vmware_host_dns:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: "{{ item }}"
+ validate_certs: false
+ type: 'static'
+ host_name: "{{ dns['results'][index]['hosts_dns_info'][item]['host_name'] }}"
+ domain: "{{ dns['results'][index]['hosts_dns_info'][item]['domain_name'] }}"
+ dns_servers: "{{ dns['results'][index]['hosts_dns_info'][item]['ip_address'] }}"
+ search_domains: "{{ dns['results'][index]['hosts_dns_info'][item]['search_domain'] }}"
+ loop: "{{ esxi_hosts }}"
+ loop_control:
+ index_var: index
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/tasks/main.yml
new file mode 100644
index 00000000..0452c7dc
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_dns_info/tasks/main.yml
@@ -0,0 +1,70 @@
+# Test code for the vmware_host_dns_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: gather DNS info about all hosts in given cluster
+ vmware_host_dns_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ register: all_hosts_dns_result
+
+- name: ensure DNS info are gathered for all hosts in given cluster
+ assert:
+ that:
+ - all_hosts_dns_result.hosts_dns_info
+ - not all_hosts_dns_result.changed
+
+- name: gather DNS info about host system
+ vmware_host_dns_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: all_hosts_dns_result
+
+- name: ensure DNS info are gathered about host system
+ assert:
+ that:
+ - all_hosts_dns_result.hosts_dns_info
+ - not all_hosts_dns_result.changed
+
+- name: gather DNS info about all hosts in given cluster in check mode
+ vmware_host_dns_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ register: all_hosts_dns_result_check_mode
+ check_mode: true
+
+- name: ensure DNS info are gathered for all hosts in given cluster
+ assert:
+ that:
+ - all_hosts_dns_result_check_mode.hosts_dns_info
+ - not all_hosts_dns_result_check_mode.changed
+
+- name: gather DNS info about host system in check mode
+ vmware_host_dns_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: all_hosts_dns_result_check_mode
+ check_mode: true
+
+- name: ensure DNS info are gathered about host system
+ assert:
+ that:
+ - all_hosts_dns_result_check_mode.hosts_dns_info
+ - not all_hosts_dns_result_check_mode.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/tasks/main.yml
new file mode 100644
index 00000000..50001b64
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_facts/tasks/main.yml
@@ -0,0 +1,69 @@
+# Test code for the vmware_guest_info module.
+# Copyright: (c) 2022, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Get info from an ESXi host
+ community.vmware.vmware_host_facts:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ register: host_facts_0001
+
+- debug:
+ var: host_facts_0001
+
+- assert:
+ that:
+ - host_facts_0001 is defined
+
+# https://github.com/ansible-collections/community.vmware/issues/184#issuecomment-630950107
+- name: Get info from an ESXi host that is offline / disconnected / shut down
+ block:
+ - name: Disconnect ESXi host
+ community.vmware.vmware_host:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: "{{ esxi1 }}"
+ state: disconnected
+
+ - name: Give the ESXi host time to disconnect
+ ansible.builtin.pause:
+ minutes: 1
+
+ - name: Get info from an ESXi host that is disconnected
+ community.vmware.vmware_host_facts:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ register: host_facts_0002
+
+ - debug:
+ var: host_facts_0002
+
+ - assert:
+ that:
+ - host_facts_0002 is defined
+ always:
+ - name: Reconnect ESXi host
+ community.vmware.vmware_host:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: "{{ esxi1 }}"
+ state: reconnect
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/tasks/main.yml
new file mode 100644
index 00000000..8b8296e0
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_feature_info/tasks/main.yml
@@ -0,0 +1,76 @@
+# Test code for the vmware_host_feature_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Gather feature capability info for all ESXi host from given cluster
+ vmware_host_feature_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: capability_0001_results
+
+- debug: var=capability_0001_results
+
+- assert:
+ that:
+ - "not capability_0001_results.changed"
+ - "capability_0001_results.hosts_feature_info is defined"
+
+- name: Gather feature capability info for all ESXi host from given cluster in check mode
+ vmware_host_feature_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: capability_0001_results
+ check_mode: true
+
+- debug: var=capability_0001_results
+
+- assert:
+ that:
+ - "not capability_0001_results.changed"
+ - "capability_0001_results.hosts_feature_info is defined"
+
+- name: Gather feature capability info for ESXi host
+ vmware_host_feature_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: capability_0002_results
+
+- debug: var=capability_0002_results
+
+- assert:
+ that:
+ - "not capability_0002_results.changed"
+ - "capability_0002_results.hosts_feature_info is defined"
+
+
+- name: Gather feature capability info for ESXi host in check mode
+ vmware_host_feature_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: capability_0002_results
+ check_mode: true
+
+- debug: var=capability_0002_results
+
+- assert:
+ that:
+ - "not capability_0002_results.changed"
+ - "capability_0002_results.hosts_feature_info is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/tasks/main.yml
new file mode 100644
index 00000000..ee0a2cd5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_info/tasks/main.yml
@@ -0,0 +1,65 @@
+# Test code for the vmware_host_firewall_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather firewall info for a given ESXi
+ vmware_host_firewall_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: firewall_0004_results
+ check_mode: true
+
+- assert:
+ that:
+ - "not firewall_0004_results.changed"
+ - "firewall_0004_results.hosts_firewall_info is defined"
+
+- name: Gather firewall info for all ESXi host from given cluster
+ vmware_host_firewall_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: firewall_0001_results
+
+- assert:
+ that:
+ - "not firewall_0001_results.changed"
+ - "firewall_0001_results.hosts_firewall_info is defined"
+
+- name: Gather firewall info for ESXi host
+ vmware_host_firewall_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: firewall_0002_results
+
+- assert:
+ that:
+ - "not firewall_0002_results.changed"
+ - "firewall_0002_results.hosts_firewall_info is defined"
+
+- name: Gather firewall info for all ESXi host from given cluster in check mode
+ vmware_host_firewall_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: firewall_0003_results
+ check_mode: true
+
+- assert:
+ that:
+ - "not firewall_0003_results.changed"
+ - "firewall_0003_results.hosts_firewall_info is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/aliases
new file mode 100644
index 00000000..d1d14d22
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_2esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/tasks/main.yml
new file mode 100644
index 00000000..1fb452c4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_firewall_manager/tasks/main.yml
@@ -0,0 +1,260 @@
+# Test code for the vmware_host_firewall_manager module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Run tests and clean up
+ block:
+ - name: Enable vvold rule set on all hosts of {{ ccr1 }}
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ rules:
+ - name: vvold
+ enabled: true
+ allowed_hosts:
+ all_ip: true
+ register: all_hosts_result
+
+ - debug: msg="{{ all_hosts_result }}"
+
+ - name: ensure everything is changed for all hosts of {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_result.changed
+ - all_hosts_result.rule_set_state is defined
+
+ - name: ensure info are gathered for all hosts of {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_result.rule_set_state[item]['vvold']['current_state'] == true
+ - all_hosts_result.rule_set_state[item]['vvold']['desired_state'] == true
+ - all_hosts_result.rule_set_state[item]['vvold']['previous_state'] == False
+ with_items:
+ - '{{ esxi1 }}'
+ - '{{ esxi2 }}'
+
+ - name: Disable vvold for {{ host1 }}
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ rules:
+ - name: vvold
+ enabled: false
+ register: host_result
+
+ - debug: msg="{{ host_result }}"
+
+ - name: ensure vvold is disabled for {{ host1 }}
+ assert:
+ that:
+ - host_result.changed
+ - host_result.rule_set_state is defined
+
+ - name: ensure info are gathered for {{ host1 }}
+ assert:
+ that:
+ - host_result.rule_set_state[item]['vvold']['current_state'] == False
+ - host_result.rule_set_state[item]['vvold']['desired_state'] == False
+ - host_result.rule_set_state[item]['vvold']['previous_state'] == true
+ with_items:
+ - '{{ esxi1 }}'
+
+ - name: Enable vvold rule set on all hosts of {{ ccr1 }} in check mode
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ rules:
+ - name: vvold
+ enabled: true
+ allowed_hosts:
+ all_ip: true
+ register: all_hosts_result_check_mode
+ check_mode: true
+
+ - debug: var=all_hosts_result_check_mode
+
+ - name: ensure everything is changed for all hosts of {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_result_check_mode.changed
+ - all_hosts_result_check_mode.rule_set_state is defined
+
+ - name: ensure info are gathered for all hosts of {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_result_check_mode.rule_set_state[esxi1]['vvold']['current_state'] == true
+ - all_hosts_result_check_mode.rule_set_state[esxi2]['vvold']['current_state'] == true
+ - all_hosts_result_check_mode.rule_set_state[esxi2]['vvold']['desired_state'] == true
+
+ - name: Disable vvold for {{ host1 }} in check mode
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ rules:
+ - name: vvold
+ enabled: false
+ register: host_result_check_mode
+ check_mode: true
+
+ - debug: msg="{{ host_result_check_mode }}"
+
+ - name: ensure vvold is disabled for {{ host1 }}
+ assert:
+ that:
+ - host_result_check_mode.changed == False
+ - host_result_check_mode.rule_set_state is defined
+
+ - name: ensure info are gathered for {{ host1 }}
+ assert:
+ that:
+ - host_result_check_mode.rule_set_state[item]['vvold']['current_state'] == False
+ - host_result_check_mode.rule_set_state[item]['vvold']['desired_state'] == False
+ - host_result_check_mode.rule_set_state[item]['vvold']['previous_state'] == False
+ with_items:
+ - '{{ esxi1 }}'
+
+ - name: Configure CIMHttpServer rule set on all hosts of {{ ccr1 }}
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ rules:
+ - name: CIMHttpServer
+ enabled: true
+ allowed_hosts:
+ all_ip: false
+ ip_address:
+ - "192.168.100.11"
+ - "192.168.100.12"
+ ip_network:
+ - "192.168.200.0/24"
+ register: all_hosts_ip_specific
+
+ - debug: var=all_hosts_ip_specific
+
+ - name: ensure everything is changed for all hosts of {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_ip_specific.changed
+ - all_hosts_ip_specific.rule_set_state is defined
+
+ - name: ensure CIMHttpServer is configured for all hosts in {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['current_state'] == true
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['desired_state'] == true
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['previous_state'] == true
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['current_allowed_all'] == False
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['previous_allowed_all'] == true
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['desired_allowed_all'] == False
+ - "'192.168.100.11' in all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['current_allowed_ip']"
+ - "'192.168.100.12' in all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['current_allowed_ip']"
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['previous_allowed_ip'] == []
+ - "'192.168.100.11' in all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['desired_allowed_ip']"
+ - "'192.168.100.12' in all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['desired_allowed_ip']"
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['current_allowed_networks'] == ["192.168.200.0/24"]
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['previous_allowed_networks'] == []
+ - all_hosts_ip_specific.rule_set_state[item]['CIMHttpServer']['allowed_hosts']['desired_allowed_networks'] == ["192.168.200.0/24"]
+ with_items:
+ - '{{ esxi1 }}'
+ - '{{ esxi2 }}'
+
+ - name: Configure the NFC firewall rule to only allow traffic from one IP on one ESXi host
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ rules:
+ - name: NFC
+ enabled: true
+ allowed_hosts:
+ all_ip: false
+ ip_address:
+ - "192.168.100.11"
+ register: single_host_ip_specific
+
+ - set_fact:
+ nfc_state: "{{ single_host_ip_specific.rule_set_state[esxi1]['NFC'] }}"
+
+ - debug: var=single_host_ip_specific
+
+ - debug: var=nfc_state
+
+ - name: ensure NFC is configured on that host
+ assert:
+ that:
+ - nfc_state.current_state == true
+ - nfc_state.desired_state == true
+ - nfc_state.previous_state == true
+ - nfc_state.allowed_hosts.current_allowed_all == False
+ - nfc_state.allowed_hosts.previous_allowed_all == true
+ - nfc_state.allowed_hosts.desired_allowed_all == False
+ - nfc_state.allowed_hosts.current_allowed_ip == ["192.168.100.11"]
+ - nfc_state.allowed_hosts.previous_allowed_all == true
+ - nfc_state.allowed_hosts.desired_allowed_ip == ["192.168.100.11"]
+ - nfc_state.allowed_hosts.current_allowed_networks == []
+ - nfc_state.allowed_hosts.previous_allowed_networks == []
+ - nfc_state.allowed_hosts.desired_allowed_networks == []
+
+ - name: Ensure we can still pass the allowed_hosts configuration through a list for compat
+ community.vmware.vmware_host_firewall_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ rules:
+ - name: NFC
+ enabled: true
+ allowed_hosts:
+ all_ip: false
+ ip_address:
+ - "1.2.3.4"
+ register: using_list
+
+ - debug: var=using_list
+
+ - set_fact:
+ nfc_state: "{{ using_list.rule_set_state[esxi1]['NFC'] }}"
+
+ - name: ensure the correct host is set
+ assert:
+ that:
+ - nfc_state.allowed_hosts.current_allowed_ip == ["1.2.3.4"]
+
+ always:
+ - name: Clean up the firewall rules
+ community.vmware.vmware_host_firewall_manager:
+ cluster_name: '{{ ccr1 }}'
+ rules:
+ - name: vvold
+ enabled: false
+ - name: CIMHttpServer
+ enabled: true
+ allowed_hosts:
+ all_ip: true
+ - name: NFC
+ enabled: true
+ allowed_hosts:
+ all_ip: true
+ ignore_errors: true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/tasks/main.yml
new file mode 100644
index 00000000..53a6fe6f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_hyperthreading/tasks/main.yml
@@ -0,0 +1,91 @@
+# Test code for the vmware_host_hyperthreading module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: Enable Hyperthreading everywhere
+ vmware_host_hyperthreading:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ state: disabled
+ register: enable_hyperthreading_everywhere
+ ignore_errors: true
+
+- when: enable_hyperthreading_everywhere is succeeded
+ block:
+
+ - name: Disable Hyperthreading for a given host
+ vmware_host_hyperthreading:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: disabled
+ register: host_hyperthreading_info
+
+ - debug: var=host_hyperthreading_info
+
+ - assert:
+ that:
+ - host_hyperthreading_info is defined
+ - host_hyperthreading_info.changed
+
+ - name: Disable Hyperthreading for a given host in check mode
+ vmware_host_hyperthreading:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: disabled
+ register: host_hyperthreading_info_check_mode
+ check_mode: true
+
+ - debug: var=host_hyperthreading_info_check_mode
+
+ - assert:
+ that:
+ - host_hyperthreading_info_check_mode is defined
+
+ - name: Disable Hyperthreading for all hosts in given cluster
+ vmware_host_hyperthreading:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: disabled
+ register: host_hyperthreading_info
+
+ - debug: var=host_hyperthreading_info
+
+ - assert:
+ that:
+ - host_hyperthreading_info is defined
+ - host_hyperthreading_info is changed
+
+ - name: Enable Hyperthreading for all hosts in given cluster in check mode
+ vmware_host_hyperthreading:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: enabled
+ register: host_hyperthreading_info_check_mode
+ check_mode: true
+
+ - debug: var=host_hyperthreading_info_check_mode
+
+ - assert:
+ that:
+ - host_hyperthreading_info_check_mode is defined
+ - host_hyperthreading_info_check_mode.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/tasks/main.yml
new file mode 100644
index 00000000..ba504725
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ipv6/tasks/main.yml
@@ -0,0 +1,89 @@
+# Test code for the vmware_host_ipv6 module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Ensure IPv6 is off
+ vmware_host_ipv6:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: disabled
+ register: host_ipv6_info
+
+- name: Enable IPv6 support for a given host
+ vmware_host_ipv6:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: enabled
+ register: host_ipv6_info
+- debug: var=host_ipv6_info
+- assert:
+ that:
+ - host_ipv6_info is defined
+ - host_ipv6_info.changed
+
+- name: Enable IPv6 support for a given host in check mode
+ vmware_host_ipv6:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: enabled
+ register: host_ipv6_info_check_mode
+ check_mode: true
+- debug: var=host_ipv6_info_check_mode
+- assert:
+ that:
+ - host_ipv6_info_check_mode is defined
+ - not (host_ipv6_info_check_mode is changed)
+
+- name: Reset the status again
+ vmware_host_ipv6:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: disabled
+ register: host_ipv6_info
+
+- name: Enable IPv6 support for all hosts in given cluster
+ vmware_host_ipv6:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: enabled
+ register: hosts_ipv6_info
+- debug: var=hosts_ipv6_info
+- assert:
+ that:
+ - hosts_ipv6_info is defined
+ - hosts_ipv6_info.changed
+
+- name: Enable IPv6 support for all hosts in given cluster in check mode
+ vmware_host_ipv6:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: enabled
+ register: hosts_ipv6_info_check_mode
+ check_mode: true
+- debug: var=hosts_ipv6_info_check_mode
+- assert:
+ that:
+ - hosts_ipv6_info_check_mode is defined
+ - not (hosts_ipv6_info_check_mode is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/iscsi_module_test_tasks.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/iscsi_module_test_tasks.yml
new file mode 100644
index 00000000..7dd17874
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/iscsi_module_test_tasks.yml
@@ -0,0 +1,1170 @@
+# Test code for the vmware_host_iscsi module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: enable iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: enabled
+ check_mode: true
+ register: enable_iscsi_check_mode_result
+
+- assert:
+ that:
+ - enable_iscsi_check_mode_result.changed is sameas true
+
+- name: enable iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: enabled
+ register: enable_iscsi_result
+
+- assert:
+ that:
+ - enable_iscsi_result.changed is sameas true
+ - enable_iscsi_result.iscsi_properties.iscsi_enabled is sameas true
+
+- name: enable iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: enabled
+ register: enable_iscsi_idempotency_check_result
+
+- assert:
+ that:
+ - enable_iscsi_idempotency_check_result.changed is sameas false
+
+- name: Gather iSCSI info
+ community.vmware.vmware_host_iscsi_info:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: gather_iscsi_info
+
+- name: Set an iqn variable for an iSCSI name changing test
+ set_fact:
+ iqn: "iqn.1998-01.com.vmware:{{ hostname }}-012345"
+
+- name: Update a name for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ iscsi_name: "{{ iqn }}"
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ check_mode: true
+ register: update_iscsi_name_check_mode_result
+
+- assert:
+ that:
+ - update_iscsi_name_check_mode_result.changed is sameas true
+
+- name: Update a name for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ iscsi_name: "{{ iqn }}"
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_iscsi_name_result
+
+- assert:
+ that:
+ - update_iscsi_name_result.changed is sameas true
+ - update_iscsi_name_result.iscsi_properties.iscsi_name == iqn
+
+- name: Update a name for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ iscsi_name: "{{ iqn }}"
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_iscsi_name_idempotency_check_result
+
+- assert:
+ that:
+ - update_iscsi_name_idempotency_check_result.changed is sameas false
+
+- name: Update an alias for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ check_mode: true
+ register: update_alias_check_mode_result
+
+- assert:
+ that:
+ - update_alias_check_mode_result.changed is sameas true
+
+- name: Update an alias for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_alias_result
+
+- assert:
+ that:
+ - update_alias_result.changed is sameas true
+ - update_alias_result.iscsi_properties.iscsi_alias == 'example'
+
+- name: Update an alias for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_alias_idempotency_check_result
+
+- assert:
+ that:
+ - update_alias_idempotency_check_result.changed is sameas false
+
+- name: Update CHAP authentication for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_name: chap_name
+ chap_secret: chap_secret
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ check_mode: true
+ register: update_chap_authentication_check_mode_result
+
+- assert:
+ that:
+ - update_chap_authentication_check_mode_result.changed is sameas true
+
+- name: Update CHAP authentication for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_name: chap_name
+ chap_secret: chap_secret
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_chap_authentication_result
+
+- assert:
+ that:
+ - update_chap_authentication_result.changed is sameas true
+ - update_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.chapAuthEnabled is sameas true
+ - update_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.chapAuthenticationType == 'chapPreferred'
+ - update_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.chapName == 'chap_name'
+
+- name: Update CHAP authentication for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_name: chap_name
+ chap_secret: chap_secret
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_chap_authentication_idempotency_check_result
+
+- assert:
+ that:
+ - update_chap_authentication_idempotency_check_result.changed is sameas false
+
+- name: Update Mutual-CHAP authentication for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ check_mode: true
+ register: update_mutual_chap_authentication_check_mode_result
+
+- assert:
+ that:
+ - update_mutual_chap_authentication_check_mode_result.changed is sameas true
+
+- name: Update Mutual-CHAP authentication for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_mutual_chap_authentication_result
+
+- assert:
+ that:
+ - update_mutual_chap_authentication_result.changed is sameas true
+ - update_mutual_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.chapAuthEnabled is sameas true
+ - update_mutual_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.chapAuthenticationType == 'chapRequired'
+ - update_mutual_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.chapName == 'chap_name'
+ - update_mutual_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.mutualChapAuthenticationType == 'chapRequired'
+ - update_mutual_chap_authentication_result.iscsi_properties.iscsi_authentication_properties.mutualChapName == 'mutual_chap_name'
+
+- name: Update Mutual-CHAP authentication for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_mutual_chap_authentication_idempotency_checkresult
+
+- assert:
+ that:
+ - update_mutual_chap_authentication_idempotency_checkresult.changed is sameas false
+
+- name: Update a port bind for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ state: present
+ check_mode: true
+ register: update_port_bind_check_mode_result
+
+- assert:
+ that:
+ - update_port_bind_check_mode_result.changed is sameas true
+
+- name: Update a port bind for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ state: present
+ register: update_port_bind_result
+
+- assert:
+ that:
+ - update_port_bind_result.changed is sameas true
+ - update_port_bind_result.iscsi_properties.port_bind.0 == 'vmk0'
+
+- name: Update a port bind for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ state: present
+ register: update_port_bind_idempotency_check_result
+
+- assert:
+ that:
+ - update_port_bind_idempotency_check_result.changed is sameas false
+
+- name: Add a dynamic target to iSCSI config of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ state: present
+ check_mode: true
+ register: add_dynamic_target_check_mode_result
+
+- assert:
+ that:
+ - add_dynamic_target_check_mode_result.changed is sameas true
+
+- name: Add a dynamic target to iSCSI config of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ state: present
+ register: add_dynamic_target_result
+
+- assert:
+ that:
+ - add_dynamic_target_result.changed is sameas true
+ - add_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.address == '100.64.0.1'
+ - add_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.port == 3260
+
+- name: Add a dynamic target to iSCSI config of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ state: present
+ register: add_dynamic_target_idempotency_check_result
+
+- assert:
+ that:
+ - add_dynamic_target_idempotency_check_result.changed is sameas false
+
+- name: Update CHAP authenticatoin of a dynamic target with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ state: present
+ check_mode: true
+ register: update_chap_authentication_dynamic_target_check_mode_result
+
+- assert:
+ that:
+ - update_chap_authentication_dynamic_target_check_mode_result.changed is sameas true
+
+- name: Update CHAP authenticatoin of a dynamic target
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ state: present
+ register: update_chap_authentication_dynamic_target_result
+
+- assert:
+ that:
+ - update_chap_authentication_dynamic_target_result.changed is sameas true
+ - update_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.address == '100.64.0.1'
+ - update_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.port == 3260
+ - update_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapAuthEnabled is sameas true
+ - update_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapAuthenticationType == 'chapPreferred'
+ - update_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapInherited is sameas false
+ - update_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapName == 'chap_name'
+
+- name: Update CHAP authenticatoin of a dynamic target (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ state: present
+ register: update_chap_authentication_dynamic_target_idempotency_check_result
+
+- assert:
+ that:
+ - update_chap_authentication_dynamic_target_idempotency_check_result.changed is sameas false
+
+- name: Update Mutual-CHAP authenticatoin of a dynamic target with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_inherited: false
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ state: present
+ check_mode: true
+ register: update_mutual_chap_authentication_dynamic_target_check_mode_result
+
+- assert:
+ that:
+ - update_chap_authentication_dynamic_target_check_mode_result.changed is sameas true
+
+- name: Update Mutual-CHAP authenticatoin of a dynamic target
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_inherited: false
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ state: present
+ register: update_mutual_chap_authentication_dynamic_target_result
+
+- assert:
+ that:
+ - update_mutual_chap_authentication_dynamic_target_result.changed is sameas true
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.address == '100.64.0.1'
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.port == 3260
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapAuthEnabled is sameas true
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapAuthenticationType == 'chapRequired'
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapInherited is sameas false
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.chapName == 'chap_name'
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.mutualChapAuthenticationType == 'chapRequired'
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.mutualChapInherited is sameas false
+ - update_mutual_chap_authentication_dynamic_target_result.iscsi_properties.iscsi_send_targets.0.authenticationProperties.mutualChapName == 'mutual_chap_name'
+
+- name: Update Mutual-CHAP authenticatoin of a dynamic target (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_inherited: false
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ state: present
+ register: update_mutual_mutual_chap_authentication_dynamic_target_idempotency_check_result
+
+- assert:
+ that:
+ - update_mutual_mutual_chap_authentication_dynamic_target_idempotency_check_result.changed is sameas false
+
+- name: Add a static target to iSCSI config of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: present
+ check_mode: true
+ register: add_static_target_check_mode_result
+
+- assert:
+ that:
+ - add_static_target_check_mode_result.changed is sameas true
+
+- name: Add a static target to iSCSI config of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: present
+ register: add_static_target_result
+
+- assert:
+ that:
+ - add_static_target_result.changed is sameas true
+
+- assert:
+ that:
+ - add_static_target_result.changed is sameas true
+ - add_static_target_result.iscsi_properties.iscsi_static_targets.0.address == '100.64.0.2'
+ - add_static_target_result.iscsi_properties.iscsi_static_targets.0.port == 3260
+
+- name: Add a static target to iSCSI config of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: present
+ register: add_static_target_idempotency_check_result
+
+- assert:
+ that:
+ - add_static_target_idempotency_check_result.changed is sameas false
+
+- name: Update CHAP authenticatoin of a static target with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ state: present
+ check_mode: true
+ register: update_chap_authentication_static_target_check_mode_result
+
+- assert:
+ that:
+ - update_chap_authentication_static_target_check_mode_result.changed is sameas true
+
+- name: Update CHAP authenticatoin of a static target
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ state: present
+ register: update_chap_authentication_static_target_result
+
+- assert:
+ that:
+ - update_chap_authentication_static_target_result.changed is sameas true
+ - update_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.address == '100.64.0.2'
+ - update_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.port == 3260
+ - update_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapAuthEnabled is sameas true
+ - update_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapAuthenticationType == 'chapPreferred'
+ - update_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapInherited is sameas false
+ - update_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapName == 'chap_name'
+
+- name: Update CHAP authenticatoin of a static target (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapPreferred
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ state: present
+ register: update_chap_authentication_static_target_idempotency_check_result
+
+- assert:
+ that:
+ - update_chap_authentication_static_target_idempotency_check_result.changed is sameas false
+
+- name: Update Mutual-CHAP authenticatoin of a static target with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_inherited: false
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ state: present
+ check_mode: true
+ register: update_mutual_chap_authentication_static_target_check_mode_result
+
+- assert:
+ that:
+ - update_mutual_chap_authentication_static_target_check_mode_result.changed is sameas true
+
+- name: Update Mutual-CHAP authenticatoin of a static target
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_inherited: false
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ state: present
+ register: update_mutual_chap_authentication_static_target_result
+
+- assert:
+ that:
+ - update_mutual_chap_authentication_static_target_result.changed is sameas true
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.address == '100.64.0.2'
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.port == 3260
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapAuthEnabled is sameas true
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapAuthenticationType == 'chapRequired'
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapInherited is sameas false
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.chapName == 'chap_name'
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.mutualChapAuthenticationType == 'chapRequired'
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.mutualChapInherited is sameas false
+ - update_mutual_chap_authentication_static_target_result.iscsi_properties.iscsi_static_targets.0.authenticationProperties.mutualChapName == 'mutual_chap_name'
+
+- name: Update Mutual-CHAP authenticatoin of a static target (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ authentication:
+ chap_auth_enabled: true
+ chap_authentication_type: chapRequired
+ chap_inherited: false
+ chap_name: chap_name
+ chap_secret: chap_secret
+ mutual_chap_authentication_type: chapRequired
+ mutual_chap_inherited: false
+ mutual_chap_name: mutual_chap_name
+ mutual_chap_secret: mutual_chap_secret
+ state: present
+ register: update_mutual_mutual_chap_authentication_static_target_idempotency_check_result
+
+- assert:
+ that:
+ - update_mutual_mutual_chap_authentication_static_target_idempotency_check_result.changed is sameas false
+
+- name: Update an alias to blank for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: ''
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ check_mode: true
+ register: update_alias_blank_check_mode_result
+
+- assert:
+ that:
+ - update_alias_blank_check_mode_result.changed is sameas true
+
+- name: Update an alias to blank for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: ''
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_alias_blank_result
+
+- assert:
+ that:
+ - update_alias_blank_result.changed is sameas true
+ - update_alias_blank_result.iscsi_properties.iscsi_alias == ''
+
+- name: Update an alias to blank for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: ''
+ vmhba_name: "{{ vmhba_name }}"
+ state: present
+ register: update_alias_blank_idempotency_check_result
+
+- assert:
+ that:
+ - update_alias_blank_idempotency_check_result.changed is sameas false
+
+- name: Remove a port bind for iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ state: absent
+ check_mode: true
+ register: remove_port_bind_check_mode_result
+
+- assert:
+ that:
+ - remove_port_bind_check_mode_result.changed is sameas true
+
+- name: Remove a port bind for iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ state: absent
+ register: remove_port_bind_result
+
+- assert:
+ that:
+ - remove_port_bind_result.changed is sameas true
+ - remove_port_bind_result.iscsi_properties.port_bind | length == 0
+
+- name: Remove a port bind for iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ state: absent
+ register: remove_port_bind_idempotency_check_result
+
+- assert:
+ that:
+ - remove_port_bind_idempotency_check_result.changed is sameas false
+
+- name: Remove a dynamic target from iSCSI config of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ send_target:
+ address: 100.64.0.1
+ state: absent
+ check_mode: true
+ register: remove_dynamic_target_check_mode_result
+
+- assert:
+ that:
+ - remove_dynamic_target_check_mode_result.changed is sameas true
+
+- name: Remove a dynamic target from iSCSI config of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ send_target:
+ address: 100.64.0.1
+ state: absent
+ register: remove_dynamic_target_result
+
+- assert:
+ that:
+ - remove_dynamic_target_result.changed is sameas true
+ - remove_dynamic_target_result.iscsi_properties.iscsi_send_targets | length == 0
+
+- name: Remove a dynamic target from iSCSI config of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ send_target:
+ address: 100.64.0.1
+ state: absent
+ register: remove_dynamic_target_idempotency_check_result
+
+- assert:
+ that:
+ - remove_dynamic_target_idempotency_check_result.changed is sameas false
+
+- name: Remove a static target from iSCSI config of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: absent
+ check_mode: true
+ register: remove_dynamic_static_check_mode_result
+
+- assert:
+ that:
+ - remove_dynamic_target_check_mode_result.changed is sameas true
+
+- name: Remove a static target from iSCSI config of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: absent
+ register: remove_static_target_result
+
+- assert:
+ that:
+ - remove_static_target_result.changed is sameas true
+ - remove_static_target_result.iscsi_properties.iscsi_static_targets | length == 0
+
+- name: Remove a dynamic target from iSCSI config of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ vmhba_name: "{{ vmhba_name }}"
+ send_target:
+ address: 100.64.0.1
+ state: absent
+ register: remove_static_target_idempotency_check_result
+
+- assert:
+ that:
+ - remove_dynamic_target_idempotency_check_result.changed is sameas false
+
+- name: disable iSCSI of ESXi with check_mode
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: disabled
+ check_mode: true
+ register: disable_iscsi_check_mode_result
+
+- assert:
+ that:
+ - disable_iscsi_check_mode_result.changed is sameas true
+
+- name: disable iSCSI of ESXi
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: disabled
+ register: disable_iscsi_result
+
+- assert:
+ that:
+ - disable_iscsi_result.changed is sameas true
+ - disable_iscsi_result.iscsi_properties.iscsi_enabled is sameas false
+
+- name: disable iSCSI of ESXi (idempotency check)
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: disabled
+ register: disable_iscsi_idempotency_check_result
+
+- assert:
+ that:
+ - disable_iscsi_idempotency_check_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/main.yml
new file mode 100644
index 00000000..97a90ad8
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi/tasks/main.yml
@@ -0,0 +1,52 @@
+# Test code for the vmware_host_iscsi module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: prepare of integration test for iSCSI - connect to vCenter
+ block:
+ - name: Enable iSCSI
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: enabled
+ register: create_iscsi_device_result
+
+ - name: Set iSCSI hba name to vmhba_name variable
+ set_fact:
+ vmhba_name: "{{ create_iscsi_device_result.iscsi_properties.vmhba_name }}"
+
+ - name: Disable iSCSI
+ community.vmware.vmware_host_iscsi:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: disabled
+ register: prepare_iscsi_disabled_result
+
+ - assert:
+ that:
+ - prepare_iscsi_disabled_result.changed is sameas true
+
+- name: vmware_host_iscsi module test - connect to vCenter
+ include_tasks: iscsi_module_test_tasks.yml
+ vars:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+
+- name: vmware_host_iscsi module test - connect to ESXi
+ include_tasks: iscsi_module_test_tasks.yml
+ vars:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/iscsi_info_module_test_tasks.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/iscsi_info_module_test_tasks.yml
new file mode 100644
index 00000000..5529a8a8
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/iscsi_info_module_test_tasks.yml
@@ -0,0 +1,126 @@
+# Test code for the vmware_host_iscsi_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Enable iSCSI of ESXi
+ vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: enabled
+ register: enable_iscsi_result
+
+- name: Gather iSCSI configuration for setting vmhba variable
+ vmware_host_iscsi_info:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: iscsi_info_vmhba_result
+
+- name: Set vmhba_name variable
+ set_fact:
+ vmhba_name: "{{ iscsi_info_vmhba_result.iscsi_properties.vmhba_name }}"
+
+- name: Add dynamic and static targets to iSCSI config of ESXi
+ vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: present
+ register: add_dynamic_static_targets_result
+
+- assert:
+ that:
+ - add_dynamic_static_targets_result.changed is sameas true
+
+- name: Gather iSCSI configuration
+ vmware_host_iscsi_info:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: iscsi_info_result
+
+- assert:
+ that:
+ - iscsi_info_result.iscsi_properties.iscsi_alias == 'example'
+ - iscsi_info_result.iscsi_properties.iscsi_authentication_properties is defined
+ - iscsi_info_result.iscsi_properties.iscsi_enabled is sameas true
+ - iscsi_info_result.iscsi_properties.iscsi_name is defined
+ - iscsi_info_result.iscsi_properties.iscsi_send_targets is defined
+ - iscsi_info_result.iscsi_properties.iscsi_send_targets[0].address == '100.64.0.1'
+ - iscsi_info_result.iscsi_properties.iscsi_static_targets is defined
+ - iscsi_info_result.iscsi_properties.iscsi_static_targets[0].address == '100.64.0.2'
+ - iscsi_info_result.iscsi_properties.iscsi_static_targets[0].iscsi_name == 'iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001'
+ - iscsi_info_result.iscsi_properties.port_bind[0] == 'vmk0'
+ - iscsi_info_result.iscsi_properties.vmhba_name is defined
+ - iscsi_info_result.detected_iscsi_drives is defined
+
+- name: Remove dynamic and static targets iSCSI config from ESXi
+ vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ iscsi_config:
+ alias: example
+ vmhba_name: "{{ vmhba_name }}"
+ port_bind:
+ - vmk0
+ send_target:
+ address: 100.64.0.1
+ static_target:
+ iscsi_name: iqn.2011-08.com.xxxxxxx:as6104t-8c3e9d.target001
+ address: 100.64.0.2
+ state: absent
+ register: remove_dynamic_static_targets_result
+
+- assert:
+ that:
+ - remove_dynamic_static_targets_result.changed is sameas true
+
+- name: Disable iSCSI of ESXi
+ vmware_host_iscsi:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ state: disabled
+ register: disable_iscsi_result
+
+- assert:
+ that:
+ - disable_iscsi_result.changed is sameas true
+
+- name: Gather iSCSI configuration when ESXi host with iSCSI disabled
+ vmware_host_iscsi_info:
+ hostname: "{{ hostname }}"
+ username: "{{ username }}"
+ password: "{{ password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: dsabled_iscsi_info_result
+
+- assert:
+ that:
+ - dsabled_iscsi_info_result.iscsi_properties.iscsi_enabled is sameas false
+ - dsabled_iscsi_info_result.detected_iscsi_drives is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/main.yml
new file mode 100644
index 00000000..dbb318bb
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_iscsi_info/tasks/main.yml
@@ -0,0 +1,22 @@
+# Test code for the vmware_host_iscsi_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: vmware_host_iscsi_info module test - connect to vCenter
+ include_tasks: iscsi_info_module_test_tasks.yml
+ vars:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+
+- name: vmware_host_iscsi_info module test - connect to ESXi
+ include_tasks: iscsi_info_module_test_tasks.yml
+ vars:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/tasks/main.yml
new file mode 100644
index 00000000..7c97ba50
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_kernel_manager/tasks/main.yml
@@ -0,0 +1,50 @@
+# test code for the vmware_host_kernel_manager module
+# Copyright: (c) 2019, Aaron Longchamps <a.j.longchamps@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: First, set ipv6=0, for consistency
+ vmware_host_kernel_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ kernel_module_name: "tcpip4"
+ kernel_module_option: "ipv6=0"
+
+- name: host connected, module exists, options exist, arguments different
+ vmware_host_kernel_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ kernel_module_name: "tcpip4"
+ kernel_module_option: "ipv6=0"
+ register: my_results_01
+- debug: var=my_results_01
+- name: Check that the provided kernel_module_name has kernel_module_option set
+ assert:
+ that:
+ - "'original_options' in my_results_01['host_kernel_status']['{{ esxi1 }}']"
+ - "my_results_01['host_kernel_status']['{{ esxi1 }}'].original_options == 'ipv6=0'"
+
+- name: host connected, module exists, same options for idempotence test
+ vmware_host_kernel_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ kernel_module_name: "tcpip4"
+ kernel_module_option: "ipv6=0"
+ register: my_results_02
+- name: Check that changed is false
+ assert:
+ that:
+ - not (my_results_02 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/tasks/main.yml
new file mode 100644
index 00000000..d8815802
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown/tasks/main.yml
@@ -0,0 +1,98 @@
+# Test code for the vmware_host_lockdown module.
+# # Copyright: (c) 2021, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Enable lockdown (check mode)
+ vmware_host_lockdown: &enable_lockdown
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: normal
+ check_mode: true
+ register: result_enable_lockdown
+
+- debug:
+ var: result_enable_lockdown
+
+- name: assert that lockdown would be enabled
+ assert:
+ that:
+ - result_enable_lockdown is changed
+
+- name: Enable lockdown
+ vmware_host_lockdown:
+ <<: *enable_lockdown
+ register: result_enable_lockdown
+
+- debug:
+ var: result_enable_lockdown
+
+- name: assert that lockdown is enabled
+ assert:
+ that:
+ - result_enable_lockdown is changed
+
+- name: Enable lockdown again (idempotency)
+ vmware_host_lockdown:
+ <<: *enable_lockdown
+ register: result_enable_lockdown
+
+- debug:
+ var: result_enable_lockdown
+
+- name: assert that lockdown is not changed
+ assert:
+ that:
+ - result_enable_lockdown is not changed
+
+- name: Disable lockdown (check mode)
+ vmware_host_lockdown: &disable_lockdown
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: disabled
+ check_mode: true
+ register: result_disable_lockdown
+
+- debug:
+ var: result_disable_lockdown
+
+- name: assert that lockdown would be disabled
+ assert:
+ that:
+ - result_disable_lockdown is changed
+
+- name: Disable lockdown
+ vmware_host_lockdown:
+ <<: *disable_lockdown
+ register: result_disable_lockdown
+
+- debug:
+ var: result_disable_lockdown
+
+- name: assert that lockdown is disabled
+ assert:
+ that:
+ - result_disable_lockdown is changed
+
+- name: Disable lockdown again (idempotency)
+ vmware_host_lockdown:
+ <<: *disable_lockdown
+ register: result_disable_lockdown
+
+- debug:
+ var: result_disable_lockdown
+
+- name: assert that lockdown is not changed
+ assert:
+ that:
+ - result_disable_lockdown is not changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/tasks/main.yml
new file mode 100644
index 00000000..d89508c5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_lockdown_exceptions/tasks/main.yml
@@ -0,0 +1,195 @@
+# Test code for the vmware_host_lockdown_exceptions module.
+# # Copyright: (c) 2022, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Allow root login in lockdown mode (check mode)
+ community.vmware.vmware_host_lockdown_exceptions: &allow_root
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ exception_users:
+ - "root"
+ state: present
+ check_mode: true
+ register: result_allow_root
+
+- debug:
+ var: result_allow_root
+
+- name: Assert that root would be allowed in lockdown mode
+ assert:
+ that:
+ - result_allow_root is changed
+
+- name: Allow root login in lockdown mode
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *allow_root
+ register: result_allow_root
+
+- debug:
+ var: result_allow_root
+
+- name: Assert that root is allowed in lockdown mode
+ assert:
+ that:
+ - result_allow_root is changed
+
+- name: Allow root login in lockdown mode again (idempotency)
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *allow_root
+ register: result_allow_root
+
+- debug:
+ var: result_allow_root
+
+- name: Assert no changes (idempotency)
+ assert:
+ that:
+ - result_allow_root is not changed
+
+- name: Disallow root login in lockdown mode (check mode)
+ community.vmware.vmware_host_lockdown_exceptions: &disallow_root
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ exception_users:
+ - "root"
+ state: absent
+ check_mode: true
+ register: result_disallow_root
+
+- debug:
+ var: result_disallow_root
+
+- name: Assert that root would be disallowed in lockdown mode
+ assert:
+ that:
+ - result_disallow_root is changed
+
+- name: Disallow root login in lockdown mode
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *disallow_root
+ register: result_disallow_root
+
+- debug:
+ var: result_disallow_root
+
+- name: Assert that root is disallowed in lockdown mode
+ assert:
+ that:
+ - result_disallow_root is changed
+
+- name: Disllow root login in lockdown mode again (idempotency)
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *disallow_root
+ register: result_disallow_root
+
+- debug:
+ var: result_disallow_root
+
+- name: Assert no changes (idempotency)
+ assert:
+ that:
+ - result_disallow_root is not changed
+
+- name: Set the list of exception users to exactly root (check mode)
+ community.vmware.vmware_host_lockdown_exceptions: &set_exception_users
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ exception_users:
+ - "root"
+ state: set
+ check_mode: true
+ register: result_set_exception_users
+
+- debug:
+ var: result_set_exception_users
+
+- name: Assert that root would be allowed in lockdown mode
+ assert:
+ that:
+ - result_set_exception_users is changed
+
+- name: Set the list of exception users to exactly root
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *set_exception_users
+ register: result_set_exception_users
+
+- debug:
+ var: result_set_exception_users
+
+- name: Assert that root is allowed in lockdown mode
+ assert:
+ that:
+ - result_set_exception_users is changed
+
+- name: Set the list of exception users to exactly root again (idempotency)
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *set_exception_users
+ register: result_set_exception_users
+
+- debug:
+ var: result_set_exception_users
+
+- name: Assert no changes (idempotency)
+ assert:
+ that:
+ - result_set_exception_users is not changed
+
+- name: Remove all exception users (check mode)
+ community.vmware.vmware_host_lockdown_exceptions: &remove_all_exception_users
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ exception_users: []
+ state: set
+ check_mode: true
+ register: result_remove_all_exception_users
+
+- debug:
+ var: result_remove_all_exception_users
+
+- name: Assert that all exception users would be removed
+ assert:
+ that:
+ - result_remove_all_exception_users is changed
+
+- name: Remove all exception users
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *remove_all_exception_users
+ register: result_remove_all_exception_users
+
+- debug:
+ var: result_remove_all_exception_users
+
+- name: Assert that all exception users are removed
+ assert:
+ that:
+ - result_remove_all_exception_users is changed
+
+- name: Remove all exception users again (idempotency)
+ community.vmware.vmware_host_lockdown_exceptions:
+ <<: *remove_all_exception_users
+ register: result_remove_all_exception_users
+
+- debug:
+ var: result_remove_all_exception_users
+
+- name: Assert no changes (idempotency)
+ assert:
+ that:
+ - result_remove_all_exception_users is not changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/tasks/main.yml
new file mode 100644
index 00000000..76115868
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle/tasks/main.yml
@@ -0,0 +1,263 @@
+# Test code for the vmware_host_logbundle module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- set_fact:
+ logbundle_archive_file_path: ./esxi-log.tgz
+
+- name: fetch logbundle archive file from ESXi - connect to vCenter
+ vmware_host_logbundle:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ register: fetch_logbundle_result
+
+- assert:
+ that:
+ - fetch_logbundle_result.changed
+ - fetch_logbundle_result.dest is defined
+
+- name: exists check logbundle archive file
+ stat:
+ path: "{{ logbundle_archive_file_path }}"
+ register: exists_check_logbundle_result
+
+- assert:
+ that:
+ - exists_check_logbundle_result.stat.exists
+
+- name: delete logbundle archive file
+ file:
+ path: "{{ logbundle_archive_file_path }}"
+ state: absent
+ register: delete_logbundle_result
+
+- assert:
+ that:
+ - delete_logbundle_result.changed
+
+- name: fetch logbundle archive file from ESXi - connect to ESXi
+ vmware_host_logbundle:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ register: fetch_logbundle_result
+
+- assert:
+ that:
+ - fetch_logbundle_result.changed
+ - fetch_logbundle_result.dest is defined
+
+- name: exists check logbundle archive file
+ stat:
+ path: "{{ logbundle_archive_file_path }}"
+ register: exists_check_logbundle_result
+
+- assert:
+ that:
+ - exists_check_logbundle_result.stat.exists
+
+- name: delete logbundle archive file
+ file:
+ path: "{{ logbundle_archive_file_path }}"
+ state: absent
+ register: delete_logbundle_result
+
+- assert:
+ that:
+ - delete_logbundle_result.changed
+
+- name: fetch logbundle archive file from ESXi use manifests param - connect to vCenter
+ vmware_host_logbundle:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ manifests:
+ - System:Base
+ - VirtualMachines:VirtualMachineStats
+ register: fetch_logbundle_result
+
+- assert:
+ that:
+ - fetch_logbundle_result.changed
+ - fetch_logbundle_result.dest is defined
+
+- name: exists check logbundle archive file
+ stat:
+ path: "{{ logbundle_archive_file_path }}"
+ register: exists_check_logbundle_result
+
+- assert:
+ that:
+ - exists_check_logbundle_result.stat.exists
+
+- name: delete logbundle archive file
+ file:
+ path: "{{ logbundle_archive_file_path }}"
+ state: absent
+ register: delete_logbundle_result
+
+- assert:
+ that:
+ - delete_logbundle_result.changed
+
+- name: fetch logbundle archive file from ESXi use manifests param - connect to ESXi
+ vmware_host_logbundle:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ manifests:
+ - System:Base
+ - VirtualMachines:VirtualMachineStats
+ register: fetch_logbundle_result
+
+- assert:
+ that:
+ - fetch_logbundle_result.changed
+ - fetch_logbundle_result.dest is defined
+
+- name: exists check logbundle archive file
+ stat:
+ path: "{{ logbundle_archive_file_path }}"
+ register: exists_check_logbundle_result
+
+- assert:
+ that:
+ - exists_check_logbundle_result.stat.exists
+
+- name: delete logbundle archive file
+ file:
+ path: "{{ logbundle_archive_file_path }}"
+ state: absent
+ register: delete_logbundle_result
+
+- assert:
+ that:
+ - delete_logbundle_result.changed
+
+- name: fetch logbundle archive file from ESXi use performance_data param - connect to vCenter
+ vmware_host_logbundle:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ performance_data:
+ duration: 10
+ interval: 5
+ retries: 3
+ register: fetch_logbundle_result
+
+- assert:
+ that:
+ - fetch_logbundle_result.changed
+ - fetch_logbundle_result.dest is defined
+
+- name: exists check logbundle archive file
+ stat:
+ path: "{{ logbundle_archive_file_path }}"
+ register: exists_check_logbundle_result
+
+- assert:
+ that:
+ - exists_check_logbundle_result.stat.exists
+
+- name: delete logbundle archive file
+ file:
+ path: "{{ logbundle_archive_file_path }}"
+ state: absent
+ register: delete_logbundle_result
+
+- assert:
+ that:
+ - delete_logbundle_result.changed
+
+- name: fetch logbundle archive file from ESXi use performance_data param - connect to ESXi
+ vmware_host_logbundle:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ performance_data:
+ duration: 10
+ interval: 5
+ retries: 3
+ register: fetch_logbundle_result
+
+- assert:
+ that:
+ - fetch_logbundle_result.changed
+ - fetch_logbundle_result.dest is defined
+
+- name: exists check logbundle archive file
+ stat:
+ path: "{{ logbundle_archive_file_path }}"
+ register: exists_check_logbundle_result
+
+- assert:
+ that:
+ - exists_check_logbundle_result.stat.exists
+
+- name: delete logbundle archive file
+ file:
+ path: "{{ logbundle_archive_file_path }}"
+ state: absent
+ register: delete_logbundle_result
+
+- assert:
+ that:
+ - delete_logbundle_result.changed
+
+- name: error check for manifests(validate) - connect to vCenter
+ vmware_host_logbundle:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ manifests:
+ - example
+ register: fetch_logbundle_result
+ ignore_errors: true
+
+- assert:
+ that:
+ - fetch_logbundle_result.failed
+
+- name: error check for manifests(validate) - connect to ESXi
+ vmware_host_logbundle:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ dest: "{{ logbundle_archive_file_path }}"
+ manifests:
+ - example
+ register: fetch_logbundle_result
+ ignore_errors: true
+
+- assert:
+ that:
+ - fetch_logbundle_result.failed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/tasks/main.yml
new file mode 100644
index 00000000..988a5f01
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_logbundle_info/tasks/main.yml
@@ -0,0 +1,38 @@
+# Test code for the vmware_host_logbundle_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: fetch the manifests for logbundle from ESXi - connect to vCenter
+ vmware_host_logbundle_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: fetch_manifests_result
+
+- debug: var=fetch_manifests_result.manifests
+
+- assert:
+ that:
+ - fetch_manifests_result.manifests | length >= 1
+
+- name: fetch the manifests for logbundle from ESXi - connect to ESXi
+ vmware_host_logbundle_info:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: fetch_manifests_result
+
+- debug: var=fetch_manifests_result.manifests
+
+- assert:
+ that:
+ - fetch_manifests_result.manifests | length >= 1
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/tasks/main.yml
new file mode 100644
index 00000000..99e33c29
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp/tasks/main.yml
@@ -0,0 +1,262 @@
+# Test code for the vmware_host_ntp module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Add NTP server to a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: present
+ ntp_servers:
+ - 192.0.2.1
+ validate_certs: false
+ register: present
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - present.changed is sameas true
+
+- name: Add another NTP server to a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: present
+ ntp_servers:
+ - 198.51.100.1
+ validate_certs: false
+ register: present
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - present.changed is sameas true
+
+- name: Remove NTP server from a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: absent
+ ntp_servers:
+ - 198.51.100.1
+ validate_certs: false
+ register: absent_one
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - absent_one.changed is sameas true
+
+- name: Add more NTP servers to a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: present
+ ntp_servers:
+ - 203.0.113.1
+ - 192.0.2.2
+ - 198.51.100.2
+ validate_certs: false
+ register: present
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - present.changed is sameas true
+
+- name: Remove all NTP servers from a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: absent
+ ntp_servers:
+ - 192.0.2.1
+ - 203.0.113.1
+ - 192.0.2.2
+ - 198.51.100.2
+ validate_certs: false
+ register: absent_all
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - absent_all.changed is sameas true
+
+- name: Configure NTP servers for a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ntp_servers:
+ - 192.0.2.1
+ - 198.51.100.1
+ - 203.0.113.1
+ validate_certs: false
+ register: ntp_servers
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - ntp_servers.changed is sameas true
+
+- name: Configure NTP servers for a host
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ntp_servers:
+ - 192.0.2.2
+ - 198.51.100.2
+ - 203.0.113.2
+ verbose: true
+ validate_certs: false
+ register: ntp_servers
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - ntp_servers.changed is sameas true
+
+- name: Add NTP server to a host in check mode
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: present
+ ntp_servers:
+ - 192.0.2.1
+ validate_certs: false
+ register: present
+ check_mode: true
+
+- name: Make sure that NTP setting has been changed
+ assert:
+ that:
+ - present.changed is sameas true
+
+- name: Remove NTP server to a host in check mode
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: absent
+ ntp_servers:
+ - 192.0.2.1
+ validate_certs: false
+ register: present
+ check_mode: true
+
+- name: Make sure that NTP setting hasn't been changed
+ assert:
+ that:
+ - present.changed is sameas false
+
+- name: Configure NTP servers for a host in check mode
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ ntp_servers:
+ - 192.0.2.1
+ - 198.51.100.1
+ - 203.0.113.1
+ validate_certs: false
+ register: ntp_servers
+ check_mode: true
+
+- name: Make sure that NTP setting will be changed
+ assert:
+ that:
+ - ntp_servers.changed is sameas true
+
+# https://github.com/ansible-collections/community.vmware/pull/588
+- name: The integration tests when ESXi disconnected
+ block:
+ - name: Disconnect ESXi
+ community.vmware.vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: disconnected
+ register: disconnect_esxi_result
+
+ - name: Make sure if ESXi host disconnected
+ assert:
+ that:
+ - disconnect_esxi_result.changed is sameas true
+
+ - name: Add NTP server to disconnected ESXi with check_mode
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ state: present
+ ntp_servers:
+ - 192.0.2.1
+ check_mode: true
+ register: add_ntp_server_disconnected_esxi_check_mode_result
+
+ - name: Make sure if the changed doesn't occur
+ assert:
+ that:
+ - add_ntp_server_disconnected_esxi_check_mode_result.changed is sameas false
+
+ - name: Add NTP server to disconnected ESXi
+ community.vmware.vmware_host_ntp:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ state: present
+ ntp_servers:
+ - 192.0.2.1
+ register: add_ntp_server_disconnected_esxi_result
+
+ - name: Make sure if the changed doesn't occur
+ assert:
+ that:
+ - add_ntp_server_disconnected_esxi_result.changed is sameas false
+
+ - name: Reconnect ESXi
+ community.vmware.vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+ esxi_hostname: '{{ esxi1 }}'
+ state: reconnect
+ register: reconnect_esxi_result
+
+ - name: Make sure if ESXi host reconnected
+ assert:
+ that:
+ - reconnect_esxi_result.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/tasks/main.yml
new file mode 100644
index 00000000..4a8abdec
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ntp_info/tasks/main.yml
@@ -0,0 +1,21 @@
+# Test code for the vmware_host_ntp_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather NTP info about all hosts in given host
+ vmware_host_ntp_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_ntp
+- debug: var=host_ntp
+- assert:
+ that:
+ - host_ntp.hosts_ntp_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/tasks/main.yml
new file mode 100644
index 00000000..329eae16
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_package_info/tasks/main.yml
@@ -0,0 +1,21 @@
+# Test code for the vmware_host_package_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather info about all hosts in given cluster
+ vmware_host_package_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_packages
+- debug: var=host_packages
+- assert:
+ that:
+ - host_packages.hosts_package_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/main.yml
new file mode 100644
index 00000000..6655325e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/main.yml
@@ -0,0 +1,22 @@
+# Test code for the vmware_host_passthrough module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- ansible.builtin.import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Include tasks pre.yml
+ ansible.builtin.include_tasks: pre.yml
+
+- name: Integration test for vmware_host_passthrough_tests module
+ when:
+ - list_of_pci_devices_that_can_be_enabled_passthrough is defined
+ - list_of_pci_devices_that_can_be_enabled_passthrough | length >= 1
+ block:
+ - name: Include tasks vmware_host_passthrough_tests.yml
+ ansible.builtin.include_tasks: vmware_host_passthrough.yml
+
+ - name: Include tasks vmware_host_passthrough_pci_id.yml
+ ansible.builtin.include_tasks: vmware_host_passthrough_pci_id.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/pre.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/pre.yml
new file mode 100644
index 00000000..6311cdbc
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/pre.yml
@@ -0,0 +1,40 @@
+# Test code for the vmware_host_passthrough module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Gather PCI devices info from ESXi host
+ community.vmware.vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - config.pciPassthruInfo
+ - hardware.pciDevice
+ register: pci_devices_result
+
+- name: Set the device_ids variable that includes to be enabled passthrough devices only
+ ansible.builtin.set_fact:
+ device_ids: >-
+ {{ device_ids | default([])
+ + [item]
+ }}
+ loop: "{{ pci_devices_result.ansible_facts.config.pciPassthruInfo }}"
+ when:
+ - item.passthruCapable is sameas true
+
+- name: The block task is collected PCI devices that can be enabled passthrough if the device_ids variable is defined
+ when:
+ - device_ids is defined
+ block:
+ - name: Set the list_of_pci_devices_that_can_be_enabled_passthrough variable
+ ansible.builtin.set_fact:
+ list_of_pci_devices_that_can_be_enabled_passthrough: >-
+ {{ list_of_pci_devices_that_can_be_enabled_passthrough | default([])
+ + [item.1]
+ }}
+ loop: "{{ device_ids | product(pci_devices_result.ansible_facts.hardware.pciDevice) | list }}"
+ when:
+ - item.0.id == item.1.id
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough.yml
new file mode 100644
index 00000000..5241b98a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough.yml
@@ -0,0 +1,229 @@
+# Test code for the vmware_host_passthrough module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Set the target_pci_device variable to execute the integration tests
+ ansible.builtin.set_fact:
+ target_pci_device: "{{ list_of_pci_devices_that_can_be_enabled_passthrough.0.deviceName }}"
+
+- name: Enable passthrough of PCI device with check_mode and diff without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ check_mode: true
+ diff: true
+ register: enable_passthrough_check_mode_diff_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_check_mode_diff_result.changed is sameas true
+
+- name: Enable passthrough of PCI device with check_mode without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ check_mode: true
+ register: enable_passthrough_check_mode_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_check_mode_result.changed is sameas true
+
+- name: Enable passthrough of PCI device without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ register: enable_passthrough_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_result.changed is sameas true
+ - enable_passthrough_result.passthrough_configs is defined
+ - enable_passthrough_result.passthrough_configs | length >= 1
+
+- name: Wait 10 sec because need a little time to enable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Enable passthrough of PCI device without the cluster (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ register: enable_passthrough_indempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_indempotency_result.changed is sameas false
+
+- name: Disable passthrough of PCI device without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_result.changed is sameas true
+
+- name: Wait 10 sec because need a little time to disable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Disable passthrough of PCI device without the cluster (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_idempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_idempotency_result.changed is sameas false
+
+- name: Enable passthrough of PCI device with check_mode and diff without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ check_mode: true
+ diff: true
+ register: enable_passthrough_cluster_check_mode_diff_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_check_mode_diff_result.changed is sameas true
+
+- name: Enable passthrough of PCI device with check_mode without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ check_mode: true
+ register: enable_passthrough_cluster_check_mode_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_check_mode_result.changed is sameas true
+
+- name: Enable passthrough of PCI device without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ register: enable_passthrough_cluster_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_result.changed is sameas true
+ - enable_passthrough_cluster_result.passthrough_configs is defined
+ - enable_passthrough_cluster_result.passthrough_configs | length >= 1
+
+- name: Wait 10 sec because need a little time to enable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Enable passthrough of PCI device without the esxi_hostname (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ register: enable_passthrough_cluster_indempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_indempotency_result.changed is sameas false
+
+- name: Disable passthrough of PCI device without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_cluster_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_cluster_result.changed is sameas true
+
+- name: Wait 10 sec because need a little time to disable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Disable passthrough of PCI device without the esxi_hostname (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device_name: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_cluster_idempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_cluster_idempotency_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough_pci_id.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough_pci_id.yml
new file mode 100644
index 00000000..799f223b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/vmware_host_passthrough_pci_id.yml
@@ -0,0 +1,229 @@
+# Test code for the vmware_host_passthrough module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Set the target_pci_device variable to execute the integration tests
+ ansible.builtin.set_fact:
+ target_pci_device: "{{ list_of_pci_devices_that_can_be_enabled_passthrough.0.id }}"
+
+- name: Enable passthrough of PCI device with check_mode and diff without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ check_mode: true
+ diff: true
+ register: enable_passthrough_check_mode_diff_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_check_mode_diff_result.changed is sameas true
+
+- name: Enable passthrough of PCI device with check_mode without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ check_mode: true
+ register: enable_passthrough_check_mode_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_check_mode_result.changed is sameas true
+
+- name: Enable passthrough of PCI device without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ register: enable_passthrough_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_result.changed is sameas true
+ - enable_passthrough_result.passthrough_configs is defined
+ - enable_passthrough_result.passthrough_configs | length >= 1
+
+- name: Wait 10 sec because need a little time to enable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Enable passthrough of PCI device without the cluster (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ register: enable_passthrough_indempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_indempotency_result.changed is sameas false
+
+- name: Disable passthrough of PCI device without the cluster
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_result.changed is sameas true
+
+- name: Wait 10 sec because need a little time to disable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Disable passthrough of PCI device without the cluster (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_idempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_idempotency_result.changed is sameas false
+
+- name: Enable passthrough of PCI device with check_mode and diff without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ check_mode: true
+ diff: true
+ register: enable_passthrough_cluster_check_mode_diff_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_check_mode_diff_result.changed is sameas true
+
+- name: Enable passthrough of PCI device with check_mode without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ check_mode: true
+ register: enable_passthrough_cluster_check_mode_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_check_mode_result.changed is sameas true
+
+- name: Enable passthrough of PCI device without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ register: enable_passthrough_cluster_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_result.changed is sameas true
+ - enable_passthrough_cluster_result.passthrough_configs is defined
+ - enable_passthrough_cluster_result.passthrough_configs | length >= 1
+
+- name: Wait 10 sec because need a little time to enable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Enable passthrough of PCI device without the esxi_hostname (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ register: enable_passthrough_cluster_indempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - enable_passthrough_cluster_indempotency_result.changed is sameas false
+
+- name: Disable passthrough of PCI device without the esxi_hostname
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_cluster_result
+
+- name: Make sure if the change has occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_cluster_result.changed is sameas true
+
+- name: Wait 10 sec because need a little time to disable completely passthrough of PCI device
+ ansible.builtin.pause:
+ seconds: 10
+
+- name: Disable passthrough of PCI device without the esxi_hostname (idempotency)
+ community.vmware.vmware_host_passthrough:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster: "{{ ccr1 }}"
+ devices:
+ - device: "{{ target_pci_device }}"
+ state: absent
+ register: disable_passthrough_cluster_idempotency_result
+
+- name: Make sure if the change hasn't occurred
+ ansible.builtin.assert:
+ that:
+ - disable_passthrough_cluster_idempotency_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml
new file mode 100644
index 00000000..822936a1
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powermgmt_policy/tasks/main.yml
@@ -0,0 +1,102 @@
+# Test code for the vmware_host_powermgmt_policy module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Run tests and clean up
+ block:
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+ - name: Reset all the hosts to balanced
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ policy: balanced
+ validate_certs: false
+
+ - name: Set the Power Management Policy for esxi1
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ policy: high-performance
+ validate_certs: false
+ register: host_result
+ - debug: var=host_result
+ - name: Ensure Power Management Policy for esxi1
+ assert:
+ that:
+ - host_result.result['{{ esxi1 }}'].current_state == "high-performance"
+
+ - name: Reset all the hosts to balanced
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ policy: balanced
+ validate_certs: false
+ register: all_hosts_result
+ - debug: var=all_hosts_result
+ - name: Ensure Power Management Policy is changed for all hosts of {{ ccr1 }}
+ assert:
+ that:
+ - all_hosts_result is changed
+ - all_hosts_result.result is defined
+
+ - name: Reset all the hosts to balanced
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ policy: balanced
+ validate_certs: false
+
+ - name: Set the Power Management Policy for esxi1 in check mode
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ policy: high-performance
+ validate_certs: false
+ register: host_result
+ check_mode: true
+ - debug: var=host_result
+ - name: Ensure Power Management Policy for esxi1 in check mode
+ assert:
+ that:
+ - host_result is changed
+ - host_result.result is defined
+
+ - name: Set the Power Management Policy on all hosts of {{ ccr1 }}
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ policy: balanced
+ validate_certs: false
+ register: all_hosts_result
+ check_mode: true
+ - debug: var=all_hosts_result
+ - name: Ensure we are still using the 'balanced' mode
+ assert:
+ that:
+ - not (all_hosts_result is changed)
+ - "all_hosts_result.result['{{ esxi1 }}'].current_state == 'balanced'"
+ always:
+ - name: Reset all the hosts to balanced
+ vmware_host_powermgmt_policy:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ policy: balanced
+ validate_certs: false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/aliases
new file mode 100644
index 00000000..ad593838
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/tasks/main.yml
new file mode 100644
index 00000000..e1a1f0c3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_powerstate/tasks/main.yml
@@ -0,0 +1,31 @@
+# Test code for the vmware_host_powerstate module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+# https://kb.vmware.com/s/article/2001651?lang=en_US
+# It seems like we need a Power managment interface to be able to run the
+# module.
+# I currently get:
+# "Failed to power down '192.168.123.7' to standby as host system due to : ('The operation is not supported on the object.', None)"
+- name: Restart Host
+ vmware_host_powerstate:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ state: power-down-to-standby
+ esxi_hostname: '{{ esxi1 }}'
+ force: true
+ register: host_powerstate
+
+- debug: var=host_powerstate
+
+- assert:
+ that:
+ - host_powerstate.results is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/tasks/main.yml
new file mode 100644
index 00000000..540c6caf
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scanhba/tasks/main.yml
@@ -0,0 +1,23 @@
+# Test code for the vmware_host_scanhba module.
+# Copyright: (c) 2019, Michael Eaton <me@michaeleaton.me>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Recan HBA's for an entire cluster (there should be at least one host as above)
+ vmware_host_scanhba:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: '{{ ccr1 }}'
+ refresh_storage: false
+ register: host_scan_results
+- debug: msg="{{ host_scan_results }}"
+- name: ensure a change occured (as in the scan happened) and the task didnt fail
+ assert:
+ that:
+ - host_scan_results.changed
+ - not host_scan_results.failed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/aliases
new file mode 100644
index 00000000..fb5c49b9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml
new file mode 100644
index 00000000..fc0e930f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml
@@ -0,0 +1,71 @@
+---
+# Test code for the vmware_host_scsidisk_info module.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+
+# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather SCSI disks info about all hosts in given cluster
+ vmware_host_scsidisk_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ register: all_hosts_disk_result
+
+- name: Ensure SCSI disks info are gathered for all hosts in given cluster
+ assert:
+ that:
+ - all_hosts_disk_result.hosts_scsidisk_info
+ - not all_hosts_disk_result.changed
+
+- name: Gather SCSI disks info about host system
+ vmware_host_scsidisk_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: all_hosts_disk_result
+
+- name: Ensure SCSI disks info are gathered about host system
+ assert:
+ that:
+ - all_hosts_disk_result.hosts_scsidisk_info
+ - not all_hosts_disk_result.changed
+
+- name: Gather SCSI disks info about all hosts in given cluster in check mode
+ vmware_host_scsidisk_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ register: all_hosts_disk_result_check_mode
+ check_mode: true
+
+- name: Ensure SCSI disks info are gathered for all hosts in given cluster
+ assert:
+ that:
+ - all_hosts_disk_result_check_mode.hosts_scsidisk_info
+ - not all_hosts_disk_result_check_mode.changed
+
+- name: Ensure SCSI disks info about host system in check mode
+ vmware_host_scsidisk_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: all_hosts_disk_result_check_mode
+ check_mode: true
+
+- name: Ensure SCSI disks info are gathered about host system
+ assert:
+ that:
+ - all_hosts_disk_result_check_mode.hosts_scsidisk_info
+ - not all_hosts_disk_result_check_mode.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/tasks/main.yml
new file mode 100644
index 00000000..20b146bc
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_info/tasks/main.yml
@@ -0,0 +1,36 @@
+# Test code for the vmware_host_service_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- &host_srv_info
+ name: Check info about all hosts in given cluster
+ vmware_host_service_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_services
+
+- debug:
+ var: host_services
+
+- assert:
+ that:
+ - host_services.host_service_info is defined
+
+- <<: *host_srv_info
+ name: Check info about all hosts in given cluster in check mode
+ check_mode: true
+
+- debug:
+ var: host_services
+
+- assert:
+ that:
+ - host_services.host_service_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/aliases
new file mode 100644
index 00000000..1e830fc4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
+disabled
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/tasks/main.yml
new file mode 100644
index 00000000..052b27c6
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_service_manager/tasks/main.yml
@@ -0,0 +1,82 @@
+# Test code for the vmware_host_service_manager module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Start ntpd service on all hosts in given cluster
+ vmware_host_service_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ service_name: ntpd
+ state: present
+ register: all_hosts_result
+- debug: var=all_hosts_result
+
+- name: Stop ntpd service on a given host
+ vmware_host_service_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ service_name: ntpd
+ state: absent
+ register: single_hosts_result
+- name: ensure info are gathered
+ assert:
+ that:
+ - single_hosts_result is changed
+
+- name: Start ntpd service on all hosts in given cluster in check mode
+ vmware_host_service_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ service_name: ntpd
+ state: present
+ register: all_hosts_result_check_mode
+ check_mode: true
+- name: ensure info are gathered for all hosts
+ assert:
+ that:
+ - all_hosts_result_check_mode is changed
+
+- name: Stop ntpd service on a given host in check mode
+ vmware_host_service_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ service_name: ntpd
+ state: absent
+ register: single_hosts_result_check_mode
+ check_mode: true
+- name: ensure info are gathered
+ assert:
+ that:
+ - not (single_hosts_result_check_mode is changed)
+
+- name: Start ntpd service on all hosts in given cluster
+ vmware_host_service_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ service_name: ntpd
+ state: present
+ register: all_hosts_result_check_mode
+- name: finally, ensure ntp is running on the cluster
+ assert:
+ that:
+ - all_hosts_result_check_mode is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml
new file mode 100644
index 00000000..a1fad114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml
@@ -0,0 +1,70 @@
+# Test code for the vmware_host_snmp.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+# SNMP works only with standalone ESXi server
+- name: Enable and configure SNMP community in check mode
+ vmware_host_snmp:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ community: [ test ]
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled_check_mode
+ check_mode: true
+- debug: var=snmp_enabled_check_mode
+- assert:
+ that:
+ - snmp_enabled_check_mode is defined
+ - snmp_enabled_check_mode.changed
+
+- name: Enable and configure SNMP community
+ vmware_host_snmp:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ community: [ test ]
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled
+- debug: var=snmp_enabled
+- assert:
+ that:
+ - snmp_enabled is defined
+ - snmp_enabled.changed
+
+- name: Enable and configure SNMP system contact and location
+ vmware_host_snmp:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ sys_contact: "admin@testemail.com"
+ sys_location: "Austin, USA"
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled_sys_options
+- debug: var=snmp_enabled_sys_options
+- assert:
+ that:
+ - snmp_enabled_sys_options is defined
+ - snmp_enabled_sys_options.changed
+
+- name: Disable SNMP
+ vmware_host_snmp:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ state: disabled
+ validate_certs: false
+ register: snmp_disabled
+- debug: var=snmp_disabled
+- assert:
+ that:
+ - snmp_disabled is defined
+ - snmp_disabled.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/aliases
new file mode 100644
index 00000000..c90d094d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/tasks/main.yml
new file mode 100644
index 00000000..3a57a0ba
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_sriov/tasks/main.yml
@@ -0,0 +1,118 @@
+# Test code for the module vmware_host_sriov
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather vmnic info
+ community.vmware.vmware_host_vmnic_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ sriov: true
+ register: host_vmnics
+
+- name: Extract vmnic0 info
+ set_fact:
+ vmnic0_info: "{{ item }}"
+ loop: "{{ host_vmnics.hosts_vmnics_info[esxi1].vmnic_details }}"
+ when: item.device == "vmnic0"
+
+- when: vmnic0_info.sriov_status == "Enabled"
+ block:
+ - name: enable SR-IOV on vmnic0 with 8 functions
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: true
+ num_virt_func: 8
+ register: present
+ - debug: var=present
+
+ - name: enable SR-IOV on already enabled interface vmnic0
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: true
+ num_virt_func: 8
+ register: present
+ - debug: var=present
+
+ - name: enable SR-IOV on vmnic0 with big num. of functions
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: true
+ num_virt_func: 100
+ ignore_errors: true
+ register: present
+ - debug: var=present
+
+ - name: change num of functions only
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: true
+ num_virt_func: 10
+ register: present
+ - debug: var=present
+
+ - name: disable SR-IOV on vmnic0
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: false
+ num_virt_func: 0
+ register: present
+ - debug: var=present
+
+ - name: change num of functions only, check mode
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: true
+ num_virt_func: 10
+ check_mode: true
+ register: present
+ - debug: var=present
+
+ - name: disable SR-IOV with num_virt_func == 1, check mode
+ vmware_host_sriov:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: "{{ esxi1 }}"
+ validate_certs: false
+ vmnic: vmnic0
+ sriov_on: false
+ num_virt_func: 1
+ check_mode: true
+ register: present
+ - debug: var=present
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/tasks/main.yml
new file mode 100644
index 00000000..84fa8982
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_ssl_info/tasks/main.yml
@@ -0,0 +1,70 @@
+# Test code for the vmware_host_ssl_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: Gather SSL info about ESXi machine
+ vmware_host_ssl_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: ssl_info
+
+- debug: var=ssl_info
+
+- assert:
+ that:
+ - ssl_info.host_ssl_info is defined
+
+- name: Gather info about all hostsystem in given cluster
+ vmware_host_ssl_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ register: ssl_info
+
+- debug: var=ssl_info
+
+- assert:
+ that:
+ - ssl_info.host_ssl_info is defined
+
+- name: Gather SSL info about ESXi machine in check mode
+ vmware_host_ssl_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ check_mode: true
+ register: ssl_info
+
+- debug: var=ssl_info
+
+- assert:
+ that:
+ - ssl_info.host_ssl_info is defined
+
+- name: Gather info about all hostsystem in given cluster in check mode ee
+ vmware_host_ssl_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ check_mode: true
+ register: ssl_info
+
+- debug: var=ssl_info
+
+- assert:
+ that:
+ - ssl_info.host_ssl_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/aliases
new file mode 100644
index 00000000..1e830fc4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
+disabled
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/destroy.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/destroy.yml
new file mode 100644
index 00000000..f52cee87
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/destroy.yml
@@ -0,0 +1,54 @@
+# Test code for the vmware_host_tcpip_stacks module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: destroy vmkernel for provisioning
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vswitch_name: "{{ switch1 }}"
+ portgroup_name: provisioning
+ device: "{{ provisioning_vmk }}"
+ network:
+ type: static
+ ip_address: 100.64.0.1
+ subnet_mask: 255.255.255.0
+ tcpip_stack: provisioning
+ state: absent
+ ignore_errors: true
+
+- name: destroy vmkernel for vmotion
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vswitch_name: "{{ switch1 }}"
+ portgroup_name: vmotion
+ device: "{{ vmotion_vmk }}"
+ network:
+ type: static
+ ip_address: 100.64.1.1
+ subnet_mask: 255.255.255.0
+ tcpip_stack: vmotion
+ state: absent
+ ignore_errors: true
+
+- name: destroy portgroups for the test
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ hosts: "{{ esxi_hosts }}"
+ switch: "{{ switch1 }}"
+ portgroup: "{{ item }}"
+ state: absent
+ ignore_errors: true
+ loop:
+ - provisioning
+ - vmotion
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/main.yml
new file mode 100644
index 00000000..e0b9e0b7
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/main.yml
@@ -0,0 +1,17 @@
+# Test code for the vmware_host_tcpip_stacks module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_switch: true
+
+- name: include tasks pre.yml
+ include_tasks: pre.yml
+
+- block:
+ - include_tasks: vmware_host_tcpip_stacks_tests.yml
+ always:
+ - include_tasks: destroy.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/pre.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/pre.yml
new file mode 100644
index 00000000..5bb32c07
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/pre.yml
@@ -0,0 +1,95 @@
+# Test code for the vmware_host_tcpip_stacks module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: add portgroups for the test
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ hosts: "{{ esxi_hosts }}"
+ switch: "{{ switch1 }}"
+ portgroup: "{{ item }}"
+ state: present
+ register: portgroups_result
+ loop:
+ - provisioning
+ - vmotion
+
+- name: Make sure if the portgroups are created
+ assert:
+ that:
+ - portgroups_result.changed is sameas true
+
+- name: add vmkernel for provisioning
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vswitch_name: "{{ switch1 }}"
+ portgroup_name: provisioning
+ network:
+ type: static
+ ip_address: 100.64.0.1
+ subnet_mask: 255.255.255.0
+ tcpip_stack: provisioning
+ state: present
+ register: vmkernel_provisioning_result
+
+- name: Make sure if the vmkernel is created for provisioning
+ assert:
+ that:
+ - vmkernel_provisioning_result.changed is sameas true
+
+- name: add vmkernel for vmotion
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vswitch_name: "{{ switch1 }}"
+ portgroup_name: vmotion
+ network:
+ type: static
+ ip_address: 100.64.1.1
+ subnet_mask: 255.255.255.0
+ tcpip_stack: vmotion
+ state: present
+ register: vmkernel_vmotion_result
+
+- name: Make sure if the vmkernel is created for vmotion
+ assert:
+ that:
+ - vmkernel_vmotion_result.changed is sameas true
+
+- name: Gather vmk info
+ vmware_vmkernel_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ register: vmk0_info_result
+
+- name: set the variable of vmk0 ipaddr
+ set_fact:
+ vmk0_ipaddr: "{{ item.ipv4_address }}"
+ loop: "{{ vmk0_info_result.host_vmk_info[esxi_hosts[0]] }}"
+ when:
+ - item.device == "vmk0"
+
+- name: set the variable for each vmk
+ set_fact:
+ provisioning_vmk: "{{ vmkernel_provisioning_result.device }}"
+ vmotion_vmk: "{{ vmkernel_vmotion_result.device }}"
+
+- name: Make sure if defined the variables
+ assert:
+ that:
+ - vmk0_ipaddr is defined
+ - provisioning_vmk is defined
+ - vmotion_vmk is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/vmware_host_tcpip_stacks_tests.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/vmware_host_tcpip_stacks_tests.yml
new file mode 100644
index 00000000..eebe0a46
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_tcpip_stacks/tasks/vmware_host_tcpip_stacks_tests.yml
@@ -0,0 +1,327 @@
+# Test code for the vmware_host_tcpip_stacks module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Update the default tcpip stack config with check_mode and diff
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ default:
+ hostname: examplehost
+ domain: example.com
+ preferred_dns: 8.8.8.8
+ alternate_dns: 9.9.9.9
+ search_domains:
+ - example.com
+ gateway: "{{ vmk0_ipaddr }}"
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ check_mode: true
+ diff: true
+ register: update_default_config_check_mode_diff_result
+
+- name: Make sure if changes will occur
+ assert:
+ that:
+ - update_default_config_check_mode_diff_result.changed is sameas true
+ - update_default_config_check_mode_diff_result.diff is defined
+
+- name: Update the default tcpip stack config
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ default:
+ hostname: examplehost
+ domain: example.com
+ preferred_dns: 8.8.8.8
+ alternate_dns: 9.9.9.9
+ search_domains:
+ - example.com
+ gateway: "{{ vmk0_ipaddr }}"
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ register: update_default_config_result
+
+- name: Make sure if the default tcpip stack config is updated
+ assert:
+ that:
+ - update_default_config_result.changed is sameas true
+ - update_default_config_result.default is defined
+ - update_default_config_result.default.hostname == "examplehost"
+ - update_default_config_result.default.domain == "example.com"
+ - update_default_config_result.default.preferred_dns == "8.8.8.8"
+ - update_default_config_result.default.alternate_dns == "9.9.9.9"
+ - update_default_config_result.default.search_domains.0 == "example.com"
+ - update_default_config_result.default.gateway == vmk0_ipaddr
+ - update_default_config_result.default.congestion_algorithm == "cubic"
+ - update_default_config_result.default.max_num_connections == 12000
+
+- name: Update the default tcpip stack config (idempotency)
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ default:
+ hostname: examplehost
+ domain: example.com
+ preferred_dns: 8.8.8.8
+ alternate_dns: 9.9.9.9
+ search_domains:
+ - example.com
+ gateway: "{{ vmk0_ipaddr }}"
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ register: update_default_config_idempotency_result
+
+- name: Make sure if the default tcpip stack config isn't updated
+ assert:
+ that:
+ - update_default_config_idempotency_result.changed is sameas false
+
+- name: Update the provisioning tcpip stack config with check_mode and diff
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ provisioning:
+ gateway: 100.64.0.1
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ check_mode: true
+ diff: true
+ register: update_provisioning_config_check_mode_diff_result
+
+- name: Make sure if changes will occur
+ assert:
+ that:
+ - update_provisioning_config_check_mode_diff_result.changed is sameas true
+ - update_provisioning_config_check_mode_diff_result.diff is defined
+
+- name: Update the provisioning tcpip stack config
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ provisioning:
+ gateway: 100.64.0.1
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ register: update_provisioning_config
+
+- debug: var=update_provisioning_config
+
+- name: Make sure if the provisioning tcpip stack config is updated
+ assert:
+ that:
+ - update_provisioning_config.changed is sameas true
+ - update_provisioning_config.provisioning.gateway == "100.64.0.1"
+ - update_provisioning_config.provisioning.congestion_algorithm == "cubic"
+ - update_provisioning_config.provisioning.max_num_connections == 12000
+
+- name: Update the provisioning tcpip stack config (idempotency)
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ provisioning:
+ gateway: 100.64.0.1
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ register: update_provisioning_idempotency_config
+
+- name: Make sure if the provisioning tcpip stack config isn't updated
+ assert:
+ that:
+ - update_provisioning_idempotency_config.changed is sameas false
+
+- name: Update the vmotion tcpip stack config with check_mode and diff
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vmotion:
+ gateway: 100.64.1.1
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ check_mode: true
+ diff: true
+ register: update_vmotion_config_check_mode_diff_result
+
+- name: Make sure if changes will occur
+ assert:
+ that:
+ - update_vmotion_config_check_mode_diff_result.changed is sameas true
+ - update_vmotion_config_check_mode_diff_result.diff is defined
+
+- name: Update the vmotion tcpip stack config
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vmotion:
+ gateway: 100.64.1.1
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ register: update_vmotion_config
+
+- name: Make sure if the vmotion tcpip stack config is updated
+ assert:
+ that:
+ - update_vmotion_config.changed is sameas true
+ - update_vmotion_config.vmotion.gateway == "100.64.1.1"
+ - update_vmotion_config.vmotion.congestion_algorithm == "cubic"
+ - update_vmotion_config.vmotion.max_num_connections == 12000
+
+- name: Update the vmotion tcpip stack config (idempotency)
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ vmotion:
+ gateway: 100.64.1.1
+ congestion_algorithm: cubic
+ max_num_connections: 12000
+ register: update_vmotion_idempotency_config
+
+- name: Make sure if the vmotion tcpip stack config isn't updated
+ assert:
+ that:
+ - update_vmotion_idempotency_config.changed is sameas false
+
+- name: Update all tcpip stack config with check_mode and diff
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ default:
+ hostname: examplehost
+ domain: example.com
+ preferred_dns: 9.9.9.9
+ alternate_dns: 8.8.8.8
+ search_domains:
+ - example.com
+ - hoge.com
+ gateway: "{{ vmk0_ipaddr }}"
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ provisioning:
+ gateway: 100.64.0.2
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ vmotion:
+ gateway: 100.64.1.2
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ check_mode: true
+ diff: true
+ register: update_all_config_check_mode_diff_result
+
+- name: Make sure if changes will occur
+ assert:
+ that:
+ - update_all_config_check_mode_diff_result.changed is sameas true
+ - update_all_config_check_mode_diff_result.diff is defined
+
+- name: Update all tcpip stack config
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ default:
+ hostname: examplehost
+ domain: example.com
+ preferred_dns: 9.9.9.9
+ alternate_dns: 8.8.8.8
+ search_domains:
+ - example.com
+ - hoge.com
+ gateway: "{{ vmk0_ipaddr }}"
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ provisioning:
+ gateway: 100.64.0.2
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ vmotion:
+ gateway: 100.64.1.2
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ register: update_all_config_result
+
+- name: Make sure if all tcpip stack config is updated
+ assert:
+ that:
+ - update_all_config_result.changed is sameas true
+ - update_all_config_result.default is defined
+ - update_all_config_result.default.hostname == "examplehost"
+ - update_all_config_result.default.domain == "example.com"
+ - update_all_config_result.default.preferred_dns == "9.9.9.9"
+ - update_all_config_result.default.alternate_dns == "8.8.8.8"
+ - update_all_config_result.default.search_domains.0 == "example.com"
+ - update_all_config_result.default.search_domains.1 == "hoge.com"
+ - update_all_config_result.default.gateway == vmk0_ipaddr
+ - update_all_config_result.default.congestion_algorithm == "newreno"
+ - update_all_config_result.default.max_num_connections == 11000
+ - update_all_config_result.provisioning.gateway == "100.64.0.2"
+ - update_all_config_result.provisioning.congestion_algorithm == "newreno"
+ - update_all_config_result.provisioning.max_num_connections == 11000
+ - update_all_config_result.vmotion.gateway == "100.64.1.2"
+ - update_all_config_result.vmotion.congestion_algorithm == "newreno"
+ - update_all_config_result.vmotion.max_num_connections == 11000
+
+- name: Update all tcpip stack config (idempotency)
+ vmware_host_tcpip_stacks:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ default:
+ hostname: examplehost
+ domain: example.com
+ preferred_dns: 9.9.9.9
+ alternate_dns: 8.8.8.8
+ search_domains:
+ - example.com
+ - hoge.com
+ gateway: "{{ vmk0_ipaddr }}"
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ provisioning:
+ gateway: 100.64.0.2
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ vmotion:
+ gateway: 100.64.1.2
+ congestion_algorithm: newreno
+ max_num_connections: 11000
+ register: update_all_config_idempotency_result
+
+- name: Make sure if all tcpip stack config isn't updated
+ assert:
+ that:
+ - update_all_config_idempotency_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/main.yml
new file mode 100644
index 00000000..c2298a7a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/main.yml
@@ -0,0 +1,14 @@
+# Test code for the vmware_host_user_manager module.
+# Copyright: (c) 2022, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Import operate_user_via_vcenter tasks
+ import_tasks: operate_user_via_vcenter.yml
+
+- name: Import operate_user_via_ESXi tasks
+ import_tasks: operate_user_via_ESXi.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_ESXi.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_ESXi.yml
new file mode 100644
index 00000000..6bf6a371
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_ESXi.yml
@@ -0,0 +1,196 @@
+# Test code for the vmware_host_user_manager module.
+# Copyright: (c) 2022, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Add new local user with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass
+ user_description: example user
+ state: present
+ check_mode: true
+ register: add_new_user_result_check_mode
+
+- name: Guaranteed new local user additional
+ assert:
+ that:
+ - add_new_user_result_check_mode.changed is sameas true
+
+- name: Add new local user
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass
+ user_description: example user
+ state: present
+ register: add_new_user_result
+
+- name: Guaranteed that added the new local user
+ assert:
+ that:
+ - add_new_user_result.changed is sameas true
+
+- name: Add new local user for idempotency test
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass
+ user_description: example user
+ state: present
+ register: add_new_user_result_idempotency
+
+- name: Guaranteed that doesn't occur the changed
+ assert:
+ that:
+ - add_new_user_result_idempotency.changed is sameas false
+
+- name: Update the local user description with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_description: example user111
+ state: present
+ check_mode: true
+ register: update_user_description_result_check_mode
+
+- name: Guaranteed the local user description updation
+ assert:
+ that:
+ - update_user_description_result_check_mode.changed is sameas true
+
+- name: Update the local user description
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_description: example user111
+ state: present
+ register: update_user_description_result
+
+- name: Guaranteed that updated the local user description
+ assert:
+ that:
+ - update_user_description_result.changed is sameas true
+
+- name: Update the local user description for idempotency test
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_description: example user111
+ state: present
+ register: update_user_description_result_idempotency
+
+- name: Guaranteed that doesn't occur the changed
+ assert:
+ that:
+ - update_user_description_result_idempotency.changed is sameas false
+
+- name: Update the local user password with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass222
+ override_user_password: true
+ state: present
+ check_mode: true
+ register: update_user_password_result_check_mode
+
+- name: Guaranteed the local user password updation
+ assert:
+ that:
+ - update_user_password_result_check_mode.changed is sameas true
+
+- name: Update the local user password
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass222
+ override_user_password: true
+ state: present
+ register: update_user_password_result
+
+- name: Guaranteed that updated the local user password
+ assert:
+ that:
+ - update_user_password_result.changed is sameas true
+
+- name: Delete the local user with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ state: absent
+ check_mode: true
+ register: delete_user_result_check_mode
+
+- name: Guaranteed new local user deletion
+ assert:
+ that:
+ - delete_user_result_check_mode.changed is sameas true
+
+- name: Delete new local user
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ state: absent
+ register: delete_new_user_result
+
+- name: Guaranteed that deleted the local user
+ assert:
+ that:
+ - delete_new_user_result.changed is sameas true
+
+- name: Delete the local user for idempotency test
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ state: absent
+ register: delete_user_result_idempotency
+
+- name: Guaranteed that doesn't occur the changed
+ assert:
+ that:
+ - delete_user_result_idempotency.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_vcenter.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_vcenter.yml
new file mode 100644
index 00000000..0a076624
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_user_manager/tasks/operate_user_via_vcenter.yml
@@ -0,0 +1,196 @@
+# Test code for the vmware_host_user_manager module.
+# Copyright: (c) 2022, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Add new local user with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass
+ user_description: example user
+ state: present
+ check_mode: true
+ register: add_new_user_result_check_mode
+
+- name: Guaranteed new local user additional
+ assert:
+ that:
+ - add_new_user_result_check_mode.changed is sameas true
+
+- name: Add new local user
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass
+ user_description: example user
+ state: present
+ register: add_new_user_result
+
+- name: Guaranteed that added the new local user
+ assert:
+ that:
+ - add_new_user_result.changed is sameas true
+
+- name: Add new local user for idempotency test
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass
+ user_description: example user
+ state: present
+ register: add_new_user_result_idempotency
+
+- name: Guaranteed that doesn't occur the changed
+ assert:
+ that:
+ - add_new_user_result_idempotency.changed is sameas false
+
+- name: Update the local user description with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_description: example user111
+ state: present
+ check_mode: true
+ register: update_user_description_result_check_mode
+
+- name: Guaranteed the local user description updation
+ assert:
+ that:
+ - update_user_description_result_check_mode.changed is sameas true
+
+- name: Update the local user description
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_description: example user111
+ state: present
+ register: update_user_description_result
+
+- name: Guaranteed that updated the local user description
+ assert:
+ that:
+ - update_user_description_result.changed is sameas true
+
+- name: Update the local user description for idempotency test
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_description: example user111
+ state: present
+ register: update_user_description_result_idempotency
+
+- name: Guaranteed that doesn't occur the changed
+ assert:
+ that:
+ - update_user_description_result_idempotency.changed is sameas false
+
+- name: Update the local user password with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass222
+ override_user_password: true
+ state: present
+ check_mode: true
+ register: update_user_password_result_check_mode
+
+- name: Guaranteed the local user password updation
+ assert:
+ that:
+ - update_user_password_result_check_mode.changed is sameas true
+
+- name: Update the local user password
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ user_password: Vmware!1@pass222
+ override_user_password: true
+ state: present
+ register: update_user_password_result
+
+- name: Guaranteed that updated the local user password
+ assert:
+ that:
+ - update_user_password_result.changed is sameas true
+
+- name: Delete the local user with check_mode
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ state: absent
+ check_mode: true
+ register: delete_user_result_check_mode
+
+- name: Guaranteed new local user deletion
+ assert:
+ that:
+ - delete_user_result_check_mode.changed is sameas true
+
+- name: Delete new local user
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ state: absent
+ register: delete_new_user_result
+
+- name: Guaranteed that deleted the local user
+ assert:
+ that:
+ - delete_new_user_result.changed is sameas true
+
+- name: Delete the local user for idempotency test
+ community.vmware.vmware_host_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ user_name: example
+ state: absent
+ register: delete_user_result_idempotency
+
+- name: Guaranteed that doesn't occur the changed
+ assert:
+ that:
+ - delete_user_result_idempotency.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/tasks/main.yml
new file mode 100644
index 00000000..70d60198
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmhba_info/tasks/main.yml
@@ -0,0 +1,36 @@
+# Test code for the vmware_host_vmhba_info module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- &vmhba_data
+ name: Gather vmhba info
+ vmware_host_vmhba_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_vmhbas
+
+- debug:
+ var: host_vmhbas
+
+- assert:
+ that:
+ - host_vmhbas.hosts_vmhbas_info is defined
+
+- <<: *vmhba_data
+ name: Gather vmhba info in check mode
+ check_mode: true
+
+- debug:
+ var: host_vmhbas
+
+- assert:
+ that:
+ - host_vmhbas.hosts_vmhbas_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/tasks/main.yml
new file mode 100644
index 00000000..b74c43aa
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_vmnic_info/tasks/main.yml
@@ -0,0 +1,94 @@
+# Test code for the vmware_host_vmnic_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather vmnic info about a host
+ vmware_host_vmnic_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_vmnics
+- debug: var=host_vmnics
+- assert:
+ that:
+ - host_vmnics.hosts_vmnics_info is defined
+
+- name: Gather extended vmnic info about a host
+ vmware_host_vmnic_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ capabilities: true
+ directpath_io: true
+ sriov: true
+ register: host_vmnics_extended
+- debug: var=host_vmnics_extended
+- assert:
+ that:
+ - host_vmnics_extended.hosts_vmnics_info is defined
+
+- name: Get info from an ESXi host that is offline / disconnected / shut down
+ block:
+ - name: Disconnect ESXi host
+ community.vmware.vmware_host:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: "{{ esxi1 }}"
+ state: disconnected
+
+ - name: Give the ESXi host time to disconnect
+ ansible.builtin.pause:
+ minutes: 1
+
+ - name: Gather vmnic info about a host that is offline / disconnected / shut down
+ vmware_host_vmnic_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_vmnics_disconnected
+ - debug: var=host_vmnics_disconnected
+ - assert:
+ that:
+ - host_vmnics_disconnected.hosts_vmnics_info is defined
+
+ - name: Gather extended vmnic info about a host that is offline / disconnected / shut down
+ vmware_host_vmnic_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ capabilities: true
+ directpath_io: true
+ sriov: true
+ register: host_vmnics_extended_disconnected
+ - debug: var=host_vmnics_extended_disconnected
+ - assert:
+ that:
+ - host_vmnics_extended_disconnected.hosts_vmnics_info is defined
+ always:
+ - name: Reconnect ESXi host
+ community.vmware.vmware_host:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: "{{ esxi1 }}"
+ state: reconnect
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/tasks/main.yml
new file mode 100644
index 00000000..98c4d4c3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_info/tasks/main.yml
@@ -0,0 +1,45 @@
+# Test code for the vmware_local_role_info module
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Set list of Roles in fact
+ set_fact:
+ role_list:
+ - Admin
+ - NoCryptoAdmin
+ - Anonymous
+ - ReadOnly
+
+- &role_data
+ name: Gather Role info
+ vmware_local_role_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: role_details
+
+- &list_to_dict
+ name: List to dict
+ set_fact:
+ role_dict: "{{ dict(role_details.local_role_info|map(attribute='role_name')|zip(role_details.local_role_info)) }}"
+
+- name: Test if NoAccess has no privilege
+ assert:
+ that: "{{ role_dict['NoAccess']['privileges'] | list | length == 0 }}"
+
+- &role_test
+ name: Test if role id is present for role
+ assert:
+ that: "{{ role_dict[item]['privileges'] | list | length > 0 }}"
+ with_items: "{{ role_list }}"
+
+- <<: *role_data
+ name: Gather Role info in check mode
+ check_mode: true
+- <<: *list_to_dict
+- <<: *role_test
+ name: Test if role id is present for role in check mode
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/tasks/main.yml
new file mode 100644
index 00000000..db358228
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_role_manager/tasks/main.yml
@@ -0,0 +1,162 @@
+# Test code for the vmware_local_role_manager module
+# Copyright: (c) 2017-2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Create a role without privileges in check mode
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ state: present
+ register: role_creation
+ check_mode: true
+
+- name: Verify if role was created
+ assert:
+ that:
+ - role_creation.changed
+
+- &create_role_data
+ name: Create a role without privileges
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ state: present
+ register: role_creation_0001
+
+- name: Verify if role was created
+ assert:
+ that:
+ - role_creation_0001.changed
+
+- <<: *create_role_data
+ name: Again create a role without privileges
+
+- name: verify if role is not created again
+ assert:
+ that:
+ - not role_creation_0001.changed
+
+- &delete_role_data
+ name: Delete a role
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ state: absent
+ register: role_creation_0001
+
+- name: Verify if role is not present
+ assert:
+ that:
+ - role_creation_0001.changed
+
+- <<: *delete_role_data
+ name: Delete role again
+
+- name: Verify if role is absent again
+ assert:
+ that:
+ - not role_creation_0001.changed
+
+- name: Create a role with privileges
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ local_privilege_ids: ['VirtualMachine.State.RenameSnapshot']
+ state: present
+ register: role_creation_0001
+
+- name: Verify if role is created with privileges
+ assert:
+ that:
+ - role_creation_0001.changed
+
+- &exist_role_data
+ name: Add a privilege to existing privileges
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ local_privilege_ids: ['Folder.Create']
+ action: add
+ state: present
+ register: role_add
+
+- name: Verify if role is updated with updated privileges
+ assert:
+ that:
+ - role_add.changed
+
+- <<: *exist_role_data
+ name: Again add a privilege to existing privileges
+
+- name: Verify if role is not updated
+ assert:
+ that:
+ - not role_add.changed
+
+- &remove_role_data
+ name: Remove a privilege from existing privileges
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ local_privilege_ids: ['Folder.Create']
+ action: remove
+ register: role_remove
+
+- name: verify if role is updated with privileges
+ assert:
+ that:
+ - role_remove.changed
+
+- <<: *remove_role_data
+ name: Again remove a privilege from existing privileges
+
+- name: Verify if role is not updated
+ assert:
+ that:
+ - not role_remove.changed
+
+- &set_priv_role_data
+ name: Set a privilege to an existing role
+ vmware_local_role_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ local_role_name: SampleRole_0001
+ validate_certs: false
+ local_privilege_ids: ['Folder.Create']
+ action: set
+ register: role_set
+
+- name: Verify if role is updated with privileges
+ assert:
+ that:
+ - role_set.changed
+
+- <<: *set_priv_role_data
+ name: Again set a privilege to an existing role
+
+- name: verify if role is not updated
+ assert:
+ that:
+ - not role_set.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/tasks/main.yml
new file mode 100644
index 00000000..23c24206
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_info/tasks/main.yml
@@ -0,0 +1,34 @@
+# Test code for the vmware_local_user_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_esxi_instance: true
+
+# Local user manager works only with standalone ESXi server
+- &user_info_data
+ name: Gather info about users
+ vmware_local_user_info:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ register: all_user_info
+
+- name: ensure user info are gathered
+ assert:
+ that:
+ - not all_user_info.changed
+ - all_user_info.local_user_info is defined
+
+- <<: *user_info_data
+ name: Gather info about users in check mode
+ check_mode: true
+
+- name: ensure user info are gathered
+ assert:
+ that:
+ - not all_user_info.changed
+ - all_user_info.local_user_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/tasks/main.yml
new file mode 100644
index 00000000..1c5cd64c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_local_user_manager/tasks/main.yml
@@ -0,0 +1,39 @@
+- import_role:
+ name: prepare_vmware_tests
+
+# Testcase 0003: Add Local user in vCenter server
+- name: add local user
+ vmware_local_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ local_user_name: testuser_0003
+ local_user_password: "SamplePassword!"
+ state: present
+ register: user_add_0003
+ ignore_errors: true
+
+- name: ensure user is created
+ assert:
+ that:
+ - user_add_0003.changed == false
+ - "{{ 'Failed to get local account manager settings' in user_add_0003.msg }}"
+
+# Testcase 0003: Delete Local user in vCenter server
+- name: Delete local user
+ vmware_local_user_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ local_user_name: testuser_0003
+ state: absent
+ register: user_delete_0004
+ ignore_errors: true
+
+- name: ensure user is deleted
+ assert:
+ that:
+ - user_delete_0004.changed == false
+ - "{{ 'Failed to get local account manager settings' in user_delete_0004.msg }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/tasks/main.yml
new file mode 100644
index 00000000..2acdb90e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_maintenancemode/tasks/main.yml
@@ -0,0 +1,76 @@
+# Test code for the vmware_guest_maintenancemode module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: Enter maintenance mode
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: test_result_0001
+
+- debug: var=test_result_0001
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_result_0001 is changed
+
+- name: Enter maintenance mode again
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: test_result_0002
+
+- debug: var=test_result_0002
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - not (test_result_0002 is changed)
+
+- name: Exit maintenance mode
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: test_result_0003
+
+- debug: var=test_result_0003
+
+- name: assert that changes were made
+ assert:
+ that:
+ - test_result_0003 is changed
+
+- name: Exit maintenance mode again
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: absent
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: test_result_0004
+
+- debug: var=test_result_0004
+
+- name: assert that no changes were made
+ assert:
+ that:
+ - not (test_result_0004 is changed)
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/aliases
new file mode 100644
index 00000000..eb830a5a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/aliases
@@ -0,0 +1,5 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
+# https://github.com/ansible-collections/community.vmware/issues/1114
+disabled
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/tasks/main.yml
new file mode 100644
index 00000000..95e0768e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_migrate_vmk/tasks/main.yml
@@ -0,0 +1,299 @@
+# Test code for the vmware_migrate_vmk module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: "Prepare integration tests for vmware_migrate_vmk module"
+ block:
+ - name: "Gather host facts from vCenter"
+ vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: gather_host_facts_from_vcenter_result
+
+ - name: "Set variables for integration test"
+ set_fact:
+ vswitch_pg_name_for_test: vSwitchForVMwareMigrateVmkPG
+ dvswitch_pg_name_for_test: dvSwitchForVMwareMigrateVmkPG
+ device_name: >-
+ {{ ( gather_host_facts_from_vcenter_result.ansible_facts.ansible_interfaces
+ | last
+ | regex_replace('vmk(.*)', '\1')
+ | int + 1 )
+ | regex_replace('(.*)', 'vmk\1')
+ }}
+
+ - name: "Gather vSwitch info"
+ vmware_vswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ register: gather_vswitch_info_result
+
+ - name: "Create a new vSwitch block"
+ when:
+ - "not '{{ switch1 }}' in gather_vswitch_info_result.hosts_vswitch_info[esxi1]"
+ block:
+ - name: "Create a new vSwitch"
+ vmware_vswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch: "{{ switch1 }}"
+ register: create_new_vswitch_result
+
+ - assert:
+ that:
+ - create_new_vswitch_result.changed is sameas true
+
+ - name: "Create a new port group of vSwitch"
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch: "{{ switch1 }}"
+ portgroup: "{{ vswitch_pg_name_for_test }}"
+ register: create_new_vswitch_pg_result
+
+ - assert:
+ that:
+ - create_new_vswitch_pg_result.changed is sameas true
+
+ - name: "Gather dvSwitch info"
+ vmware_dvswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: gather_dvswitch_info_result
+
+ - name: "Create a new dvSwitch block"
+ when:
+ - >-
+ gather_dvswitch_info_result.distributed_virtual_switches
+ | map(attribute='configure.name')
+ | map('regex_search',dvswitch1)
+ | list
+ | length == 0
+ block:
+ - name: "Create a new dvSwitch"
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ switch_name: "{{ dvswitch1 }}"
+ switch_version: 6.5.0
+ uplink_quantity: 2
+ state: present
+ register: create_new_dvswitch_result
+
+ - assert:
+ that:
+ - create_new_dvswitch_result.changed is sameas true
+
+ - name: "Add ESXi host to dvSwitch"
+ vmware_dvs_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch_name: "{{ dvswitch1 }}"
+ state: present
+ register: add_esxi_host_dvswitch_result
+
+ - assert:
+ that:
+ - add_esxi_host_dvswitch_result.changed is sameas true
+
+ - name: "Create new a port group of dvSwitch"
+ vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch_name: "{{ dvswitch1 }}"
+ portgroup_name: "{{ dvswitch_pg_name_for_test }}"
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ num_ports: 8
+ vlan_id: 0
+ state: present
+ register: create_new_dvswitch_pg_result
+
+ - assert:
+ that:
+ - create_new_dvswitch_pg_result.changed is sameas true
+
+ - name: "Create a new vmkernel"
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ vswitch_name: "{{ switch1 }}"
+ portgroup_name: "{{ vswitch_pg_name_for_test }}"
+ device: "{{ device_name }}"
+ network:
+ type: 'static'
+ ip_address: 192.168.0.254
+ subnet_mask: 255.255.255.0
+ register: prepare_integration_tests_result
+
+ - assert:
+ that:
+ - prepare_integration_tests_result.changed is sameas true
+
+- name: "Migrate Management vmk from vSwitch to dvSwitch"
+ vmware_migrate_vmk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ device: "{{ device_name }}"
+ current_switch_name: "{{ switch1 }}"
+ current_portgroup_name: "{{ vswitch_pg_name_for_test }}"
+ migrate_switch_name: "{{ dvswitch1 }}"
+ migrate_portgroup_name: "{{ dvswitch_pg_name_for_test }}"
+ register: migrate_management_vmk_vswitch_to_dvswitch_result
+
+- assert:
+ that:
+ - migrate_management_vmk_vswitch_to_dvswitch_result.changed is sameas true
+
+- name: "Migrate Management vmk from vSwitch to dvSwitch (idempotency check)"
+ vmware_migrate_vmk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ device: "{{ device_name }}"
+ current_switch_name: "{{ switch1 }}"
+ current_portgroup_name: "{{ vswitch_pg_name_for_test }}"
+ migrate_switch_name: "{{ dvswitch1 }}"
+ migrate_portgroup_name: "{{ dvswitch_pg_name_for_test }}"
+ register: migrate_management_vmk_vswitch_to_dvswitch_idempotency_check_result
+
+- assert:
+ that:
+ - migrate_management_vmk_vswitch_to_dvswitch_idempotency_check_result.changed is sameas false
+
+- name: "Migrate Management vmk from dvSwitch to vSwitch"
+ vmware_migrate_vmk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ device: "{{ device_name }}"
+ current_switch_name: "{{ dvswitch1 }}"
+ current_portgroup_name: "{{ dvswitch_pg_name_for_test }}"
+ migrate_switch_name: "{{ switch1 }}"
+ migrate_portgroup_name: "{{ vswitch_pg_name_for_test }}"
+ register: migrate_management_vmk_dvswitch_to_vswitch_result
+
+- assert:
+ that:
+ - migrate_management_vmk_dvswitch_to_vswitch_result.changed is sameas true
+
+- name: "Migrate Management vmk from dvSwitch to vSwitch (idempotency check)"
+ vmware_migrate_vmk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ device: "{{ device_name }}"
+ current_switch_name: "{{ dvswitch1 }}"
+ current_portgroup_name: "{{ dvswitch_pg_name_for_test }}"
+ migrate_switch_name: "{{ switch1 }}"
+ migrate_portgroup_name: "{{ vswitch_pg_name_for_test }}"
+ register: migrate_management_vmk_dvswitch_to_vswitch_idempotency_check_result
+
+- assert:
+ that:
+ - migrate_management_vmk_dvswitch_to_vswitch_idempotency_check_result.changed is sameas false
+
+- name: "Delete the used objects for integration test"
+ block:
+ - name: "Delete the used vmkernel for integration test"
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ vswitch_name: "{{ switch1 }}"
+ portgroup_name: "{{ vswitch_pg_name_for_test }}"
+ device: "{{ device_name }}"
+ state: absent
+ register: delete_vmk_result
+
+ - assert:
+ that:
+ - delete_vmk_result.changed is sameas true
+
+ - name: "Delete the used dvSwitch for integration test"
+ vmware_dvswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ switch: "{{ dvswitch1 }}"
+ uplink_quantity: 1
+ state: absent
+ register: delete_dvswitch_result
+
+ - assert:
+ that:
+ - delete_dvswitch_result.changed is sameas true
+
+ - name: "Delete the used port group for integration test"
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch: "{{ switch1 }}"
+ portgroup: "{{ vswitch_pg_name_for_test }}"
+ state: absent
+ register: delete_vswitch_pg_result
+
+ - assert:
+ that:
+ - delete_vswitch_pg_result.changed is sameas true
+
+ - name: "Delete the used vSwitch for integration test"
+ vmware_vswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch: "{{ switch1 }}"
+ state: absent
+ register: delete_vswitch_result
+
+ - assert:
+ that:
+ - delete_vswitch_result.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/cleanup.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/cleanup.yml
new file mode 100644
index 00000000..16c7c0f2
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/cleanup.yml
@@ -0,0 +1,41 @@
+# Test code for the vmware_object_custom_attributes_info module.
+# Copyright: (c) 2022, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Remove VM custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: "{{ item }}"
+ state: absent
+ loop:
+ - vm_example01
+ - vm_example02
+
+- name: Remove VM custom attribute definition for global type
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: "{{ item }}"
+ state: absent
+ loop:
+ - vm_example03_global
+
+- name: Remove ESXi custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: HostSystem
+ custom_attribute: "{{ item }}"
+ state: absent
+ loop:
+ - esxi_example01
+ - esxi_example02
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/main.yml
new file mode 100644
index 00000000..d56e10ef
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/main.yml
@@ -0,0 +1,19 @@
+# Test code for the vmware_object_custom_attributes_info module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Include tasks pre.yml
+ include_tasks: pre.yml
+
+- name: Include tasks vmware_object_custom_attributes_info_tests.yml
+ include_tasks: vmware_object_custom_attributes_info_tests.yml
+
+- name: Include tasks cleanup
+ include_tasks: cleanup.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/pre.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/pre.yml
new file mode 100644
index 00000000..9acb9d0a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/pre.yml
@@ -0,0 +1,100 @@
+# Test code for the vmware_object_custom_attributes_info module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Add VM custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: VirtualMachine
+ custom_attribute: "{{ item }}"
+ state: present
+ loop:
+ - vm_example01
+ - vm_example02
+
+- name: Add VM custom attribute definition for global type
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: Global
+ custom_attribute: "{{ item }}"
+ state: present
+ loop:
+ - vm_example03_global
+
+- name: Add ESXi custom attribute definition
+ community.vmware.vmware_custom_attribute:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ object_type: HostSystem
+ custom_attribute: "{{ item }}"
+ state: present
+ loop:
+ - esxi_example01
+ - esxi_example02
+
+- name: Add custom attributes to a virtual machine
+ community.vmware.vmware_custom_attribute_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_name: "{{ virtual_machines.0.name }}"
+ object_type: VirtualMachine
+ custom_attributes:
+ - name: vm_example01
+ value: test1
+ - name: vm_example02
+ value: test2
+ - name: vm_example03_global
+ value: test3
+ state: present
+
+- name: Add custom attributes to an ESXi
+ community.vmware.vmware_custom_attribute_manager:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ custom_attributes:
+ - name: esxi_example01
+ value: test1
+ - name: esxi_example02
+ value: test2
+ state: present
+
+- name: Gather virtual machine information
+ community.vmware.vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines.0.name }}"
+ register: vm_info
+
+- name: Gather ESXi host information
+ community.vmware.vmware_host_facts:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ schema: vsphere
+ properties:
+ - _moId
+ register: esxi_info
+
+- name: Set vm_moid and esxi_moid variable
+ set_fact:
+ vm_moid: "{{ vm_info.instance.moid }}"
+ esxi_moid: "{{ esxi_info.ansible_facts.moid }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml
new file mode 100644
index 00000000..04f0ff55
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml
@@ -0,0 +1,105 @@
+# Test code for the vmware_object_custom_attributes_info module.
+# Copyright: (c) 2021, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Gather custom attributes of a virtual machine
+ community.vmware.vmware_object_custom_attributes_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_type: VirtualMachine
+ object_name: "{{ virtual_machines.0.name }}"
+ register: vm_custom_attributes_result
+
+- name: Make sure if custom attributes exist
+ assert:
+ that:
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01')
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01')
+ | selectattr('type', 'equalto', 'VirtualMachine')
+ - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1')
+
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02')
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02')
+ | selectattr('type', 'equalto', 'VirtualMachine')
+ - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2')
+
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global')
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global')
+ | selectattr('type', 'equalto', 'Global')
+ - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test3')
+
+- name: Gather custom attributes of an ESXi
+ community.vmware.vmware_object_custom_attributes_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_type: HostSystem
+ object_name: "{{ esxi1 }}"
+ register: esxi_custom_attributes_result
+
+- name: Make sure if custom attributes exist
+ assert:
+ that:
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01')
+ | selectattr('type', 'equalto', 'HostSystem')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1')
+
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02')
+ | selectattr('type', 'equalto', 'HostSystem')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2')
+
+- name: Gather custom attributes of a virtual machine with moid
+ community.vmware.vmware_object_custom_attributes_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_type: VirtualMachine
+ moid: "{{ vm_moid }}"
+ register: vm_custom_attributes_with_moid_result
+
+- name: Make sure if custom attributes exist
+ assert:
+ that:
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01')
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01')
+ | selectattr('type', 'equalto', 'VirtualMachine')
+ - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1')
+
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02')
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02')
+ | selectattr('type', 'equalto', 'VirtualMachine')
+ - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2')
+
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global')
+ - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global')
+ | selectattr('type', 'equalto', 'Global')
+ - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test3')
+
+- name: Gather custom attributes of an ESXi with moid
+ community.vmware.vmware_object_custom_attributes_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_type: HostSystem
+ moid: "{{ esxi_moid }}"
+ register: esxi_custom_attributes_result
+
+- name: Make sure if custom attributes exist
+ assert:
+ that:
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01')
+ | selectattr('type', 'equalto', 'HostSystem')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1')
+
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02')
+ | selectattr('type', 'equalto', 'HostSystem')
+ - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2')
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/dc_rename.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/dc_rename.yml
new file mode 100644
index 00000000..cf1668bb
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/dc_rename.yml
@@ -0,0 +1,66 @@
+# Test code for the vmware_object_rename Operations.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+
+- name: Rename datastore dc1
+ vmware_object_rename:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_type: Datacenter
+ object_name: "{{ dc1 }}"
+ new_name: "datacenter_0001"
+ validate_certs: false
+ register: rename_result
+
+- debug: var=rename_result
+
+- name: Check if VM rename status
+ assert:
+ that:
+ - rename_result.changed
+ - rename_result.rename_status.current_name == "datacenter_0001"
+ - rename_result.rename_status.desired_name == "datacenter_0001"
+ - rename_result.rename_status.previous_name == "{{ dc1 }}"
+
+- name: Rename datastore dc1 (again)
+ vmware_object_rename:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_type: Datacenter
+ object_name: "{{ dc1 }}"
+ new_name: "datacenter_0001"
+ validate_certs: false
+ register: rename_result
+
+- debug: var=rename_result
+
+- name: Check if VM rename status is changed==false
+ assert:
+ that:
+ - rename_result.changed == false
+
+- name: Revert the renaming
+ vmware_object_rename:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ object_type: Datacenter
+ object_name: "datacenter_0001"
+ new_name: "{{ dc1 }}"
+ validate_certs: false
+ register: rename_result
+
+- debug: var=rename_result
+
+- name: Check if VM rename status
+ assert:
+ that:
+ - rename_result.changed == true
+ - rename_result.rename_status.current_name == "{{ dc1 }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml
new file mode 100644
index 00000000..6fb17616
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml
@@ -0,0 +1,5 @@
+# Test code for the vmware_object_rename Operations.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- include: dc_rename.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/alias b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/alias
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/alias
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/main.yml
new file mode 100644
index 00000000..10c78f6e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/main.yml
@@ -0,0 +1,26 @@
+# Test code for the vmware_object_role_permission module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_dvswitch: true
+ setup_resource_pool: true
+ setup_virtualmachines: true
+ setup_switch: true
+ setup_dvs_portgroup: true
+
+- include_tasks: vmware_object_role_permission_tests.yml
+ vars:
+ principal: "root"
+
+- include_tasks: vmware_object_role_permission_tests.yml
+ vars:
+ principal: "vsphere.local\\K/M"
+
+- include_tasks: user_friendly_role_name_tests.yml
+ vars:
+ principal: "root"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/user_friendly_role_name_tests.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/user_friendly_role_name_tests.yml
new file mode 100644
index 00000000..4d21d84c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/user_friendly_role_name_tests.yml
@@ -0,0 +1,40 @@
+# Test code for the vmware_object_role_permission module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Set default parameter of the module
+ module_defaults:
+ vmware_object_role_permission:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ block:
+ - name: User friendly role name test
+ vmware_object_role_permission:
+ role: "{{ item }}"
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: present
+ register: user_friendly_role_name_result
+ loop:
+ - Administrator
+ - Read-Only
+ - Content library administrator (sample)
+ - No cryptography administrator
+ - No access
+ - Virtual machine power user (sample)
+ - Virtual machine user (sample)
+ - Resource pool administrator (sample)
+ - VMware Consolidated Backup user (sample)
+ - Datastore consumer (sample)
+ - Network administrator (sample)
+ - Virtual Machine console user
+ - Tagging Admin
+
+ - name: Make sure all status changed occurs
+ assert:
+ that:
+ - item.changed is sameas true
+ loop: "{{ user_friendly_role_name_result.results }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/vmware_object_role_permission_tests.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/vmware_object_role_permission_tests.yml
new file mode 100644
index 00000000..d3818360
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission/tasks/vmware_object_role_permission_tests.yml
@@ -0,0 +1,881 @@
+# Test code for the vmware_object_role_permission module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Set default parameter of the module
+ module_defaults:
+ vmware_object_role_permission:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ block:
+ # Here start to VM folder test
+ - name: Assign user to VM folder with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: present
+ check_mode: true
+ register: assing_user_vm_folder_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_vm_folder_check_mode_result.changed is sameas true
+
+ - name: Assign user to VM folder
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: present
+ register: assing_user_vm_folder_result
+
+ - name: Make sure if a user assigned to an object
+ assert:
+ that:
+ - assing_user_vm_folder_result.changed is sameas true
+
+ - name: Assign user to VM folder(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: present
+ register: assing_user_vm_folder_idempotency_result
+
+ - name: Make sure if a user assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_vm_folder_idempotency_result.changed is sameas false
+
+ - name: Unassign user from VM folder with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: absent
+ check_mode: true
+ register: unassing_user_vm_folder_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_vm_folder_check_mode_result.changed is sameas true
+
+ - name: Unassign user from VM folder
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: absent
+ register: unassing_user_vm_folder_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_vm_folder_result.changed is sameas true
+
+ - name: Unassign user from VM folder(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: absent
+ register: unassing_user_vm_folder_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_vm_folder_idempotency_result.changed is sameas false
+
+ # Here start to VM test
+ - name: Assign user to VM with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ virtual_machines.0 }}"
+ object_type: VirtualMachine
+ state: present
+ check_mode: true
+ register: assing_user_vm_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_vm_check_mode_result.changed is sameas true
+
+ - name: Assign user to VM
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ virtual_machines.0 }}"
+ object_type: VirtualMachine
+ state: present
+ register: assing_user_vm_result
+
+ - name: Make sure if a user assigned to an object
+ assert:
+ that:
+ - assing_user_vm_result.changed is sameas true
+
+ - name: Assign user to VM(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ virtual_machines.0 }}"
+ object_type: VirtualMachine
+ state: present
+ register: assing_user_vm_idempotency_result
+
+ - name: Make sure if a user assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_vm_idempotency_result.changed is sameas false
+
+ - name: Unassign user from VM with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ virtual_machines.0 }}"
+ object_type: VirtualMachine
+ state: absent
+ check_mode: true
+ register: unassing_user_vm_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_vm_check_mode_result.changed is sameas true
+
+ - name: Unassign user from VM
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ virtual_machines.0 }}"
+ object_type: VirtualMachine
+ state: absent
+ register: unassing_user_vm_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_vm_result.changed is sameas true
+
+ - name: Unassign user from VM(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ virtual_machines.0 }}"
+ object_type: VirtualMachine
+ state: absent
+ register: unassing_user_vm_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_vm_idempotency_result.changed is sameas false
+
+ # Here start to Datacenter test
+ - name: Assign user to Datacenter with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dc1 }}"
+ object_type: Datacenter
+ state: present
+ check_mode: true
+ register: assing_user_dc_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_dc_check_mode_result.changed is sameas true
+
+ - name: Assign user to Datacenter
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dc1 }}"
+ object_type: Datacenter
+ state: present
+ register: assing_user_dc_result
+
+ - name: Make sure if a user assigned to an object
+ assert:
+ that:
+ - assing_user_dc_result.changed is sameas true
+
+ - name: Assign user to Datacenter(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dc1 }}"
+ object_type: Datacenter
+ state: present
+ register: assing_user_dc_idempotency_result
+
+ - name: Make sure if a user assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_dc_idempotency_result.changed is sameas false
+
+ - name: Unassign user from Datacenter with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dc1 }}"
+ object_type: Datacenter
+ state: absent
+ check_mode: true
+ register: unassing_user_dc_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_dc_check_mode_result.changed is sameas true
+
+ - name: Unassign user from Datacenter
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dc1 }}"
+ object_type: Datacenter
+ state: absent
+ register: unassing_user_dc_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_dc_result.changed is sameas true
+
+ - name: Unassign user from Datacenter(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dc1 }}"
+ object_type: Datacenter
+ state: absent
+ register: unassing_user_dc_idempotency_result
+
+ - name: Make sure if unassing a user from an object and doesn't change
+ assert:
+ that:
+ - unassing_user_dc_idempotency_result.changed is sameas false
+
+ # Here start to Resource Pool test
+ - name: Assign user to ResourcePool with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: DC0_C0_RP1
+ object_type: ResourcePool
+ state: present
+ check_mode: true
+ register: assing_user_rp_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_rp_check_mode_result.changed is sameas true
+
+ - name: Assign user to ResourcePool
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: DC0_C0_RP1
+ object_type: ResourcePool
+ state: present
+ register: assing_user_rp_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_rp_result.changed is sameas true
+
+ - name: Assign user to ResourcePool(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: DC0_C0_RP1
+ object_type: ResourcePool
+ state: present
+ register: assing_user_rp_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_rp_idempotency_result.changed is sameas false
+
+ - name: Unassign user from ResourcePool with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: DC0_C0_RP1
+ object_type: ResourcePool
+ state: absent
+ check_mode: true
+ register: unassing_user_rp_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_rp_check_mode_result.changed is sameas true
+
+ - name: Unassign user from ResourcePool
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: DC0_C0_RP1
+ object_type: ResourcePool
+ state: absent
+ register: unassing_user_rp_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_rp_result.changed is sameas true
+
+ - name: Unassign user from ResourcePool(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: DC0_C0_RP1
+ object_type: ResourcePool
+ state: absent
+ register: unassing_user_rp_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_rp_idempotency_result.changed is sameas false
+
+ # Here start to Datastore test
+ - name: Assign user to Datastore with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: present
+ check_mode: true
+ register: assing_user_datastore_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_datastore_check_mode_result.changed is sameas true
+
+ - name: Assign user to Datastore
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: present
+ register: assing_user_datastore_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_datastore_result.changed is sameas true
+
+ - name: Assign user to Datastore(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: present
+ register: assing_user_datastore_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_datastore_idempotency_result.changed is sameas false
+
+ - name: Unassign user from Datastore with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: absent
+ check_mode: true
+ register: unassing_user_datastore_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_datastore_check_mode_result.changed is sameas true
+
+ - name: Unassign user from Datastore
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: absent
+ register: unassing_user_datastore_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_datastore_result.changed is sameas true
+
+ - name: Unassign user from Datastore(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: absent
+ register: unassing_user_datastore_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_datastore_idempotency_result.changed is sameas false
+
+ # Here start to Network test
+ - name: Assign user to Network with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: VM Network
+ object_type: Network
+ state: present
+ check_mode: true
+ register: assing_user_network_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_network_check_mode_result.changed is sameas true
+
+ - name: Assign user to Network
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: VM Network
+ object_type: Network
+ state: present
+ register: assing_user_network_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_network_result.changed is sameas true
+
+ - name: Assign user to Network(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: VM Network
+ object_type: Network
+ state: present
+ register: assing_user_network_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_network_idempotency_result.changed is sameas false
+
+ - name: Unassign user from Network with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: VM Network
+ object_type: Network
+ state: absent
+ check_mode: true
+ register: unassing_user_network_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_network_check_mode_result.changed is sameas true
+
+ - name: Unassign user from Network
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: VM Network
+ object_type: Network
+ state: absent
+ register: unassing_user_network_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_network_result.changed is sameas true
+
+ - name: Unassign user from Network(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: VM Network
+ object_type: Network
+ state: absent
+ register: unassing_user_network_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_network_idempotency_result.changed is sameas false
+
+ # Here start to HostSystem test
+ - name: Assign user to HostSystem with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ state: present
+ check_mode: true
+ register: assing_user_hostsystem_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_hostsystem_check_mode_result.changed is sameas true
+
+ - name: Assign user to HostSystem
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ state: present
+ register: assing_user_hostsystem_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_hostsystem_result.changed is sameas true
+
+ - name: Assign user to HostSystem(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ state: present
+ register: assing_user_hostsystem_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_hostsystem_idempotency_result.changed is sameas false
+
+ - name: Unassign user from HostSystem with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ state: absent
+ check_mode: true
+ register: assing_user_hostsystem_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_hostsystem_check_mode_result.changed is sameas true
+
+ - name: Unassign user from HostSystem
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ state: absent
+ register: assing_user_hostsystem_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - assing_user_hostsystem_result.changed is sameas true
+
+ - name: Unassign user from HostSystem(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ esxi1 }}"
+ object_type: HostSystem
+ state: absent
+ register: assing_user_hostsystem_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - assing_user_hostsystem_idempotency_result.changed is sameas false
+
+ # Here start to ComputeResource test
+ - name: Assign user to ComputeResource with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ComputeResource
+ state: present
+ check_mode: true
+ register: assing_user_compute_resource_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_compute_resource_check_mode_result.changed is sameas true
+
+ - name: Assign user to ComputeResource
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ComputeResource
+ state: present
+ register: assing_user_compute_resource_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_compute_resource_result.changed is sameas true
+
+ - name: Assign user to ComputeResource(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ComputeResource
+ state: present
+ register: assing_user_compute_resource_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_compute_resource_idempotency_result.changed is sameas false
+
+ - name: Unassign user from ComputeResource with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ComputeResource
+ state: absent
+ check_mode: true
+ register: unassing_user_compute_resource_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_compute_resource_check_mode_result.changed is sameas true
+
+ - name: Unassign user from ComputeResource
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ComputeResource
+ state: absent
+ register: unassing_user_compute_resource_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_compute_resource_result.changed is sameas true
+
+ - name: Unassign user from ComputeResource(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ComputeResource
+ state: absent
+ register: unassing_user_compute_resource_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_compute_resource_idempotency_result.changed is sameas false
+
+ # Here start to ClusterComputeResource test
+ - name: Assign user to ClusterComputeResource with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ClusterComputeResource
+ state: present
+ check_mode: true
+ register: assing_user_cluster_resource_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_cluster_resource_result.changed is sameas true
+
+ - name: Assign user to ClusterComputeResource
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ClusterComputeResource
+ state: present
+ register: assing_user_cluster_resource_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_cluster_resource_result.changed is sameas true
+
+ - name: Assign user to ClusterComputeResource(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ClusterComputeResource
+ state: present
+ register: assing_user_cluster_resource_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_cluster_resource_idempotency_result.changed is sameas false
+
+ - name: Unassign user from ClusterComputeResource with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ClusterComputeResource
+ state: absent
+ check_mode: true
+ register: unassing_user_cluster_resource_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_cluster_resource_result.changed is sameas true
+
+ - name: Unassign user from ClusterComputeResource
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ClusterComputeResource
+ state: absent
+ register: unassing_user_cluster_resource_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_cluster_resource_result.changed is sameas true
+
+ - name: Unassign user from ClusterComputeResource(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ ccr1 }}"
+ object_type: ClusterComputeResource
+ state: absent
+ register: unassing_user_cluster_resource_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_cluster_resource_idempotency_result.changed is sameas false
+
+ # Here start to DistributedVirtualSwitch test
+ - name: Assign user to DistributedVirtualSwitch with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dvswitch1 }}"
+ object_type: DistributedVirtualSwitch
+ state: present
+ check_mode: true
+ register: assing_user_dvswitch_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - assing_user_dvswitch_check_mode_result.changed is sameas true
+
+ - name: Assign user to DistributedVirtualSwitch
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dvswitch1 }}"
+ object_type: DistributedVirtualSwitch
+ state: present
+ register: assing_user_dvswitch_result
+
+ - name: Make sure if a user and role assigned to an object
+ assert:
+ that:
+ - assing_user_dvswitch_result.changed is sameas true
+
+ - name: Assign user to DistributedVirtualSwitch(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dvswitch1 }}"
+ object_type: DistributedVirtualSwitch
+ state: present
+ register: assing_user_dvswitch_idempotency_result
+
+ - name: Make sure if a user and role assigned of an object doesn't change
+ assert:
+ that:
+ - assing_user_dvswitch_idempotency_result.changed is sameas false
+
+ - name: Unassign user from DistributedVirtualSwitch with check_mode
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dvswitch1 }}"
+ object_type: DistributedVirtualSwitch
+ state: absent
+ check_mode: true
+ register: unassing_user_dvswitch_check_mode_result
+
+ - name: Make sure if changed occurs
+ assert:
+ that:
+ - unassing_user_dvswitch_check_mode_result.changed is sameas true
+
+ - name: Unassign user from DistributedVirtualSwitch
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dvswitch1 }}"
+ object_type: DistributedVirtualSwitch
+ state: absent
+ register: unassing_user_dvswitch_result
+
+ - name: Make sure if unassing a user from an object
+ assert:
+ that:
+ - unassing_user_dvswitch_result.changed is sameas true
+
+ - name: Unassign user from DistributedVirtualSwitch(idempotency check)
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ dvswitch1 }}"
+ object_type: DistributedVirtualSwitch
+ state: absent
+ register: unassing_user_dvswitch_idempotency_result
+
+ - name: Make sure if unassing a user from an object doesn't change
+ assert:
+ that:
+ - unassing_user_dvswitch_idempotency_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/alias b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/alias
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/alias
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/main.yml
new file mode 100644
index 00000000..7334a976
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/main.yml
@@ -0,0 +1,18 @@
+# Test code for the vmware_object_role_permission_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_dvswitch: true
+ setup_resource_pool: true
+ setup_virtualmachines: true
+ setup_switch: true
+ setup_dvs_portgroup: true
+
+- include_tasks: vmware_object_role_permission_tests.yml
+ vars:
+ principal: "root"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/vmware_object_role_permission_tests.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/vmware_object_role_permission_tests.yml
new file mode 100644
index 00000000..32254f8d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_role_permission_info/tasks/vmware_object_role_permission_tests.yml
@@ -0,0 +1,41 @@
+# Test code for the vmware_object_role_permission_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Set default parameter of the module
+ module_defaults:
+ vmware_object_role_permission:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ block:
+ - name: Assign user to VM folder
+ vmware_object_role_permission:
+ role: Admin
+ principal: "{{ principal }}"
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ state: present
+ register: assign_user_vm_folder_result
+
+ - name: Make sure if a user assigned to an object
+ assert:
+ that:
+ - assign_user_vm_folder_result.changed is sameas true
+
+ - name: Gather information about VM folder
+ vmware_object_role_permission_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ object_name: "{{ f0 }}"
+ object_type: Folder
+ register: vm_folder_info
+
+ - name: Make sure we gather information about VM folder
+ assert:
+ that:
+ - vm_folder_info.changed is sameas false
+ - vm_folder_info.permission_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/tasks/main.yml
new file mode 100644
index 00000000..3d7e1f93
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup/tasks/main.yml
@@ -0,0 +1,214 @@
+# Test code for the vmware_portgroup module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datacenter: true
+ setup_attach_host: true
+ setup_cluster: true
+ setup_switch: true
+
+- name: Create portgroup without Portgroup and vSwitch
+ vmware_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ ignore_errors: true
+ register: no_pg_vs
+
+- assert:
+ that:
+ - '"missing" in no_pg_vs.msg'
+
+- name: Create portgroup without Portgroup
+ vmware_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ vswitch: ''
+ validate_certs: false
+ ignore_errors: true
+ register: no_vs
+
+- assert:
+ that:
+ - '"missing" in no_vs.msg'
+
+- name: Create portgroup without cluster
+ vmware_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ vswitch: '{{ switch1 }}'
+ portgroup: 'pg_03'
+ validate_certs: false
+ ignore_errors: true
+ register: no_cluster
+
+- assert:
+ that:
+ - '"cluster_name" in no_cluster.msg'
+
+- name: Create portgroup
+ vmware_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ vswitch: '{{ switch1 }}'
+ portgroup: 'pg_03'
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ state: present
+ ignore_errors: true
+ register: pg_info
+
+- assert:
+ that:
+ - pg_info.changed
+
+- name: Create portgroup with traffic shaping
+ vmware_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ vswitch: '{{ switch1 }}'
+ portgroup: 'pg_ts'
+ cluster_name: "{{ ccr1 }}"
+ traffic_shaping:
+ enabled: true
+ average_bandwidth: 100000
+ peak_bandwidth: 100000
+ burst_size: 102400
+ validate_certs: false
+ state: present
+ register: create_portgroup_with_traffic_shaping_result
+
+- assert:
+ that:
+ - create_portgroup_with_traffic_shaping_result.changed
+
+# Issue 955
+- name: Disable traffic shaping
+ vmware_portgroup:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ vswitch: '{{ switch1 }}'
+ portgroup: 'pg_ts'
+ cluster_name: "{{ ccr1 }}"
+ traffic_shaping:
+ enabled: false
+ validate_certs: false
+ state: present
+ register: disable_traffic_shaping_result
+
+- assert:
+ that:
+ - disable_traffic_shaping_result.changed
+
+- name: Integration test a PortGroup name with special characters
+ block:
+ - name: Create Switch with special characters
+ vmware_vswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch: 'Switch\%'
+ state: present
+ register: create_switch_with_special_characters_result
+
+ - assert:
+ that:
+ - create_switch_with_special_characters_result.changed is sameas true
+
+ - name: Create PortGroup with special characters
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ hosts: "{{ esxi1 }}"
+ switch: 'Switch\%'
+ portgroup: 'PortGroup\%'
+ security:
+ promiscuous_mode: false
+ mac_changes: false
+ forged_transmits: false
+ state: present
+ register: create_portgroup_with_special_characters_result
+
+ - assert:
+ that:
+ - create_portgroup_with_special_characters_result.changed is sameas true
+
+ - name: Create PortGroup with special characters(idempotency check)
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ hosts: "{{ esxi1 }}"
+ switch: 'Switch\%'
+ portgroup: 'PortGroup\%'
+ security:
+ promiscuous_mode: false
+ mac_changes: false
+ forged_transmits: false
+ state: present
+ register: create_portgroup_with_special_characters_idempotency_check_result
+
+ - assert:
+ that:
+ - create_portgroup_with_special_characters_idempotency_check_result.changed is sameas false
+
+ - name: Delete PortGroup with special characters
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ hosts: "{{ esxi1 }}"
+ switch: 'Switch\%'
+ portgroup: 'PortGroup\%'
+ state: absent
+ register: delete_portgroup_with_special_characters_result
+
+ - assert:
+ that:
+ - delete_portgroup_with_special_characters_result.changed is sameas true
+
+ - name: Delete PortGroup with special characters(idempotency check)
+ vmware_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ hosts: "{{ esxi1 }}"
+ switch: 'Switch\%'
+ portgroup: 'PortGroup\%'
+ state: absent
+ register: delete_portgroup_with_special_characters_idempotency_check_result
+
+ - assert:
+ that:
+ - delete_portgroup_with_special_characters_idempotency_check_result.changed is sameas false
+
+ - name: Delete Switch with special characters
+ vmware_vswitch:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi1 }}"
+ switch: 'Switch\%'
+ state: absent
+ register: delete_switch_with_special_characters_result
+
+ - assert:
+ that:
+ - delete_switch_with_special_characters_result.changed is sameas true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/tasks/main.yml
new file mode 100644
index 00000000..1eea226d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_portgroup_info/tasks/main.yml
@@ -0,0 +1,67 @@
+# Test code for the vmware_portgroup_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: Gather portgroup info for all ESXi host from given cluster
+ vmware_portgroup_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: portgroup_0001_results
+
+- assert:
+ that:
+ - "not portgroup_0001_results.changed"
+ - "portgroup_0001_results.hosts_portgroup_info is defined"
+
+- name: Gather portgroup info for an ESXi host
+ vmware_portgroup_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: portgroup_0002_results
+
+- assert:
+ that:
+ - "not portgroup_0002_results.changed"
+ - "portgroup_0002_results.hosts_portgroup_info is defined"
+
+- name: Gather all portgroup info for an ESXi host
+ vmware_portgroup_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ policies: true
+ register: portgroup_0003_results
+
+- assert:
+ that:
+ - "not portgroup_0003_results.changed"
+ - "portgroup_0003_results.hosts_portgroup_info is defined"
+
+- name: Gather all portgroup info for an ESXi host in check mode
+ vmware_portgroup_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ policies: true
+ register: portgroup_0004_results
+ check_mode: true
+
+- assert:
+ that:
+ - "not portgroup_0004_results.changed"
+ - "portgroup_0004_results.hosts_portgroup_info is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/tasks/main.yml
new file mode 100644
index 00000000..fd4a832d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_recommended_datastore/tasks/main.yml
@@ -0,0 +1,92 @@
+# Test code for the vmware_recommended_datastore module.
+# Copyright: (c) 2021, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Set Datastore cluster name
+ set_fact:
+ dsc: "DSC1"
+
+- name: Run tests and clean up
+ block:
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+ - name: Get list of info about datastores
+ vmware_datastore_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ gather_nfs_mount_info: true
+ register: datastore_info_0001
+
+ - name: Get datastore name for adding in datastore cluster
+ set_fact:
+ datastore_name: "{{ datastore_info_0001['datastores'][0]['name'] }}"
+
+ - name: Add a datastore cluster to datacenter
+ vmware_datastore_cluster:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ dsc }}"
+ enable_sdrs: true
+ state: present
+ register: add_dsc
+
+ - name: Check if datastore cluster is added successfully
+ assert:
+ that:
+ - add_dsc.changed
+
+ - name: Add a datastore in the given datastore cluster
+ vmware_datastore_cluster_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ dsc }}"
+ datastores:
+ - "{{ datastore_name }}"
+ register: add_ds
+
+ - name: Check if datastore is added in datastore cluster
+ assert:
+ that:
+ - add_ds.changed
+
+ - name: Gather information about recommended datastore
+ vmware_recommended_datastore:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ datastore_cluster: DSC1
+ register: dsc_info
+
+ - name: Check if datastore information is returned
+ assert:
+ that:
+ - dsc_info.recommended_datastore is defined
+ - dsc_info.recommended_datastore == datastore_name
+
+ always:
+ - name: Delete a datastore cluster to datacenter
+ vmware_datastore_cluster:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ datacenter_name: "{{ dc1 }}"
+ datastore_cluster_name: "{{ dsc }}"
+ state: absent
+ register: delete_dsc
+ ignore_errors: true
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/aliases
new file mode 100644
index 00000000..d1d14d22
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_2esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/tasks/main.yml
new file mode 100644
index 00000000..2d34680f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool/tasks/main.yml
@@ -0,0 +1,445 @@
+# Test code for the vmware_resource_pool module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_resource_pool: true
+
+# Tests on cluster
+- name: set the vmware_resource_pool module default values
+ module_defaults:
+ vmware_resource_pool:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ cluster: "{{ ccr1 }}"
+
+ block:
+ - name: add resource pool with check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ check_mode: true
+ register: resource_result_001
+
+ - assert:
+ that:
+ - resource_result_001.changed is sameas true
+
+ - name: add resource pool
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ register: resource_result_002
+
+ - assert:
+ that:
+ - resource_result_002.changed is sameas true
+ - resource_result_002.resource_pool_config is defined
+ - resource_result_002.resource_pool_config.name == "test_resource_001"
+
+ - name: add resource pool(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ register: resource_result_003
+
+ - assert:
+ that:
+ - resource_result_003.changed is sameas false
+
+ - name: change resource pool config with the custom default value and check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: custom
+ cpu_shares: custom
+ check_mode: true
+ register: resource_result_004
+
+ - assert:
+ that:
+ - resource_result_004.changed is sameas true
+
+ - name: change resource pool config with the custom default value
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: custom
+ cpu_shares: custom
+ register: resource_result_005
+
+ - assert:
+ that:
+ - resource_result_005.changed is sameas true
+ - resource_result_005.resource_pool_config is defined
+ - resource_result_005.resource_pool_config.cpuAllocation.shares.level == 'custom'
+ - resource_result_005.resource_pool_config.cpuAllocation.shares.shares == 4000
+ - resource_result_005.resource_pool_config.memoryAllocation.shares.level == 'custom'
+ - resource_result_005.resource_pool_config.memoryAllocation.shares.shares == 163840
+
+ - name: change resource pool config with the custom default value(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: custom
+ cpu_shares: custom
+ register: resource_result_006
+
+ - assert:
+ that:
+ - resource_result_006.changed is sameas false
+ - resource_result_006.resource_pool_config is defined
+
+ - name: change resource pool config with the allocation_shares
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: custom
+ mem_allocation_shares: 1000
+ cpu_shares: custom
+ cpu_allocation_shares: 1000
+ register: resource_result_007
+
+ - assert:
+ that:
+ - resource_result_007.changed is sameas true
+ - resource_result_007.resource_pool_config is defined
+ - resource_result_007.resource_pool_config.cpuAllocation.shares.level == 'custom'
+ - resource_result_007.resource_pool_config.cpuAllocation.shares.shares == 1000
+ - resource_result_007.resource_pool_config.memoryAllocation.shares.level == 'custom'
+ - resource_result_007.resource_pool_config.memoryAllocation.shares.shares == 1000
+
+ - name: change resource pool config with the allocation_shares(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: custom
+ mem_allocation_shares: 1000
+ cpu_shares: custom
+ cpu_allocation_shares: 1000
+ register: resource_result_008
+
+ - assert:
+ that:
+ - resource_result_008.changed is sameas false
+ - resource_result_008.resource_pool_config is defined
+
+ - name: change resource pool config with some option and check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: normal
+ mem_limit: 1
+ mem_reservation: 1
+ mem_expandable_reservations: false
+ cpu_shares: normal
+ cpu_limit: 1
+ cpu_reservation: 1
+ cpu_expandable_reservations: false
+ check_mode: true
+ register: resource_result_009
+
+ - assert:
+ that:
+ - resource_result_009.changed is sameas true
+
+ - name: change resource pool config with some option
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: normal
+ mem_limit: 1
+ mem_reservation: 1
+ mem_expandable_reservations: false
+ cpu_shares: normal
+ cpu_limit: 1
+ cpu_reservation: 1
+ cpu_expandable_reservations: false
+ register: resource_result_010
+
+ - assert:
+ that:
+ - resource_result_010.changed is sameas true
+ - resource_result_010.resource_pool_config is defined
+ - resource_result_010.resource_pool_config.cpuAllocation.shares.level == 'normal'
+ - resource_result_010.resource_pool_config.cpuAllocation.limit == 1
+ - resource_result_010.resource_pool_config.cpuAllocation.reservation == 1
+ - resource_result_010.resource_pool_config.cpuAllocation.expandableReservation is sameas false
+ - resource_result_010.resource_pool_config.memoryAllocation.shares.level == 'normal'
+ - resource_result_010.resource_pool_config.memoryAllocation.limit == 1
+ - resource_result_010.resource_pool_config.memoryAllocation.reservation == 1
+ - resource_result_010.resource_pool_config.memoryAllocation.expandableReservation is sameas false
+
+ - name: change resource pool config with some option(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ mem_shares: normal
+ mem_limit: 1
+ mem_reservation: 1
+ mem_expandable_reservations: false
+ cpu_shares: normal
+ cpu_limit: 1
+ cpu_reservation: 1
+ cpu_expandable_reservations: false
+ register: resource_result_011
+
+ - assert:
+ that:
+ - resource_result_011.changed is sameas false
+ - resource_result_011.resource_pool_config is defined
+
+ - name: remove resource pool with check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ state: absent
+ check_mode: true
+ register: resource_result_012
+
+ - assert:
+ that:
+ - resource_result_012.changed is sameas true
+
+ - name: remove resource pool
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ state: absent
+ register: resource_result_013
+
+ - assert:
+ that:
+ - resource_result_013.changed is sameas true
+ - resource_result_013.resource_pool_config is defined
+
+ - name: remove resource pool(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_001
+ state: absent
+ register: resource_result_014
+
+ - assert:
+ that:
+ - resource_result_014.changed is sameas false
+ - resource_result_014.resource_pool_config is defined
+
+# Tests on ESXi host
+- name: set the vmware_resource_pool module default values without cluster parameter
+ module_defaults:
+ vmware_resource_pool:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ esxi_hostname: "{{ esxi2 }}"
+
+ block:
+ # Remove ESXi host from cluster for tests
+ - name: Enter maintenance mode
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi2 }}"
+ state: present
+
+ - name: Move ESXi out of Cluster
+ vmware_host:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ folder: "{{ dc1 }}/host"
+ esxi_hostname: "{{ esxi2 }}"
+ state: reconnect
+
+ - name: Exit maintenance mode
+ vmware_maintenancemode:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: "{{ esxi2 }}"
+ state: absent
+
+ - name: add resource pool to ESXi with check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ check_mode: true
+ register: resource_result_015
+
+ - assert:
+ that:
+ - resource_result_015.changed is sameas true
+
+ - name: add resource pool to ESXi
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ register: resource_result_016
+
+ - assert:
+ that:
+ - resource_result_016.changed is sameas true
+
+ - name: add resource pool to ESXi(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ register: resource_result_017
+
+ - assert:
+ that:
+ - resource_result_017.changed is sameas false
+
+ - name: change resource pool config with the custom default value and check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ mem_shares: custom
+ cpu_shares: custom
+ check_mode: true
+ register: resource_result_018
+
+ - assert:
+ that:
+ - resource_result_018.changed is sameas true
+
+ - name: change resource pool config with the custom default value
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ mem_shares: custom
+ cpu_shares: custom
+ register: resource_result_019
+
+ - assert:
+ that:
+ - resource_result_019.changed is sameas true
+ - resource_result_019.resource_pool_config is defined
+ - resource_result_019.resource_pool_config.cpuAllocation.shares.level == 'custom'
+ - resource_result_019.resource_pool_config.cpuAllocation.shares.shares == 4000
+ - resource_result_019.resource_pool_config.memoryAllocation.shares.level == 'custom'
+ - resource_result_019.resource_pool_config.memoryAllocation.shares.shares == 163840
+
+ - name: remove resource pool from ESXi with check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ state: absent
+ check_mode: true
+ register: resource_result_020
+
+ - assert:
+ that:
+ - resource_result_020.changed is sameas true
+
+ - name: remove resource pool from ESXi
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ state: absent
+ register: resource_result_021
+
+ - assert:
+ that:
+ - resource_result_021.changed is sameas true
+
+ - name: remove resource pool from ESXi(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_015
+ state: absent
+ register: resource_result_023
+
+ - assert:
+ that:
+ - resource_result_023.changed is sameas false
+
+- name: set the vmware_resource_pool module default values without cluster and esxi_hostnamme parameter
+ module_defaults:
+ vmware_resource_pool:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ datacenter: "{{ dc1 }}"
+ parent_resource_pool: DC0_C0_RP1
+
+ block:
+ - name: add resource pool to Parent Resource Pool with check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ check_mode: true
+ register: resource_result_024
+
+ - assert:
+ that:
+ - resource_result_024.changed is sameas true
+
+ - name: add resource pool to Parent Resource Pool
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ register: resource_result_025
+
+ - assert:
+ that:
+ - resource_result_025.changed is sameas true
+
+ - name: add resource pool to Parent Resource Pool(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ register: resource_result_026
+
+ - assert:
+ that:
+ - resource_result_026.changed is sameas false
+
+ - name: change resource pool config with the custom default value and check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ mem_shares: custom
+ cpu_shares: custom
+ check_mode: true
+ register: resource_result_027
+
+ - assert:
+ that:
+ - resource_result_027.changed is sameas true
+
+ - name: change resource pool config with the custom default value
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ mem_shares: custom
+ cpu_shares: custom
+ register: resource_result_028
+
+ - assert:
+ that:
+ - resource_result_028.changed is sameas true
+ - resource_result_028.resource_pool_config is defined
+ - resource_result_028.resource_pool_config.cpuAllocation.shares.level == 'custom'
+ - resource_result_028.resource_pool_config.cpuAllocation.shares.shares == 4000
+ - resource_result_028.resource_pool_config.memoryAllocation.shares.level == 'custom'
+ - resource_result_028.resource_pool_config.memoryAllocation.shares.shares == 163840
+
+ - name: remove resource pool from Parent Resource Pool with check_mode
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ state: absent
+ check_mode: true
+ register: resource_result_029
+
+ - assert:
+ that:
+ - resource_result_029.changed is sameas true
+
+ - name: remove resource pool from Parent Resource Pool
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ state: absent
+ register: resource_result_030
+
+ - assert:
+ that:
+ - resource_result_030.changed is sameas true
+
+ - name: remove resource pool from Parent Resource Pool(idempotency check)
+ vmware_resource_pool:
+ resource_pool: test_resource_024
+ state: absent
+ register: resource_result_031
+
+ - assert:
+ that:
+ - resource_result_031.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/tasks/main.yml
new file mode 100644
index 00000000..041c5ee0
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_resource_pool_info/tasks/main.yml
@@ -0,0 +1,20 @@
+# Test code for the vmware_resource_pool_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Gather info about resource pool
+ vmware_resource_pool_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: resource_result_0001
+
+- name: ensure a resource pool is present
+ assert:
+ that:
+ - "{{ resource_result_0001.changed == false }}"
+ - "{{ resource_result_0001.resource_pool_info is defined }}"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/aliases
new file mode 100644
index 00000000..9cc67c41
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+unsupported
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml
new file mode 100644
index 00000000..8961c691
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml
@@ -0,0 +1,7 @@
+# Test code for the vmware_tag Operations.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- include: tag_crud_ops.yml
+- include: tag_manager_ops.yml
+- include: tag_manager_duplicate_tag_cat.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_crud_ops.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_crud_ops.yml
new file mode 100644
index 00000000..3f3d08a4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_crud_ops.yml
@@ -0,0 +1,112 @@
+# Test code for the vmware_tag CRUD Operations.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &cat_create
+ name: Create Category
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: Sample_Cat_0006
+ category_description: Sample Description
+ category_cardinality: 'multiple'
+ state: present
+ register: category_create
+
+- name: Check Category is created
+ assert:
+ that:
+ - category_create.changed
+
+- <<: *cat_create
+ name: Create category again
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not category_create.changed
+
+- name: Set Cat_ID Paramter. Required for Tag creation
+ set_fact: Cat_ID={{ category_create['category_results']['category_id'] }}
+
+# Testcase Create Tag
+- &tag_create
+ name: Create a tag
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: Sample_Tag_0001
+ category_id: "{{ Cat_ID }}"
+ tag_description: Sample Description
+ state: present
+ register: tag_creation
+
+- name: Check tag is created
+ assert:
+ that:
+ - tag_creation.changed
+
+- <<: *tag_create
+ name: Create a tag again
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not tag_creation.changed
+
+# Testcase Update Tag Description (reconfig)
+- &tag_update
+ name: Update Tag Description
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: Sample_Tag_0001
+ category_id: "{{ Cat_ID }}"
+ tag_description: Some fancy description
+ state: present
+ register: update_tag_desc
+
+- name: Check tag description updated
+ assert:
+ that:
+ - update_tag_desc.changed
+
+- <<: *tag_update
+ name: Update tag description again
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not update_tag_desc.changed
+
+# Testcase Delete the Tag
+- &tag_delete
+ name: Delete Tag
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: Sample_Tag_0001
+ category_id: "{{ Cat_ID }}"
+ state: absent
+ register: delete_tag
+
+- name: Check Tag is Deleted
+ assert:
+ that:
+ - delete_tag.changed
+- <<: *tag_delete
+ name: Delete tag again
+
+- name: Check if no changes are made
+ assert:
+ that:
+ - not delete_tag.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_duplicate_tag_cat.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_duplicate_tag_cat.yml
new file mode 100644
index 00000000..90ea3389
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_duplicate_tag_cat.yml
@@ -0,0 +1,188 @@
+# Test code for the vmware_tag_manager
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Create first category
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ cat_one }}"
+ category_cardinality: 'multiple'
+ state: present
+ register: category_one_create
+
+- name: Create second category
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ cat_two }}"
+ category_cardinality: 'multiple'
+ state: present
+ register: category_two_create
+
+- name: Check categories are created
+ assert:
+ that:
+ - category_two_create.changed
+ - category_one_create.changed
+
+- name: Set category one id
+ set_fact: cat_one_id={{ category_one_create['category_results']['category_id'] }}
+
+- name: Set category two id
+ set_fact: cat_two_id={{ category_two_create['category_results']['category_id'] }}
+
+- name: Create duplicate tags in two different categories
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_one }}"
+ category_id: "{{ cat_one_id }}"
+ state: present
+ register: tag_one_create
+
+- name: Check tag is created
+ assert:
+ that:
+ - tag_one_create.changed
+
+- name: Create duplicate tags in two different categories
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_one }}"
+ category_id: "{{ cat_two_id }}"
+ state: present
+ register: tag_two_create
+
+- name: Check tag is created
+ assert:
+ that:
+ - tag_two_create.changed
+
+- name: Create duplicate tags in two different categories
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_two }}"
+ category_id: "{{ cat_one_id }}"
+ state: present
+ register: tag_one_create
+
+- name: Check tag is created
+ assert:
+ that:
+ - tag_one_create.changed
+
+- name: Create duplicate tags in two different categories
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_two }}"
+ category_id: "{{ cat_two_id }}"
+ state: present
+ register: tag_two_create
+
+- name: Check tag is created
+ assert:
+ that:
+ - tag_two_create.changed
+
+- name: Get VM Facts
+ vmware_vm_facts:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ register: vm_facts
+
+- set_fact: vm_name="{{ vm_facts['virtual_machines'][0]['guest_name'] }}"
+
+- name: Assign tags to given virtual machine
+ vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - "{{ cat_one }}:{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: add
+ delegate_to: localhost
+ register: vm_tag_info
+
+- name: Check if we assigned correct tags
+ assert:
+ that:
+ - vm_tag_info.changed
+
+- name: Delete Tags for category_1001
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ item }}"
+ category_id: "{{ cat_one_id }}"
+ state: absent
+ register: delete_tag_category_1001
+ with_items:
+ - "{{ tag_one }}"
+ - "{{ tag_two }}"
+
+- name: Check if the tags are deleted for category_1001
+ assert:
+ that:
+ - item.changed
+ loop: "{{ delete_tag_category_1001.results }}"
+
+- name: Delete Tags for category_1002
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ item }}"
+ category_id: "{{ cat_two_id }}"
+ state: absent
+ register: delete_tag_category_1002
+ with_items:
+ - "{{ tag_one }}"
+ - "{{ tag_two }}"
+
+- name: Check if the tags are deleted for category_1002
+ assert:
+ that:
+ - item.changed
+ loop: "{{ delete_tag_category_1002.results }}"
+
+- name: Delete Categories
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ item }}"
+ state: absent
+ register: delete_categories
+ with_items:
+ - "{{ cat_one }}"
+ - "{{ cat_two }}"
+ vars:
+ cat_one: category_1001
+ cat_two: category_1002
+ tag_one: tag_1001
+ tag_two: tag_1002
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml
new file mode 100644
index 00000000..9ebe9daf
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml
@@ -0,0 +1,90 @@
+# Test code for the vmware_tag Manager Operations.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Get VM Facts
+ vmware_vm_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ register: vm_info
+
+- set_fact: vm_name="{{ vm_info['virtual_machines'][0]['guest_name'] }}"
+
+# Get Tagname
+- &tag_info
+ name: Get info about tag
+ vmware_tag_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ register: tag_info
+
+- <<: *tag_info
+ name: Get info about tag in check mode
+ check_mode: true
+
+- set_fact: Tag_Name={{ tag_info['tag_facts'].keys() | list }}
+
+- debug: var=Tag_Name
+
+# Testcase Assign tag to virtual Machine
+- &tag_assign
+ name: Add tags to a virtual machine
+ vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - "{{ Tag_Name[0] }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: add
+ register: tag_manager_ops
+
+- name: Check tag is assign to virtual machine
+ assert:
+ that:
+ - tag_manager_ops.changed
+
+- name: Get tags from a virtual machine
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "{{ vm_name }}"
+ register: r
+
+- name: Get detailed tags' information from a virtual machine
+ vmware_guest_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ name: "{{ vm_name }}"
+ tags: true
+ tag_details: true
+ register: tag_details
+
+- name: Check if tag information is available
+ assert:
+ that:
+ - not r.changed
+ - r['instance']['tags'] is defined
+ - "{{ Tag_Name[0] in r['instance']['tags'] }}"
+ - not tag_details.changed
+ - tag_details['instance']['tags'] is defined
+ - "{{ Tag_Name[0] == tag_details['instance']['tags'][0]['name'] }}"
+
+- <<: *tag_assign
+ name: Add tags to a virtual machine again
+
+- name: Check tag is not assigned to virtual machine again
+ assert:
+ that:
+ - not tag_manager_ops.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/aliases
new file mode 100644
index 00000000..9cc67c41
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+unsupported
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml
new file mode 100644
index 00000000..c7b0209a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml
@@ -0,0 +1,5 @@
+# Test code for the vmware_tag_info.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- include: tag_info.yml \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/tag_info.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/tag_info.yml
new file mode 100644
index 00000000..e34be7eb
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/tag_info.yml
@@ -0,0 +1,22 @@
+# Test code for the vmware_tag_info.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &tag_info
+ name: Get info about tag
+ vmware_tag_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ register: tag_info
+
+- <<: *tag_info
+ name: Get info about tag in check mode
+ check_mode: true
+
+- name: Check if facts exists
+ assert:
+ that:
+ - tag_info['tag_facts'] is defined
+ - tag_info['tag_info'] is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/cleanup.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/cleanup.yml
new file mode 100644
index 00000000..3e6586c9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/cleanup.yml
@@ -0,0 +1,20 @@
+- name: Delete Tags
+ community.vmware.vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_one }}"
+ category_id: "{{ cat_one_id }}"
+ state: absent
+ register: delete_tag
+
+- name: Delete Categories
+ community.vmware.vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ cat_one }}"
+ state: absent
+ register: delete_categories
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml
new file mode 100644
index 00000000..e49301ef
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml
@@ -0,0 +1,33 @@
+# Test code for the vmware_tag_manger Operations.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- set_fact:
+ cat_one: category_1003
+ tag_one: tag:1003
+
+- block:
+ - name: Create first category
+ community.vmware.vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ cat_one }}"
+ category_cardinality: 'multiple'
+ state: present
+ register: category_one_create
+
+ - name: Set category one id
+ set_fact: cat_one_id={{ category_one_create['category_results']['category_id'] }}
+
+ - include: tag_manager_dict.yml
+ always:
+ - include: cleanup.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/tag_manager_dict.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/tag_manager_dict.yml
new file mode 100644
index 00000000..9c9dc5c6
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/tag_manager_dict.yml
@@ -0,0 +1,187 @@
+# Test code for the vmware_tag_manager Operations.
+# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Testcase for https://github.com/ansible/ansible/issues/65765
+
+- name: Create tag with colon in name
+ community.vmware.vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_one }}"
+ category_id: "{{ cat_one_id }}"
+ state: present
+ register: tag_one_create
+
+- name: Check tag is created
+ assert:
+ that:
+ - tag_one_create.changed
+
+- name: Get VM Facts
+ community.vmware.vmware_vm_info:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ register: vm_info
+
+- set_fact:
+ vm_name: "{{ vm_info['virtual_machines'][0]['guest_name'] }}"
+ vm_moid: "{{ vm_info['virtual_machines'][0]['moid'] }}"
+
+- name: Assign tag to given virtual machine
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: add
+ register: vm_tag_info
+
+- name: Assign tag to rw_datastore
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: add
+ register: datastore_tag_info
+
+- name: Check if we assigned correct tags
+ assert:
+ that:
+ - vm_tag_info.changed
+ - datastore_tag_info.changed
+
+- name: Remove tag to given virtual machine
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: remove
+ register: vm_tag_info
+
+- name: Test idempotency for state set
+ block:
+ - name: Set the tags on a VM to a given list
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: set
+ register: vm_tag_info
+
+ - name: Check the module assigned the tags
+ assert:
+ that:
+ - vm_tag_info.changed
+
+ - name: Set the tags on a VM to a given list again
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: set
+ register: vm_tag_info
+
+ - name: Check idempotency
+ assert:
+ that:
+ - not vm_tag_info.changed
+
+ - name: Remove tag from given virtual machine
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: remove
+
+- name: Assign tag to given virtual machine using moid
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ moid: "{{ vm_moid }}"
+ object_type: VirtualMachine
+ state: add
+ register: vm_tag_info
+
+- name: Check if we assigned correct tags
+ assert:
+ that:
+ - vm_tag_info.changed
+
+- name: Remove tag to datastore
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ rw_datastore }}"
+ object_type: Datastore
+ state: remove
+ register: datastore_tag_info
+
+- name: Remove tag to given virtual machine
+ community.vmware.vmware_tag_manager:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_names:
+ - category: "{{ cat_one }}"
+ tag: "{{ tag_one }}"
+ object_name: "{{ vm_name }}"
+ object_type: VirtualMachine
+ state: remove
+ register: vm_tag_info
+
+- name: Check if we removed correct tag
+ assert:
+ that:
+ - vm_tag_info.changed
+ - datastore_tag_info.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/tasks/main.yml
new file mode 100644
index 00000000..cfaff4c4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_target_canonical_info/tasks/main.yml
@@ -0,0 +1,37 @@
+# Test code for the vmware_target_canonical_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: Gather target info for all ESXi host from given cluster
+ vmware_target_canonical_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ cluster_name: "{{ ccr1 }}"
+ register: target_0001_results
+
+- assert:
+ that:
+ - "not target_0001_results.changed"
+ - "target_0001_results.scsi_tgt_info is defined"
+
+- name: Gather target info for ESXi host
+ vmware_target_canonical_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ esxi_hostname: '{{ esxi1 }}'
+ register: target_0002_results
+
+- assert:
+ that:
+ - "not target_0002_results.changed"
+ - "target_0002_results.scsi_tgt_info is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/aliases
new file mode 100644
index 00000000..3f8a3477
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/tasks/main.yml
new file mode 100644
index 00000000..f64520e7
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vc_infraprofile_info/tasks/main.yml
@@ -0,0 +1,72 @@
+# Test code for the vmware_vc_infraprofile_info.
+# Copyright: (c) 2019, Naveenkumar G P <ngp@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Get the version number of vcenter
+ vmware_about_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: about
+
+- name: Get List of infraprofile configs
+ vmware_vc_infraprofile_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ api: "list"
+ register: infraprofile_config_info
+ when: about.about_info.version | int >= 7
+- debug: var=infraprofile_config_info
+
+- name: export Vcenter appliance infra profile config
+ vmware_vc_infraprofile_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ api: "export"
+ profiles: "ApplianceManagement"
+ register: infraprofile_config_info
+ when: about.about_info.version | int >= 7
+- debug: var=infraprofile_config_info
+
+- name: validate infra profile config json
+ vmware_vc_infraprofile_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ api: "validate"
+ profiles: "ApplianceManagement"
+ config_path: "export.json"
+ register: infraprofile_config_info
+ when: about.about_info.version | int >= 7
+- debug: var=infraprofile_config_info
+
+- name: import Vcenter appliance infra profile config
+ vmware_vc_infraprofile_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ api: "import"
+ profiles: "ApplianceManagement"
+ config_path: "export.json"
+ register: infraprofile_config_info
+ when: about.about_info.version | int >= 7
+- debug: var=infraprofile_config_info
+
+- name: Check infraprofile configs details
+ assert:
+ that:
+ - infraprofile_config_info is changed
+ when: infraprofile_config_info == true \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/tasks/main.yml
new file mode 100644
index 00000000..c3baa9ec
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings/tasks/main.yml
@@ -0,0 +1,222 @@
+# Test code for the vmware_vcenter_settings module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Configure general settings in check mode
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ runtime_settings:
+ unique_id: 7
+ managed_address: 192.168.1.0
+ vcenter_server_name: "{{ inventory_hostname }}"
+ user_directory:
+ timeout: 120
+ query_limit: true
+ query_limit_size: 100000
+ validation: true
+ validation_period: 1440
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ snmp_receivers:
+ snmp_receiver_1_url: localhost
+ snmp_receiver_1_enabled: true
+ snmp_receiver_1_port: 162
+ snmp_receiver_1_community: public
+ timeout_settings:
+ normal_operations: 30
+ long_operations: 120
+ logging_options: info
+ validate_certs: false
+ register: all_settings_results_check_mode
+ check_mode: true
+
+- debug: var=all_settings_results_check_mode
+
+- name: Configure general settings
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ runtime_settings:
+ unique_id: 7
+ managed_address: 192.168.1.0
+ vcenter_server_name: "{{ inventory_hostname }}"
+ user_directory:
+ timeout: 120
+ query_limit: true
+ query_limit_size: 100000
+ validation: true
+ validation_period: 1440
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ snmp_receivers:
+ snmp_receiver_1_url: localhost
+ snmp_receiver_1_enabled: true
+ snmp_receiver_1_port: 162
+ snmp_receiver_1_community: public
+ timeout_settings:
+ normal_operations: 30
+ long_operations: 120
+ logging_options: info
+ validate_certs: false
+ register: all_settings_results
+
+- debug: var=all_settings_results
+
+- name: Configure settings with out runtime_settings parameter
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ register: without_runtime_settings_results
+
+- debug: var=without_runtime_settings_results
+
+- name: Configure settings with check mode and diff mode
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ diff: true
+ check_mode: true
+ register: configure_settings_check_diff_mode_result
+
+- name: Make sure if the change occurred and to exist the diff key
+ assert:
+ that:
+ - configure_settings_check_diff_mode_result.changed is sameas true
+ - configure_settings_check_diff_mode_result.diff is defined
+
+- name: Configure settings without check mode and diff mode
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ register: configure_settings_result
+
+- name: Make sure if the change occurred
+ assert:
+ that:
+ - configure_settings_result.changed is sameas true
+
+- name: Configure settings without check mode and diff mode(idempotency check)
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ register: configure_settings_idempotency_check_result
+
+- name: Make sure if the change doesn't occur
+ assert:
+ that:
+ - configure_settings_idempotency_check_result.changed is sameas false
+
+- name: Configure advanced settings
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ advanced_settings:
+ 'config.vcls.clusters.domain-c8.enabled': 'false'
+ register: configure_advanced_settings
+
+- name: Make sure that advanced settings are configured
+ assert:
+ that:
+ - configure_advanced_settings.changed
+
+- name: Configure advanced settings again (idempotency)
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ database:
+ max_connections: 50
+ task_cleanup: true
+ task_retention: 180
+ event_cleanup: true
+ event_retention: 180
+ mail:
+ server: mail.example.local
+ sender: vcenter@{{ inventory_hostname }}
+ advanced_settings:
+ 'config.vcls.clusters.domain-c8.enabled': 'false'
+ register: configure_advanced_settings_again
+
+- name: Make sure that advanced settings are not configured (idempotency)
+ assert:
+ that:
+ - not configure_advanced_settings_again.changed
+
+- name: Restore the original advanced_settings configuration
+ community.vmware.vmware_vcenter_settings:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ advanced_settings:
+ 'config.vcls.clusters.domain-c8.enabled': 'true'
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/aliases
new file mode 100644
index 00000000..dea29ccd
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/aliases
@@ -0,0 +1,4 @@
+shippable/vcenter/group1
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/tasks/main.yml
new file mode 100644
index 00000000..6ca52cef
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_settings_info/tasks/main.yml
@@ -0,0 +1,53 @@
+# Test code for the vmware_vcenter_settings_info module.
+# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: "Gather info about vCenter settings"
+ community.vmware.vmware_vcenter_settings_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: gather_info_about_vcenter_settings_result
+
+- assert:
+ that:
+ - gather_info_about_vcenter_settings_result.vcenter_config_info is defined
+ - gather_info_about_vcenter_settings_result.vcenter_config_info | length == 32
+
+- name: "Get a list of information about vCenter settings by specifying the properties"
+ community.vmware.vmware_vcenter_settings_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ schema: vsphere
+ properties:
+ - config.workflow.port
+ - config.log.level
+ - vpxd.locale
+ validate_certs: false
+ register: get_list_of_info_about_vcenter_settings_result
+
+- assert:
+ that:
+ - get_list_of_info_about_vcenter_settings_result.vcenter_config_info['config.workflow.port'] is defined
+ - get_list_of_info_about_vcenter_settings_result.vcenter_config_info['config.log.level'] is defined
+ - get_list_of_info_about_vcenter_settings_result.vcenter_config_info['vpxd.locale'] is defined
+
+- name: "Gather all vCenter settings"
+ community.vmware.vmware_vcenter_settings_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ schema: vsphere
+ register: all_vcenter_settings_result
+
+- assert:
+ that:
+ - all_vcenter_settings_result.vcenter_config_info['config.vmacore.threadPool.TaskMax'] is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/tasks/main.yml
new file mode 100644
index 00000000..478d5b18
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vcenter_statistics/tasks/main.yml
@@ -0,0 +1,126 @@
+# Test code for the vmware_vcenter_statistics module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Disable all the statistics
+ vmware_vcenter_statistics:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ interval_past_day:
+ enabled: false
+ interval_past_week:
+ enabled: false
+ interval_past_month:
+ enabled: false
+ interval_past_year:
+ enabled: false
+ validate_certs: false
+ register: statistics_results_check_mode
+
+- name: Configure statistics in check mode
+ vmware_vcenter_statistics: &stats
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ interval_past_day:
+ enabled: true
+ interval_minutes: 5
+ save_for_days: 3
+ level: 2
+ interval_past_week:
+ enabled: true
+ interval_minutes: 30
+ save_for_weeks: 1
+ level: 2
+ interval_past_month:
+ enabled: true
+ interval_hours: 2
+ save_for_months: 1
+ level: 1
+ interval_past_year:
+ enabled: true
+ interval_days: 1
+ save_for_years: 1
+ level: 1
+ validate_certs: false
+ register: statistics_results_check_mode
+ check_mode: true
+
+- debug: var=statistics_results_check_mode
+
+- name: ensure statistics were configured
+ assert:
+ that:
+ - statistics_results_check_mode is changed
+
+- name: Configure statistics
+ vmware_vcenter_statistics:
+ <<: *stats
+ register: statistics_results
+
+- debug: var=statistics_results
+
+- name: ensure statistics were configured
+ assert:
+ that:
+ - statistics_results is changed
+
+- name: Configure statistics (again)
+ vmware_vcenter_statistics:
+ <<: *stats
+ register: statistics_results
+
+- debug: var=statistics_results
+
+- name: ensure statistics were configured
+ assert:
+ that:
+ - not (statistics_results is changed)
+
+- name: Configure statistics intervall to level 2 for later check
+ vmware_vcenter_statistics:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ interval_past_day:
+ enabled: true
+ level: 2
+ interval_past_week:
+ enabled: true
+ level: 2
+ interval_past_month:
+ enabled: true
+ level: 2
+ interval_past_year:
+ enabled: true
+ level: 2
+ validate_certs: false
+
+- name: Increase daily and weekly while decrease monthly and yearly
+ vmware_vcenter_statistics:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ interval_past_day:
+ enabled: true
+ level: 3
+ interval_past_week:
+ enabled: true
+ level: 3
+ interval_past_month:
+ enabled: true
+ level: 1
+ interval_past_year:
+ enabled: true
+ level: 1
+ validate_certs: false
+ register: statistics_results_mixed_increase_decrease
+
+- name: Ensure statistics were configured
+ assert:
+ that:
+ - statistics_results_mixed_increase_decrease is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/tasks/main.yml
new file mode 100644
index 00000000..1d37af00
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_config_option/tasks/main.yml
@@ -0,0 +1,154 @@
+# Test code for the vmware_vm_config_option module.
+# Copyright: (c) 2021, VMware, Inc. All Rights Reserved.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: get list of config option keys from ESXi host
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ get_hardware_versions: true
+ register: config_option_keys_1
+
+- debug:
+ var: config_option_keys_1
+
+- name: get list of config option keys from cluster
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ cluster_name: "{{ ccr1 }}"
+ get_hardware_versions: true
+ register: config_option_keys_2
+
+- debug:
+ var: config_option_keys_2
+
+# Ignore errors due to there is known issue on vSphere 7.0.x
+# https://github.com/vmware/pyvmomi/issues/915
+- name: get list of supported guest IDs from ESXi host
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ get_guest_os_ids: true
+ register: guest_ids_1
+ ignore_errors: true
+
+- debug:
+ var: guest_ids_1
+
+- name: check guest ID list returned when task not failed
+ assert:
+ that:
+ - "'instance' in guest_ids_1"
+ - guest_ids_1.instance | length != 0
+ when:
+ - "'failed' in guest_ids_1"
+ - not guest_ids_1.failed
+
+- block:
+ # Ignore errors due to there is known issue on vSphere 7.0.x
+ # https://github.com/vmware/pyvmomi/issues/915
+ - name: get list of supported guest IDs from ESXi host with config option key
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ get_guest_os_ids: true
+ hardware_version: "{{ config_option_keys_1['instance']['supported_hardware_versions'][0] }}"
+ register: guest_ids_2
+ ignore_errors: true
+
+ - debug:
+ var: guest_ids_2
+ - name: check guest ID list returned when task not failed
+ assert:
+ that:
+ - "'instance' in guest_ids_2"
+ - guest_ids_2.instance | length != 0
+ when:
+ - "'failed' in guest_ids_2"
+ - not guest_ids_2.failed
+ when:
+ - "'instance' in config_option_keys_1"
+ - "'supported_hardware_versions' in config_option_keys_1['instance']"
+
+# Ignore errors due to there is known issue on vSphere 7.0.x
+# https://github.com/vmware/pyvmomi/issues/915
+- name: get dict of recommended configs for specified guest ID from ESXi host
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ get_config_options: true
+ guest_id: "rhel6_64Guest"
+ register: recommended_configs
+ ignore_errors: true
+
+- debug:
+ var: recommended_configs
+- name: check guest ID list returned when task not failed
+ assert:
+ that:
+ - "'instance' in recommended_configs"
+ - recommended_configs.instance | length != 0
+ when:
+ - "'failed' in recommended_configs"
+ - not recommended_configs.failed
+
+- name: get list of config option keys by connecting to ESXi host
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ esxi_hosts[0] }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ get_hardware_versions: true
+ register: config_option_keys_3
+
+- debug:
+ var: config_option_keys_3
+
+- name: get list of supported guest IDs by connecting to ESXi host with config option key
+ community.vmware.vmware_vm_config_option:
+ validate_certs: false
+ hostname: "{{ esxi_hosts[0] }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ esxi_hostname: "{{ esxi_hosts[0] }}"
+ get_guest_os_ids: true
+ hardware_version: "{{ config_option_keys_3['instance']['supported_hardware_versions'][2] }}"
+ register: guest_ids_3
+ ignore_errors: true
+
+- debug:
+ var: guest_ids_3
+- name: check guest ID list returned when task not failed
+ assert:
+ that:
+ - "'instance' in guest_ids_3"
+ - guest_ids_3.instance | length != 0
+ when:
+ - "'failed' in guest_ids_3"
+ - not guest_ids_3.failed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml
new file mode 100644
index 00000000..5c858049
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_host_drs_rule/tasks/main.yml
@@ -0,0 +1,121 @@
+# Test code for the vmware_vm_vm_drs_rule module.
+# Copyright: (c) 2017, Karsten Kaj Jakobsen <kj@patientsky.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Create DRS VM group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ # Options
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: DC0_C0_VM_GR1
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ state: present
+ register: drs_vm_group_01_results
+- debug: var=drs_vm_group_01_results
+
+- name: Create DRS Host group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ # Options
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: DC0_C0_HOST_GR1
+ hosts: '{{ esxi_hosts }}'
+ state: present
+ register: drs_host_group_01_results
+- debug: var=drs_host_group_01_results
+
+- name: Create mandatory DRS Affinity rule for VM/Host
+ vmware_vm_host_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_host_aff_0001
+ vm_group_name: DC0_C0_VM_GR1
+ host_group_name: DC0_C0_HOST_GR1
+ cluster_name: "{{ ccr1 }}"
+ enabled: true
+ affinity_rule: true
+ mandatory: true
+ register: drs_rule_host_0001_results
+- debug: var=drs_rule_host_0001_results
+- assert:
+ that:
+ - "{{ drs_rule_host_0001_results.changed }}"
+
+- name: Create non-mandatory DRS Anti-Affinity rule for VM/Host
+ vmware_vm_host_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_host_aff_0001
+ vm_group_name: DC0_C0_VM_GR1
+ host_group_name: DC0_C0_HOST_GR1
+ cluster_name: "{{ ccr1 }}"
+ enabled: true
+ affinity_rule: false
+ mandatory: false
+ register: drs_rule_host_0002_results
+- debug: var=drs_rule_host_0002_results
+- assert:
+ that:
+ - "{{ drs_rule_host_0001_results.changed }}"
+
+- name: Delete rules
+ vmware_vm_host_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_host_aff_0001
+ vm_group_name: DC0_C0_VM_GR1
+ host_group_name: DC0_C0_HOST_GR1
+ cluster_name: "{{ ccr1 }}"
+ state: absent
+ register: result
+- debug: var=result
+- assert:
+ that:
+ - result is changed
+
+- name: Delete DRS VM group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ # Options
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: DC0_C0_VM_GR1
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ state: absent
+
+- name: Delete DRS Host group
+ vmware_drs_group:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ # Options
+ cluster_name: '{{ ccr1 }}'
+ datacenter_name: '{{ dc1 }}'
+ group_name: DC0_C0_HOST_GR1
+ hosts: '{{ esxi_hosts }}'
+ state: absent
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/tasks/main.yml
new file mode 100644
index 00000000..1094a11c
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_info/tasks/main.yml
@@ -0,0 +1,98 @@
+# Test code for the vmware_vm_info module
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# Copyright, (c) 2018, Fedor Vompe <f.vompe@comptek.ru>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Get info from a given ESXi
+ vmware_vm_info:
+ validate_certs: false
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- &vm_data
+ name: Get info about available vms
+ vmware_vm_info:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ register: vm_info
+
+- &set_vm_by_name
+ set_fact:
+ vm_by_name: "{{ dict(vm_info.virtual_machines|map(attribute='guest_name')|zip(vm_info.virtual_machines)) }}"
+
+- set_fact:
+ my_vm1: "{{ vm_by_name['DC0_H0_VM1'] }}"
+- &vm_fact_check
+ name: Verify if VM info exist
+ assert:
+ that:
+ - "my_vm1.esxi_hostname is defined"
+ - "my_vm1.guest_fullname is defined"
+ - "my_vm1.ip_address is defined"
+ - "my_vm1.mac_address is defined"
+ - "my_vm1.power_state is defined"
+ - "my_vm1.uuid is defined"
+ - "my_vm1.vm_network is defined"
+
+- <<: *vm_data
+ name: Get info about available vms in check mode
+ check_mode: true
+
+- <<: *vm_fact_check
+ name: Verify if VM info exist in check mode
+
+- name: Get folder name from VM
+ vmware_guest_find:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ name: "{{ virtual_machines[0].name }}"
+ register: folder_path_info
+
+- set_fact:
+ folder_path: "{{ folder_path_info.folders[0] }}"
+ when: folder_path_info.folders is defined
+
+- name: Gather info about VM using folder
+ vmware_vm_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ folder: "{{ folder_path }}"
+ register: vm_info
+ when: folder_path_info.folders is defined
+- debug: var=vm_info
+
+- <<: *set_vm_by_name
+
+- set_fact:
+ my_vm0: "{{ vm_by_name['DC0_H0_VM0'] }}"
+
+- name: Check if info are returned for VM with folder specified
+ assert:
+ that:
+ - "my_vm0.esxi_hostname is defined"
+ - "my_vm0.guest_fullname is defined"
+ - "my_vm0.ip_address is defined"
+ - "my_vm0.mac_address is defined"
+ - "my_vm0.power_state is defined"
+ - "my_vm0.uuid is defined"
+ - "my_vm0.vm_network is defined"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/aliases
new file mode 100644
index 00000000..1abfff23
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/aliases
@@ -0,0 +1,2 @@
+cloud/vcenter
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/ansible.cfg b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/ansible.cfg
new file mode 100644
index 00000000..a0048a90
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/ansible.cfg
@@ -0,0 +1,9 @@
+[defaults]
+roles_path = ..
+
+[inventory]
+enable_plugins = community.vmware.vmware_vm_inventory
+cache = False
+#cache = True
+#cache_plugin = jsonfile
+#cache_connection = inventory_cache
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml
new file mode 100644
index 00000000..65e643b7
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml
@@ -0,0 +1,55 @@
+---
+- hosts: localhost
+ module_defaults:
+ group/vmware:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ port: "{{ vcenter_port|default('443') }}"
+ validate_certs: "{{ vmware_validate_certs|default('no') }}"
+ tasks:
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+ - name: Create VM
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ folder: vm
+ esxi_hostname: "{{ esxi1 }}"
+ state: powered-on
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: local
+ cdrom:
+ type: iso
+ iso_path: "[{{ ro_datastore }}] fedora.iso"
+ hardware:
+ # vmware_guest_disk need vmx-13 to reconfigure the disks
+ version: 13
+ memory_mb: 1024
+ num_cpus: 1
+ scsi: paravirtual
+ register: vm_create
+
+ - copy:
+ dest: vmware.yaml
+ content: |
+ plugin: community.vmware.vmware_vm_inventory
+ strict: false
+ hostname: {{ vcenter_hostname }}
+ username: {{ vcenter_username }}
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ with_tags: true
+ hostnames:
+ - config.name
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/runme.sh b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/runme.sh
new file mode 100755
index 00000000..8cecbac3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/runme.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+# shellcheck disable=SC2086,SC2048
+set -eux
+export ANSIBLE_CONFIG=ansible.cfg
+ansible-playbook prepare_environment.yml $*
+ansible-inventory --list -i vmware.yaml
+exec ansible-playbook -i vmware.yaml test_inventory.yml $*
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/test_inventory.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/test_inventory.yml
new file mode 100644
index 00000000..6c1ffb67
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/test_inventory.yml
@@ -0,0 +1,10 @@
+# Test code for the vmware guest dynamic plugin module
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+---
+- hosts: localhost
+ tasks:
+ - assert:
+ that:
+ - "{{ groups['debian8_64Guest'] | length }} == 1"
+ - hostvars['test_vm1'] is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/aliases
new file mode 100644
index 00000000..bbbe4ca4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/aliases
@@ -0,0 +1,3 @@
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
+cloud/vcenter \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/tasks/main.yml
new file mode 100644
index 00000000..b99ba0e4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy/tasks/main.yml
@@ -0,0 +1,164 @@
+# Test code for the vmware_tag CRUD Operations.
+# Copyright: (c) 2020, Dustin Scott <sdustin@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- block:
+ - name: Create category
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ cat_one }}"
+ category_cardinality: 'multiple'
+ state: present
+ register: category_one_create
+
+ - name: Set category one id
+ set_fact: cat_one_id={{ category_one_create['category_results']['category_id'] }}
+
+ - name: Create tag
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ tag_one }}"
+ category_id: "{{ cat_one_id }}"
+ state: present
+ register: tag_one_create
+
+ - name: Check tag is created
+ assert:
+ that:
+ - tag_one_create.changed
+
+ - &policy_create
+ name: Create or update a vSphere tag-based storage policy
+ community.vmware.vmware_vm_storage_policy:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ name: "{{ policy_one }}"
+ description: "{{ policy_one }}"
+ tag_category: "{{ cat_one }}"
+ tag_name: "{{ tag_one }}"
+ tag_affinity: true
+ state: "present"
+ register: policy_create
+
+ - name: Check policy is created
+ assert:
+ that:
+ - policy_create.changed
+
+ - <<: *policy_create
+ name: Create policy again
+
+ - name: Check policy is created
+ assert:
+ that:
+ - not policy_create.changed
+
+ - &policy_delete
+ name: Remove a vSphere tag-based storage policy
+ community.vmware.vmware_vm_storage_policy:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ name: "{{ policy_one }}"
+ state: "absent"
+ register: policy_delete
+
+ - name: Check policy is deleted
+ assert:
+ that:
+ - policy_delete.changed
+
+ - <<: *policy_delete
+ name: Delete policy again
+
+ - name: Check policy is deleted
+ assert:
+ that:
+ - not policy_delete.changed
+
+ # The tests are the failure test for issue 677.
+ # https://github.com/ansible-collections/community.vmware/issues/677
+ - name: The failure test when tag_category not exists
+ community.vmware.vmware_vm_storage_policy:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ name: "storage policy for issue 667"
+ description: "issue667"
+ tag_category: "issue667"
+ tag_name: "{{ tag_one }}"
+ tag_affinity: true
+ state: "present"
+ ignore_errors: true
+ register: policy_failure_test1
+
+ - name: Make sure if the task failed and an error message displayed including tag_category name
+ assert:
+ that:
+ - policy_failure_test1.failed is sameas true
+ - "'issue667 is not found in vCenter Server tag categories' in policy_failure_test1.msg"
+
+ - name: The failure test when tag_name not exists
+ community.vmware.vmware_vm_storage_policy:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ name: "storage policy for issue 667"
+ description: "issue667"
+ tag_category: "{{ cat_one }}"
+ tag_name: "issue667"
+ tag_affinity: true
+ state: "present"
+ ignore_errors: true
+ register: policy_failure_test2
+
+ - name: Make sure if the task failed and an error message displayed including tag_name name
+ assert:
+ that:
+ - policy_failure_test2.failed is sameas true
+ - "'issue667 is not found in vCenter Server tags' in policy_failure_test2.msg"
+
+ always:
+
+ - name: Delete Tags
+ vmware_tag:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ tag_name: "{{ item }}"
+ category_id: "{{ cat_one_id }}"
+ state: absent
+ register: delete_tag
+ with_items:
+ - "{{ tag_one }}"
+
+ - name: Delete Categories
+ vmware_category:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ category_name: "{{ item }}"
+ state: absent
+ register: delete_categories
+ with_items:
+ - "{{ cat_one }}"
+ vars:
+ cat_one: category_1004
+ tag_one: tag_1004
+ policy_one: policy_1004
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/aliases
new file mode 100644
index 00000000..b1682114
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/tasks/main.yml
new file mode 100644
index 00000000..3aa96625
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_storage_policy_info/tasks/main.yml
@@ -0,0 +1,23 @@
+# Test code for the vmware_vm_storage_policy_info module.
+# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- &spbm_data
+ name: Get information about vSphere SPBM info
+ vmware_vm_storage_policy_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ register: spbm_data
+
+- &spbm_check
+ assert:
+ that:
+ - spbm_data.spbm_profiles is defined
+
+- <<: *spbm_data
+ name: Get information about vSphere SPBM info in check mode
+ check_mode: true
+
+- <<: *spbm_check
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml
new file mode 100644
index 00000000..396be3b6
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_vm_drs_rule/tasks/main.yml
@@ -0,0 +1,163 @@
+# Test code for the vmware_vm_vm_drs_rule module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_virtualmachines: true
+
+- name: Create a DRS Affinity rule for vms in check mode
+ vmware_vm_vm_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_0001
+ cluster_name: "{{ ccr1 }}"
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ enabled: true
+ affinity_rule: true
+ mandatory: true
+ register: drs_rule_0001_results
+ check_mode: true
+
+- debug: var=drs_rule_0001_results
+
+- name: Check if changes are reported in check mode
+ assert:
+ that:
+ - drs_rule_0001_results.changed
+
+- &create_drs_rule
+ name: Create a DRS Affinity rule for vms
+ vmware_vm_vm_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_0001
+ cluster_name: "{{ ccr1 }}"
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ enabled: true
+ affinity_rule: true
+ mandatory: true
+ register: drs_rule_0001_results
+
+- debug: var=drs_rule_0001_results
+
+- name: Check if changes are made
+ assert:
+ that:
+ - drs_rule_0001_results.changed
+
+- <<: *create_drs_rule
+ name: Create a DRS Affinity rule for vms again
+
+- name: Check if no changes are made if drs rule is created again
+ assert:
+ that:
+ - not drs_rule_0001_results.changed
+
+- &update_drs_rule
+ name: Update a DRS Affinity rule for vms
+ vmware_vm_vm_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_0001
+ cluster_name: "{{ ccr1 }}"
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ enabled: false
+ affinity_rule: true
+ mandatory: false
+ register: drs_rule_0001_results
+
+- name: Check if changes are made if drs rule is created
+ assert:
+ that:
+ - drs_rule_0001_results.changed
+
+- <<: *update_drs_rule
+ name: Update a DRS Affinity rule for vms again
+
+- name: Check if no changes are made if drs rule is created again
+ assert:
+ that:
+ - not drs_rule_0001_results.changed
+
+- &delete_drs_rule
+ name: Delete a DRS Affinity rule for vms
+ vmware_vm_vm_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_0001
+ cluster_name: "{{ ccr1 }}"
+ state: absent
+ register: drs_rule_0001_results
+
+- name: Check if DRS rule is delete
+ assert:
+ that:
+ - drs_rule_0001_results.changed
+
+- <<: *delete_drs_rule
+ name: Delete a DRS Affinity rule for vms again
+
+- name: Check if DRS rule is not delete again
+ assert:
+ that:
+ - not drs_rule_0001_results.changed
+
+- &create_anti_drs_rule
+ name: Create a DRS Anti-Affinity rule for vms
+ vmware_vm_vm_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_0002
+ cluster_name: "{{ ccr1 }}"
+ vms: "{{ virtual_machines_in_cluster | map(attribute='name') | list }}"
+ enabled: true
+ affinity_rule: false
+ mandatory: false
+ register: drs_rule_0002_results
+
+- debug: var=drs_rule_0002_results
+
+- name: Check if DRS Anti-Affinity rule is created
+ assert:
+ that:
+ - drs_rule_0002_results.changed
+
+- <<: *create_anti_drs_rule
+ name: Create a DRS Anti-Affinity rule for vms again
+
+- debug: var=drs_rule_0002_results
+
+- name: Check if no changes are made if DRS Anti-Affinity rule is created again
+ assert:
+ that:
+ - not drs_rule_0002_results.changed
+
+- name: Delete a DRS Anti-Affinity rule for vms
+ vmware_vm_vm_drs_rule:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ drs_rule_name: drs_rule_0002
+ cluster_name: "{{ ccr1 }}"
+ state: absent
+ register: drs_rule_0002_results
+
+- name: Check if DRS rule is not delete
+ assert:
+ that:
+ - drs_rule_0002_results.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/tasks/main.yml
new file mode 100644
index 00000000..e1d659df
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel/tasks/main.yml
@@ -0,0 +1,62 @@
+# Test code for the vmware_vmkernel module.
+# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_switch: true
+
+- name: create basic portgroup
+ vmware_portgroup:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ switch_name: "{{ switch1 }}"
+ cluster_name: "{{ ccr1 }}"
+ portgroup_name: vMotion
+ vlan_id: 0
+ state: present
+ register: dvs_pg_result_0001
+
+- debug: var=dvs_pg_result_0001
+- name: Create VMkernel adapter with vMotion TCP/IP stack
+ vmware_vmkernel: &new_vmkernel
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ vswitch: "{{ switch1 }}"
+ portgroup: vMotion
+ mtu: 9000
+ network:
+ type: static
+ ip_address: 192.168.100.100
+ subnet_mask: 255.255.255.0
+ tcpip_stack: vmotion
+ state: present
+ validate_certs: false
+ register: host_vmkernel
+- debug: var=host_vmkernel
+
+- name: Create VMkernel adapter in check mode
+ vmware_vmkernel:
+ <<: *new_vmkernel
+ register: host_vmkernel
+ check_mode: true
+- debug: var=host_vmkernel
+
+- name: Delete VMkernel adapter
+ vmware_vmkernel:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ vswitch: "{{ switch1 }}"
+ device: '{{ host_vmkernel.device }}'
+ portgroup: vMotion
+ state: absent
+ validate_certs: false
+ register: host_vmkernel
+- debug: var=host_vmkernel
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/tasks/main.yml
new file mode 100644
index 00000000..eba5b86d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmkernel_info/tasks/main.yml
@@ -0,0 +1,35 @@
+# Test code for the vmware_vmkernel_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather VMkernel info for a given host
+ vmware_vmkernel_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_vmkernel
+- debug: var=host_vmkernel
+- assert:
+ that:
+ - host_vmkernel.host_vmk_info is defined
+
+- name: Gather VMkernel info for a given host in check mode
+ vmware_vmkernel_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: host_vmkernel_check_mode
+ check_mode: true
+- debug: var=host_vmkernel
+- assert:
+ that:
+ - host_vmkernel_check_mode.host_vmk_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/aliases
new file mode 100644
index 00000000..d1d14d22
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_2esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/tasks/main.yml
new file mode 100644
index 00000000..3452cff4
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vmotion/tasks/main.yml
@@ -0,0 +1,131 @@
+# Test code for the vmware_vmotion module.
+# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+ setup_resource_pool: true
+
+- name: Add ESXi Hosts to vCenter
+ vmware_host:
+ datacenter_name: '{{ dc1 }}'
+ esxi_hostname: '{{ item }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ folder: '/DC0/host'
+ state: present
+ with_items: "{{ esxi_hosts }}"
+
+- name: Disable the Maintenance Mode
+ vmware_maintenancemode:
+ esxi_hostname: '{{ item }}'
+ state: absent
+ with_items: "{{ esxi_hosts }}"
+
+- name: Create VM
+ vmware_guest:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ folder: vm
+ esxi_hostname: "{{ esxi1 }}"
+ state: present
+ guest_id: debian8_64Guest
+ disk:
+ - size_gb: 1
+ type: thin
+ datastore: '{{ rw_datastore }}'
+ hardware:
+ version: 11
+ memory_mb: 1024
+ num_cpus: 1
+ scsi: paravirtual
+ register: vm_create
+
+- name: Perform vMotion of non-existing VM
+ vmware_vmotion:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ vm_name: not_a_thing
+ destination_host: '{{ esxi2 }}'
+ destination_datastore: '{{ rw_datastore }}'
+ register: vm_vmotion
+ ignore_errors: true
+
+- assert:
+ that:
+ - vm_vmotion.msg == "Failed to find the virtual machine with not_a_thing"
+
+
+- name: Perform vMotion of virtual machine
+ vmware_vmotion:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ vm_name: test_vm1
+ destination_host: '{{ esxi2 }}'
+ destination_datastore: '{{ rw_datastore }}'
+ register: vm_vmotion
+
+- name: assert that changes were made
+ assert:
+ that:
+ - vm_vmotion is changed
+
+
+- name: Add ESXi Hosts to a cluster
+ vmware_host:
+ datacenter_name: '{{ dc1 }}'
+ cluster_name: '{{ ccr1 }}'
+ esxi_hostname: '{{ item }}'
+ esxi_username: '{{ esxi_user }}'
+ esxi_password: '{{ esxi_password }}'
+ state: present
+ with_items: "{{ esxi_hosts }}"
+
+- name: Disable the Maintenance Mode
+ vmware_maintenancemode:
+ esxi_hostname: '{{ item }}'
+ state: absent
+ with_items: "{{ esxi_hosts }}"
+
+- name: Perform vMotion of virtual machine to resource_pool
+ vmware_vmotion:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ vm_name: test_vm1
+ destination_host: '{{ esxi1 }}'
+ destination_resourcepool: DC0_C0_RP1
+ register: vm_vmotion_to_rp
+
+- name: assert that changes were made
+ assert:
+ that:
+ - vm_vmotion_to_rp is changed
+
+- name: Perform storage vMotion of virtual machine
+ vmware_vmotion:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ validate_certs: false
+ vm_name: test_vm1
+ destination_host: '{{ esxi2 }}'
+ destination_datastore: '{{ rw_datastore }}'
+ register: vm_vmotion_to_datastore
+
+- name: assert that changes were made
+ assert:
+ that:
+ - vm_vmotion_to_datastore is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/aliases
new file mode 100644
index 00000000..b3bf7b22
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/aliases
@@ -0,0 +1,4 @@
+cloud/vcenter
+unsupported
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/tasks/main.yml
new file mode 100644
index 00000000..4d6f8399
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vsan_health_info/tasks/main.yml
@@ -0,0 +1,20 @@
+# Test code for the vmware_vsan_health_info module.
+# Copyright: (c) 2019, OVH SAS
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Gather health info from a vSAN's cluster
+ vmware_vsan_health_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ cluster_name: "{{ ccr1 }}"
+ validate_certs: false
+ fetch_from_cache: false
+ register: info
+- debug: var=info
+- assert:
+ that:
+ - info.vsan_health_info is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/tasks/main.yml
new file mode 100644
index 00000000..a97f4e0f
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vspan_session/tasks/main.yml
@@ -0,0 +1,102 @@
+# Test code for the vmware_vspan_session module.
+# Copyright: (c) 2018, Peter Gyorgy <gyorgy.peter@edu.bme.hu>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+
+- name: add distributed vSwitch
+ vmware_dvswitch:
+ validate_certs: false
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter_name: "{{ dc1 }}"
+ state: present
+ switch_name: dvswitch_0001
+ mtu: 9000
+ uplink_quantity: 2
+ discovery_proto: lldp
+ discovery_operation: both
+ register: dvs_result_0001
+- debug: var=dvs_result_0001
+- name: ensure distributed vswitch is present
+ assert:
+ that:
+ - "{{ dvs_result_0001.changed == true }}"
+
+- name: Create vlan portgroup with all security and port policies
+ vmware_dvs_portgroup:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ portgroup_name: vlan-123-portrgoup
+ switch_name: dvswitch_0001
+ vlan_id: 123
+ num_ports: 120
+ port_binding: 'static'
+ port_allocation: 'fixed'
+ state: present
+ network_policy:
+ inherited: false
+ promiscuous: true
+ forged_transmits: true
+ mac_changes: true
+ port_policy:
+ block_override: true
+ ipfix_override: true
+ live_port_move: true
+ network_rp_override: true
+ port_config_reset_at_disconnect: true
+ security_override: true
+ shaping_override: true
+ traffic_filter_override: true
+ uplink_teaming_override: true
+ vendor_config_override: true
+ vlan_override: true
+ register: portgroup_create_result
+
+- name: ensure portgroup was created
+ assert:
+ that:
+ - portgroup_create_result.changed
+
+- name: create a session.
+ vmware_vspan_session:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch: dvswitch_0001
+ name: "session_0001"
+ state: "present"
+ enabled: true
+ description: "basic_description"
+ source_port_transmitted: 13
+ source_port_received: 13
+ destination_port: 12
+ register: vspan_session_create_result
+- debug: var=vspan_session_create_result
+- name: ensure session was created
+ assert:
+ that:
+ - vspan_session_create_result.changed
+
+- name: delete a session.
+ vmware_vspan_session:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ validate_certs: false
+ switch: dvswitch_0001
+ name: "session_0001"
+ state: "absent"
+ register: vspan_session_delete_result
+- name: ensure session was deleted
+ assert:
+ that:
+ - vspan_session_delete_result.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/aliases
new file mode 100644
index 00000000..d1d14d22
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_2esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/main.yml
new file mode 100644
index 00000000..b7088437
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/main.yml
@@ -0,0 +1,278 @@
+# Test code for the vmware_vswitch module.
+# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Run tests and clean up
+ block:
+ - import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+ - name: Ensure the vswitch is not already here
+ include_tasks: teardown.yml
+
+ - name: Add a nic to a switch
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ nics: vmnic1
+ state: present
+ register: add_nic_run
+ - debug: var=add_nic_run
+ - assert:
+ that:
+ - add_nic_run.changed == true
+
+ - name: Add a nic to a switch again
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ nics: vmnic1
+ state: present
+ register: add_nic_again_run
+ - assert:
+ that:
+ - add_nic_again_run.changed == false
+
+ - name: Remove a nic from a switch
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ state: present
+ register: remove_nic_run
+ - debug: var=remove_nic_run
+ - assert:
+ that:
+ - remove_nic_run.changed == true
+
+ - name: Remove a nic from a switch again
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ state: present
+ register: remove_nic_again_run
+ - debug: var=remove_nic_run
+ - assert:
+ that:
+ - remove_nic_again_run.changed == false
+
+ - name: Remove a switch
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ state: absent
+ register: remove_nic_run
+ - assert:
+ that:
+ - remove_nic_run is changed
+
+ - name: Remove a switch again
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ state: absent
+ register: remove_nic_again_run
+ - assert:
+ that:
+ - not (remove_nic_again_run is changed)
+
+ - name: Add vswitch to a specific host system
+ vmware_vswitch:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ switch: vmswitch_0002
+ nics: vmnic1
+ esxi_hostname: '{{ esxi2 }}'
+ register: add_vswitch_with_host_system
+ - debug: var=add_vswitch_with_host_system
+ - assert:
+ that:
+ - add_vswitch_with_host_system is changed
+
+ - name: Add a vSwitch with a network policy
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ nics:
+ - vmnic1
+ - vmnic2
+ state: present
+ security:
+ forged_transmits: true
+ mac_changes: true
+ traffic_shaping:
+ enabled: true
+ average_bandwidth: 100000
+ peak_bandwidth: 100000
+ burst_size: 102400
+ teaming:
+ active_adapters: vmnic1
+ standby_adapters: vmnic2
+ register: add_vswitch_netpol_run
+ - debug: var=add_vswitch_netpol_run
+ - assert:
+ that:
+ - add_vswitch_netpol_run.changed == true
+
+ - name: Add a vSwitch with a network policy again (idempotency check)
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ nics:
+ - vmnic1
+ - vmnic2
+ state: present
+ security:
+ forged_transmits: true
+ mac_changes: true
+ traffic_shaping:
+ enabled: true
+ average_bandwidth: 100000
+ peak_bandwidth: 100000
+ burst_size: 102400
+ teaming:
+ active_adapters: vmnic1
+ standby_adapters: vmnic2
+ register: add_vswitch_netpol_again_run
+ - assert:
+ that:
+ - add_vswitch_netpol_again_run.changed == false
+
+ - name: Update a vSwitch network policy
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ nics:
+ - vmnic1
+ - vmnic2
+ state: present
+ security:
+ forged_transmits: false
+ mac_changes: true
+ traffic_shaping:
+ enabled: false
+ teaming:
+ active_adapters:
+ - vmnic1
+ - vmnic2
+ standby_adapters: []
+ register: update_vswitch_netpol_run
+ - debug: var=update_vswitch_netpol_run
+ - assert:
+ that:
+ - update_vswitch_netpol_run.changed == true
+
+ - name: Update a vSwitch network policy again (idempotency check)
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ validate_certs: false
+ switch: vmswitch_0001
+ nics:
+ - vmnic1
+ - vmnic2
+ state: present
+ security:
+ forged_transmits: false
+ mac_changes: true
+ traffic_shaping:
+ enabled: false
+ teaming:
+ active_adapters:
+ - vmnic1
+ - vmnic2
+ standby_adapters: []
+ register: update_vswitch_netpol_again_run
+ - assert:
+ that:
+ - update_vswitch_netpol_again_run.changed == false
+
+ always:
+ - include_tasks: teardown.yml
+
+ - name: Create Switch with special characters
+ vmware_vswitch:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ switch: 'Switch\%'
+ state: present
+ register: create_switch_with_special_characters_result
+
+ - assert:
+ that:
+ - create_switch_with_special_characters_result.changed is sameas true
+
+ - name: Create Switch with special characters(idempotency check)
+ vmware_vswitch:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ switch: 'Switch\%'
+ state: present
+ register: create_switch_with_special_characters_idempotency_check_result
+
+ - assert:
+ that:
+ - create_switch_with_special_characters_idempotency_check_result.changed is sameas false
+
+ - name: Delete Switch with special characters
+ vmware_vswitch:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ switch: 'Switch\%'
+ state: absent
+ register: delete_switch_with_special_characters_result
+
+ - assert:
+ that:
+ - delete_switch_with_special_characters_result.changed is sameas true
+
+ - name: Delete Switch with special characters(idempotency check)
+ vmware_vswitch:
+ hostname: "{{ esxi1 }}"
+ username: "{{ esxi_user }}"
+ password: "{{ esxi_password }}"
+ validate_certs: false
+ switch: 'Switch\%'
+ state: absent
+ register: delete_switch_with_special_characters_idempotency_check_result
+
+ - assert:
+ that:
+ - delete_switch_with_special_characters_idempotency_check_result.changed is sameas false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/teardown.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/teardown.yml
new file mode 100644
index 00000000..fb590664
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch/tasks/teardown.yml
@@ -0,0 +1,16 @@
+- name: Remove the vSwitches (ESXi1)
+ vmware_vswitch:
+ hostname: '{{ esxi1 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ switch_name: vmswitch_0001
+ state: absent
+
+- name: Remove the vSwitches (ESXi2)
+ vmware_vswitch:
+ hostname: '{{ esxi2 }}'
+ username: '{{ esxi_user }}'
+ password: '{{ esxi_password }}'
+ switch_name: vmswitch_0002
+ state: absent
+ when: esxi2 is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/aliases
new file mode 100644
index 00000000..07e8732a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/tasks/main.yml
new file mode 100644
index 00000000..ca281aab
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vswitch_info/tasks/main.yml
@@ -0,0 +1,60 @@
+# Test code for the vmware_vswitch_info module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather vswitch info about all hosts in given cluster
+ vmware_vswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: switch_info
+
+- debug: var=switch_info
+
+- assert:
+ that:
+ - switch_info.hosts_vswitch_info is defined
+
+- name: Gather vswitch info about all hosts in given cluster in check mode
+ vmware_vswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: switch_info_check_mode
+ check_mode: true
+
+- debug: var=switch_info_check_mode
+
+- assert:
+ that:
+ - switch_info_check_mode.hosts_vswitch_info is defined
+
+- name: Gather vswitch policies info about all hosts in given cluster
+ vmware_vswitch_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ policies: true
+ register: switch_policies_info
+
+- debug: var=switch_policies_info
+
+- assert:
+ that:
+ - switch_policies_info.hosts_vswitch_info is defined
+ - switch_policies_info.hosts_vswitch_info[esxi1] is defined
+ - switch_policies_info.hosts_vswitch_info[esxi1]['vSwitch0'] is defined
+ - switch_policies_info.hosts_vswitch_info[esxi1]['vSwitch0'].security is defined
+ - switch_policies_info.hosts_vswitch_info[esxi1]['vSwitch0'].ts is defined
+ - switch_policies_info.hosts_vswitch_info[esxi1]['vSwitch0'].lb is defined
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vsphere_file/aliases b/ansible_collections/community/vmware/tests/integration/targets/vsphere_file/aliases
new file mode 100644
index 00000000..ad7ccf7a
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vsphere_file/aliases
@@ -0,0 +1 @@
+unsupported
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vsphere_file/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vsphere_file/tasks/main.yml
new file mode 100644
index 00000000..d3b0284b
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vsphere_file/tasks/main.yml
@@ -0,0 +1,369 @@
+- set_fact:
+ file: '/ansible_test_file.txt'
+ directory: '/ansible_test_directory/'
+ vsphere_connection: &vsphere_conn
+ host: '{{ vcenter_ipaddress }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: '{{ vcenter_datacenter }}'
+ datastore: '{{ vcenter_datastore }}'
+ validate_certs: false
+
+- set_fact:
+ vsphere_conection_file: &vsphere_conn_file
+ <<: *vsphere_conn
+ path: '{{ file }}'
+ vsphere_conection_dir: &vsphere_conn_dir
+ <<: *vsphere_conn
+ path: '{{ directory }}'
+
+# Clean up environment
+- name: Delete file
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: absent
+ ignore_errors: true
+
+- name: Delete directory
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ state: absent
+ ignore_errors: true
+
+# Test file operations
+- name: Test file at start (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: file
+ check_mode: true
+ ignore_errors: true
+ register: cm_test_file_start
+
+- name: Verify cm_test_file_start
+ assert:
+ that:
+ - cm_test_file_start is failed
+ - cm_test_file_start.state == 'absent'
+ - cm_test_file_start.status == 404
+
+- name: Test file at start (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: file
+ register: nm_test_file_start
+ ignore_errors: true
+
+- name: Verify nm_test_file_start
+ assert:
+ that:
+ - nm_test_file_start is failed
+ - nm_test_file_start.state == 'absent'
+ - nm_test_file_start.status == 404
+
+- name: Touch file (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: touch
+ check_mode: true
+ register: cm_touch_file
+
+- name: Verify cm_touch_file
+ assert:
+ that:
+ - cm_touch_file is success
+ - cm_touch_file is changed
+ - cm_touch_file.reason == 'Created'
+ - cm_touch_file.size == 0
+ #- cm_touch_file.state == 'file' # FIXME
+ - cm_touch_file.status == 201
+
+- name: Touch file (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: touch
+ register: nm_touch_file
+
+- name: Verify nm_touch_file
+ assert:
+ that:
+ - nm_touch_file is success
+ - nm_touch_file is changed
+ - nm_touch_file.reason == 'Created'
+ - nm_touch_file.size == 0
+ #- nm_touch_file.state == 'file' # FIXME
+ - nm_touch_file.status == 201
+
+- name: Test file after touch (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: file
+ check_mode: true
+ register: cm_test_file_touch
+
+- name: Verify cm_test_file_touch
+ assert:
+ that:
+ - cm_test_file_touch is success
+ - cm_test_file_touch is not changed
+ - cm_test_file_touch.size == 0
+ #- cm_test_file_touch.state == 'file' # FIXME
+ - cm_test_file_touch.status == 200
+
+- name: Test file after touch (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: file
+ register: nm_test_file_touch
+
+- name: Verify nm_test_file_touch
+ assert:
+ that:
+ - nm_test_file_touch is success
+ - nm_test_file_touch is not changed
+ - nm_test_file_touch.size == 0
+ #- nm_test_file_touch.state == 'file' # FIXME
+ - nm_test_file_touch.status == 200
+
+- name: Delete file (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: absent
+ check_mode: true
+ register: cm_delete_file
+
+- name: Verify cm_delete_file
+ assert:
+ that:
+ - cm_delete_file is success
+ - cm_delete_file is changed
+ - cm_delete_file.reason == 'No Content'
+ - cm_delete_file.size == None
+ - cm_delete_file.state == 'absent'
+ - cm_delete_file.status == 204
+
+- name: Delete file (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: absent
+ register: nm_delete_file
+
+- name: Verify nm_delete_file
+ assert:
+ that:
+ - nm_delete_file is success
+ - nm_delete_file is changed
+ - nm_delete_file.reason == 'No Content'
+ - nm_delete_file.size == None
+ - nm_delete_file.state == 'absent'
+ - nm_delete_file.status == 204
+
+- name: Test file after delete (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: file
+ check_mode: true
+ ignore_errors: true
+ register: cm_test_file_delete
+
+- name: Verify cm_test_file_delete
+ assert:
+ that:
+ - cm_test_file_delete is failed
+ - cm_test_file_delete.size == None
+ - cm_test_file_delete.state == 'absent'
+ - cm_test_file_delete.status == 404
+
+- name: Test file after delete (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_file
+ state: file
+ ignore_errors: true
+ register: nm_test_file_delete
+
+- name: Verify nm_test_file_delete
+ assert:
+ that:
+ - nm_test_file_delete is failed
+ - nm_test_file_delete.size == None
+ - nm_test_file_delete.state == 'absent'
+ - nm_test_file_delete.status == 404
+
+# Test directory operations
+- name: Test directory at start (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ state: file
+ check_mode: true
+ ignore_errors: true
+ register: cm_test_dir_start
+
+- name: Verify cm_test_dir_start
+ assert:
+ that:
+ - cm_test_dir_start is failed
+ - cm_test_dir_start.size == None
+ - cm_test_dir_start.state == 'absent'
+ - cm_test_dir_start.status == 404
+
+- name: Test directory at start (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ state: file
+ ignore_errors: true
+ register: nm_test_dir_start
+
+# NOTE: Deleting directories is not implemented.
+- name: Verify nm_test_dir_start
+ assert:
+ that:
+ - nm_test_dir_start is failed
+ - nm_test_dir_start.size == None
+ - nm_test_dir_start.state == 'absent'
+ - nm_test_dir_start.status == 404
+
+- name: Create directory (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: directory
+ check_mode: true
+ register: cm_create_dir
+
+- name: Verify cm_create_dir
+ assert:
+ that:
+ - cm_create_dir is success
+ - cm_create_dir is changed
+ - cm_create_dir.reason == 'Created'
+ - cm_create_dir.size == None
+ #- cm_create_dir.state == 'directory' # FIXME
+ - cm_create_dir.status == 201
+
+- name: Create directory (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: directory
+ register: nm_create_dir
+
+- name: Verify nm_create_dir
+ assert:
+ that:
+ - nm_create_dir is success
+ - nm_create_dir is changed
+ - nm_create_dir.reason == 'Created'
+ - nm_create_dir.size == None
+ #- nm_create_dir.state == 'directory' # FIXME
+ - nm_create_dir.status == 201
+
+- name: Test directory after create (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: file
+ check_mode: true
+ register: cm_test_dir_create
+
+- name: Verify cm_test_dir_create
+ assert:
+ that:
+ - cm_test_dir_create is success
+ - cm_test_dir_create is not changed
+ #- cm_test_dir_create.size == 0
+ #- cm_test_dir_create.state == 'file' # FIXME
+ - cm_test_dir_create.status == 200
+
+- name: Test directory after create (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: file
+ register: nm_test_dir_create
+
+- name: Verify nm_test_dir_create
+ assert:
+ that:
+ - nm_test_dir_create is success
+ - nm_test_dir_create is not changed
+ #- nm_test_dir_create.size == 0
+ #- nm_test_dir_create.state == 'file' # FIXME
+ - nm_test_dir_create.status == 200
+
+- name: Delete directory (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ state: absent
+ check_mode: true
+ ignore_errors: true
+ register: cm_delete_dir
+
+- name: Verify cm_delete_dir
+ assert:
+ that:
+ - cm_delete_dir is success
+ - cm_delete_dir is changed
+ - cm_delete_dir.reason == 'No Content'
+ - cm_delete_dir.size == None
+ - cm_delete_dir.state == 'absent'
+ - cm_delete_dir.status == 204
+
+- name: Delete directory (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: absent
+ ignore_errors: true
+ register: nm_delete_dir
+
+# NOTE: Deleting directories is not implemented
+- name: Verify nm_delete_dir
+ assert:
+ that:
+ - nm_delete_dir is failed # FIXME
+ #- nm_delete_dir is success
+ #- nm_delete_dir is changed
+ - nm_delete_dir.reason == 'Method Not Allowed' # FIXME
+ #- cm_delete_dir.reason == 'No Content'
+ #- nm_delete_dir.size == None
+ #- cm_delete_dir.state == 'absent'
+ - nm_delete_dir.status == 405 # FIXME
+ #- cm_delete_dir.status == 204
+
+- name: Test directory after delete (check_mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: file
+ check_mode: true
+ ignore_errors: true
+ register: cm_test_dir_delete
+
+- name: Verify cm_test_dir_delete
+ assert:
+ that:
+ - cm_test_dir_delete is success # FIXME
+ - cm_test_dir_delete is not changed #FIXME
+ #- cm_test_dir_delete is failed
+ #- cm_test_dir_delete.size == None
+ #- cm_test_dir_delete.state == 'file'
+ - cm_test_dir_delete.status == 200 # FIXME
+ #- nm_test_dir_delete.status == 404
+
+- name: Test directory after delete (normal mode)
+ vsphere_file:
+ <<: *vsphere_conn_dir
+ path: '{{ directory }}'
+ state: file
+ ignore_errors: true
+ register: nm_test_dir_delete
+
+- name: Verify nm_test_dir_delete
+ assert:
+ that:
+ - nm_test_dir_delete is success # FIXME
+ - nm_test_dir_delete is not changed #FIXME
+ #- nm_test_dir_delete is failed
+ #- nm_test_dir_delete.size == None
+ #- nm_test_dir_delete.state == 'file'
+ - nm_test_dir_delete.status == 200 # FIXME
+ #- nm_test_dir_delete.status == 404