diff --git a/lib/ansible/modules/cloud/vmware/vcenter_folder.py b/lib/ansible/modules/cloud/vmware/vcenter_folder.py index 1a251b0af46..9f1fb757b6a 100644 --- a/lib/ansible/modules/cloud/vmware/vcenter_folder.py +++ b/lib/ansible/modules/cloud/vmware/vcenter_folder.py @@ -79,6 +79,7 @@ EXAMPLES = r''' folder_type: vm state: present register: vm_folder_creation_result + delegate_to: localhost - name: Create a datastore folder on given datacenter vcenter_folder: @@ -90,6 +91,7 @@ EXAMPLES = r''' folder_type: datastore state: present register: datastore_folder_creation_result + delegate_to: localhost - name: Create a sub folder under VM folder on given datacenter vcenter_folder: @@ -101,6 +103,7 @@ EXAMPLES = r''' parent_folder: vm_folder state: present register: sub_folder_creation_result + delegate_to: localhost - name: Delete a VM folder on given datacenter vcenter_folder: @@ -112,6 +115,7 @@ EXAMPLES = r''' folder_type: vm state: absent register: vm_folder_deletion_result + delegate_to: localhost ''' RETURN = r''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_about_facts.py b/lib/ansible/modules/cloud/vmware/vmware_about_facts.py index 7896a35d803..b9e807e592e 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_about_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_about_facts.py @@ -44,7 +44,7 @@ EXAMPLES = r''' vmware_about_facts: hostname: '{{ esxi_hostname }}' username: '{{ esxi_username }}' - password: '{{ esxu_password }}' + password: '{{ esxi_password }}' delegate_to: localhost register: esxi_about_info ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_category_facts.py b/lib/ansible/modules/cloud/vmware/vmware_category_facts.py index 8dcd8514121..366d2b061f9 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_category_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_category_facts.py @@ -39,17 +39,17 @@ extends_documentation_fragment: vmware_rest_client.documentation EXAMPLES = r''' - name: Gather facts about tag categories vmware_category_facts: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" delegate_to: localhost register: all_tag_category_facts - name: Gather category id from given tag category vmware_category_facts: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" delegate_to: localhost register: tag_category_results diff --git a/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py b/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py index 3e2f6f95fbb..b838bb7b5ee 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py +++ b/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py @@ -51,23 +51,21 @@ extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' -# save the ESXi configuration locally by authenticating directly against the ESXi host -- name: ESXI backup test +- name: Save the ESXi configuration locally by authenticating directly against the ESXi host vmware_cfg_backup: - hostname: esxi_hostname - username: user - password: pass + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' state: saved dest: /tmp/ delegate_to: localhost -# save the ESXi configuration locally by authenticating against the vCenter and selecting the ESXi host -- name: ESXI backup test +- name: Save the ESXi configuration locally by authenticating against the vCenter and selecting the ESXi host vmware_cfg_backup: - hostname: vCenter - esxi_hostname: esxi_hostname - username: user - password: pass + hostname: '{{ vcenter_hostname }}' + esxi_hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' state: saved dest: /tmp/ delegate_to: localhost diff --git a/lib/ansible/modules/cloud/vmware/vmware_cluster.py b/lib/ansible/modules/cloud/vmware/vmware_cluster.py index 39a52add7a9..d0d2315d05b 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_cluster.py +++ b/lib/ansible/modules/cloud/vmware/vmware_cluster.py @@ -58,9 +58,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Create Cluster vmware_cluster: - hostname: '{{ ansible_ssh_host }}' - username: root - password: vmware + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' datacenter_name: datacenter cluster_name: cluster enable_ha: yes diff --git a/lib/ansible/modules/cloud/vmware/vmware_cluster_facts.py b/lib/ansible/modules/cloud/vmware/vmware_cluster_facts.py index a73c0415d8b..f20d44ffc36 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_cluster_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_cluster_facts.py @@ -46,21 +46,20 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Gather cluster facts from given datacenter vmware_cluster_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' datacenter: ha-datacenter - validate_certs: False + validate_certs: no delegate_to: localhost register: cluster_facts - name: Gather facts from datacenter about specific cluster vmware_cluster_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' cluster_name: DC0_C0 - validate_certs: False delegate_to: localhost register: cluster_facts ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_datacenter.py b/lib/ansible/modules/cloud/vmware/vmware_datacenter.py index 83058dd3a00..f703bc9d08a 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_datacenter.py +++ b/lib/ansible/modules/cloud/vmware/vmware_datacenter.py @@ -45,19 +45,19 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Create Datacenter vmware_datacenter: - hostname: "{{ ansible_ssh_host }}" - username: root - password: vmware - datacenter_name: "datacenter" + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter_name: '{{ datacenter_name }}' state: present delegate_to: localhost - name: Delete Datacenter vmware_datacenter: - hostname: vcenter_hostname - username: root - password: pass - datacenter_name: DC2 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter_name: '{{ datacenter_name }}' state: absent delegate_to: localhost register: datacenter_delete_result diff --git a/lib/ansible/modules/cloud/vmware/vmware_datastore_cluster.py b/lib/ansible/modules/cloud/vmware/vmware_datastore_cluster.py index ece4343e22f..2004c0be676 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_datastore_cluster.py +++ b/lib/ansible/modules/cloud/vmware/vmware_datastore_cluster.py @@ -50,22 +50,22 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Create datastore cluster vmware_datastore_cluster: - hostname: vCenter - username: root - password: vmware - datacenter_name: "datacenter" - datastore_cluster_name: datacluster0 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter_name: '{{ datacenter_name }}' + datastore_cluster_name: '{{ datastore_cluster_name }}' state: present delegate_to: localhost - name: Delete datastore cluster vmware_datastore_cluster: - hostname: vCenter - username: root - password: vmware - datacenter_name: "datacenter" - datastore_cluster_name: datacluster0 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter_name: '{{ datacenter_name }}' + datastore_cluster_name: '{{ datastore_cluster_name }}' state: absent delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py b/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py index 79b6a0967a1..5f86f8723c1 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py @@ -52,22 +52,21 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Gather facts from standalone ESXi server having datacenter as 'ha-datacenter' vmware_datastore_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - datacenter: ha-datacenter + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter: '{{ datacenter_name }}' validate_certs: no delegate_to: localhost register: facts - name: Gather facts from datacenter about specific datastore vmware_datastore_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - datacenter: DC0 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter: '{{ datacenter_name }}' name: datastore1 - validate_certs: no delegate_to: localhost register: facts ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_datastore_maintenancemode.py b/lib/ansible/modules/cloud/vmware/vmware_datastore_maintenancemode.py index 27239372a5a..a86d9cb31e1 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_datastore_maintenancemode.py +++ b/lib/ansible/modules/cloud/vmware/vmware_datastore_maintenancemode.py @@ -58,37 +58,37 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Enter datastore into Maintenance Mode vmware_datastore_maintenancemode: - hostname: vc_host - username: vc_user - password: vc_pass - datastore: datastore1 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datastore: '{{ datastore_name }}' state: present delegate_to: localhost - name: Enter all datastores under cluster into Maintenance Mode vmware_datastore_maintenancemode: - hostname: vc_host - username: vc_user - password: vc_pass - cluster_name: DC0_C0 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + cluster_name: '{{ cluster_name }}' state: present delegate_to: localhost - name: Enter all datastores under datastore cluster into Maintenance Mode vmware_datastore_maintenancemode: - hostname: vc_host - username: vc_user - password: vc_pass - datastore_cluster: DSC_POD0 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datastore_cluster: '{{ datastore_cluster_name }}' state: present delegate_to: localhost - name: Exit datastore into Maintenance Mode vmware_datastore_maintenancemode: - hostname: vc_host - username: vc_user - password: vc_pass - datastore: datastore1 + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datastore: '{{ datastore_name }}' state: absent delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py index 827fbd23398..04892796136 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py +++ b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py @@ -107,9 +107,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - vmware_deploy_ovf: - hostname: esx.example.org - username: root - password: passw0rd + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' ovf: /path/to/ubuntu-16.04-amd64.ovf wait_for_ip_address: true delegate_to: localhost @@ -118,7 +118,7 @@ EXAMPLES = r''' RETURN = r''' instance: - description: metadata about the new virtualmachine + description: metadata about the new virtual machine returned: always type: dict sample: None diff --git a/lib/ansible/modules/cloud/vmware/vmware_dns_config.py b/lib/ansible/modules/cloud/vmware/vmware_dns_config.py index ce6f0219c61..8f1032887e2 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_dns_config.py +++ b/lib/ansible/modules/cloud/vmware/vmware_dns_config.py @@ -44,9 +44,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Configure ESXi hostname and DNS servers vmware_dns_config: - hostname: esxi_hostname - username: root - password: your_password + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' change_hostname_to: esx01 domainname: foo.org dns_servers: diff --git a/lib/ansible/modules/cloud/vmware/vmware_drs_rule_facts.py b/lib/ansible/modules/cloud/vmware/vmware_drs_rule_facts.py index cdc233d7d78..93ff211cf56 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_drs_rule_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_drs_rule_facts.py @@ -48,7 +48,7 @@ EXAMPLES = r''' hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - cluster_name: cluster_name + cluster_name: '{{ cluster_name }}' delegate_to: localhost register: cluster_drs_facts @@ -57,7 +57,7 @@ EXAMPLES = r''' hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - datacenter: datacenter_name + datacenter: '{{ datacenter_name }}' delegate_to: localhost register: datacenter_drs_facts ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_dvs_host.py b/lib/ansible/modules/cloud/vmware/vmware_dvs_host.py index 11e2508b091..aa482321e06 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_dvs_host.py +++ b/lib/ansible/modules/cloud/vmware/vmware_dvs_host.py @@ -55,10 +55,10 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Add Host to dVS vmware_dvs_host: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password - esxi_hostname: esxi_hostname_as_listed_in_vcenter + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + esxi_hostname: '{{ esxi_hostname }}' switch_name: dvSwitch vmnics: - vmnic0 diff --git a/lib/ansible/modules/cloud/vmware/vmware_dvs_portgroup.py b/lib/ansible/modules/cloud/vmware/vmware_dvs_portgroup.py index 06a9c2a8eda..17cc7be3c2f 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_dvs_portgroup.py +++ b/lib/ansible/modules/cloud/vmware/vmware_dvs_portgroup.py @@ -139,78 +139,74 @@ extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' - - name: Create vlan portgroup - connection: local - vmware_dvs_portgroup: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password - portgroup_name: vlan-123-portrgoup - switch_name: dvSwitch - vlan_id: 123 - num_ports: 120 - portgroup_type: earlyBinding - state: present - delegate_to: localhost - - - name: Create vlan trunk portgroup - connection: local - vmware_dvs_portgroup: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password - portgroup_name: vlan-trunk-portrgoup - switch_name: dvSwitch - vlan_id: 1-1000 - vlan_trunk: True - num_ports: 120 - portgroup_type: earlyBinding - state: present - delegate_to: localhost - - - name: Create no-vlan portgroup - connection: local - vmware_dvs_portgroup: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password - portgroup_name: no-vlan-portrgoup - switch_name: dvSwitch - vlan_id: 0 - num_ports: 120 - portgroup_type: earlyBinding - state: present - delegate_to: localhost - - - name: Create vlan portgroup with all security and port policies - connection: local - vmware_dvs_portgroup: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password - portgroup_name: vlan-123-portrgoup - switch_name: dvSwitch - vlan_id: 123 - num_ports: 120 - portgroup_type: earlyBinding - state: present - network_policy: - promiscuous: yes - forged_transmits: yes - mac_changes: yes - port_policy: - block_override: yes - ipfix_override: yes - live_port_move: yes - network_rp_override: yes - port_config_reset_at_disconnect: yes - security_override: yes - shaping_override: yes - traffic_filter_override: yes - uplink_teaming_override: yes - vendor_config_override: yes - vlan_override: yes - delegate_to: localhost +- name: Create vlan portgroup + vmware_dvs_portgroup: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + portgroup_name: vlan-123-portrgoup + switch_name: dvSwitch + vlan_id: 123 + num_ports: 120 + portgroup_type: earlyBinding + state: present + delegate_to: localhost + +- name: Create vlan trunk portgroup + vmware_dvs_portgroup: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + portgroup_name: vlan-trunk-portrgoup + switch_name: dvSwitch + vlan_id: 1-1000 + vlan_trunk: True + num_ports: 120 + portgroup_type: earlyBinding + state: present + delegate_to: localhost + +- name: Create no-vlan portgroup + vmware_dvs_portgroup: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + portgroup_name: no-vlan-portrgoup + switch_name: dvSwitch + vlan_id: 0 + num_ports: 120 + portgroup_type: earlyBinding + state: present + delegate_to: localhost + +- name: Create vlan portgroup with all security and port policies + vmware_dvs_portgroup: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + portgroup_name: vlan-123-portrgoup + switch_name: dvSwitch + vlan_id: 123 + num_ports: 120 + portgroup_type: earlyBinding + state: present + network_policy: + promiscuous: yes + forged_transmits: yes + mac_changes: yes + port_policy: + block_override: yes + ipfix_override: yes + live_port_move: yes + network_rp_override: yes + port_config_reset_at_disconnect: yes + security_override: yes + shaping_override: yes + traffic_filter_override: yes + uplink_teaming_override: yes + vendor_config_override: yes + vlan_override: yes + delegate_to: localhost ''' try: diff --git a/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py b/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py index 1f8f958800b..87f10c2659e 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py +++ b/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py @@ -76,9 +76,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Create dvswitch vmware_dvswitch: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' datacenter_name: datacenter switch_name: dvSwitch switch_version: 6.0.0 diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 43c6568b44b..55df58c467c 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -331,10 +331,10 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Create a virtual machine on given ESXi hostname vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no folder: /DC1/vm/ name: test_vm_0001 state: poweredon @@ -361,10 +361,10 @@ EXAMPLES = r''' - name: Create a virtual machine from a template vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no folder: /testvms name: testvm_2 state: poweredon @@ -402,10 +402,10 @@ EXAMPLES = r''' - name: Clone a virtual machine from Windows template and customize vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no datacenter: datacenter1 cluster: cluster name: testvm-2 @@ -435,8 +435,8 @@ EXAMPLES = r''' - name: Clone a virtual machine from Linux template and customize vmware_guest: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no datacenter: "{{ datacenter }}" @@ -462,10 +462,10 @@ EXAMPLES = r''' - name: Rename a virtual machine (requires the virtual machine's uuid) vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no uuid: "{{ vm_uuid }}" name: new_name state: present @@ -473,20 +473,20 @@ EXAMPLES = r''' - name: Remove a virtual machine by uuid vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no uuid: "{{ vm_uuid }}" state: absent delegate_to: localhost - name: Manipulate vApp properties vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no name: vm_name state: present vapp_properties: @@ -501,10 +501,10 @@ EXAMPLES = r''' - name: Set powerstate of a virtual machine to poweroff by using UUID vmware_guest: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - validate_certs: False + validate_certs: no uuid: "{{ vm_uuid }}" state: poweredoff delegate_to: localhost diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py b/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py index d1308b37ab5..78e1f958eea 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py @@ -78,9 +78,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Change virtual machine's boot order and related parameters vmware_guest_boot_manager: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" name: testvm boot_delay: 2000 enter_bios_setup: True diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attribute_defs.py b/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attribute_defs.py index 7b386df3f4f..d517081d68f 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attribute_defs.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attribute_defs.py @@ -52,7 +52,7 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Add VMWare Attribute Definition vmware_guest_custom_attribute_defs: - hostname: "{{ vcenter_server }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" state: present @@ -62,7 +62,7 @@ EXAMPLES = ''' - name: Remove VMWare Attribute Definition vmware_guest_custom_attribute_defs: - hostname: "{{ vcenter_server }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" state: absent diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attributes.py b/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attributes.py index 5ed67e7b7f0..9a5cd686171 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attributes.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_custom_attributes.py @@ -67,9 +67,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Add virtual machine custom attributes vmware_guest_custom_attributes: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" uuid: 421e4592-c069-924d-ce20-7e7533fab926 state: present attributes: @@ -80,9 +80,9 @@ EXAMPLES = ''' - name: Add multiple virtual machine custom attributes vmware_guest_custom_attributes: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" uuid: 421e4592-c069-924d-ce20-7e7533fab926 state: present attributes: @@ -95,9 +95,9 @@ EXAMPLES = ''' - name: Remove virtual machine Attribute vmware_guest_custom_attributes: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" uuid: 421e4592-c069-924d-ce20-7e7533fab926 state: absent attributes: diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_disk_facts.py b/lib/ansible/modules/cloud/vmware/vmware_guest_disk_facts.py index 851ee1e21d7..b61c4b22a8a 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_disk_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_disk_facts.py @@ -65,9 +65,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Gather disk facts from virtual machine using UUID vmware_guest_disk_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" datacenter: ha-datacenter validate_certs: no uuid: 421e4592-c069-924d-ce20-7e7533fab926 @@ -76,9 +76,9 @@ EXAMPLES = ''' - name: Gather disk facts from virtual machine using name vmware_guest_disk_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" datacenter: ha-datacenter validate_certs: no name: VM_225 @@ -126,7 +126,7 @@ class PyVmomiHelper(PyVmomi): def gather_disk_facts(self, vm_obj): """ - Function to gather facts about VM's disks + Gather facts about VM's disks Args: vm_obj: Managed object of virtual machine diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py b/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py index 0d48be5a009..12407be1829 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py @@ -69,9 +69,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Gather facts from standalone ESXi server having datacenter as 'ha-datacenter' vmware_guest_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" datacenter: ha-datacenter validate_certs: no uuid: 421e4592-c069-924d-ce20-7e7533fab926 diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py b/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py index 536dab25acb..7e6f0192958 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py @@ -107,14 +107,14 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Create directory inside a vm vmware_guest_file_operation: - hostname: myVSphere - username: myUsername - password: mySecret - datacenter: myDatacenter - validate_certs: True - vm_id: NameOfVM - vm_username: root - vm_password: superSecret + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + validate_certs: no + vm_id: "{{ guest_name }}" + vm_username: "{{ guest_username }}" + vm_password: "{{ guest_userpassword }}" directory: path: "/test" operation: create @@ -123,14 +123,13 @@ EXAMPLES = ''' - name: copy file to vm vmware_guest_file_operation: - hostname: myVSphere - username: myUsername - password: mySecret - datacenter: myDatacenter - validate_certs: True - vm_id: NameOfVM - vm_username: root - vm_password: superSecret + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + vm_id: "{{ guest_name }}" + vm_username: "{{ guest_username }}" + vm_password: "{{ guest_userpassword }}" copy: src: "files/test.zip" dest: "/root/test.zip" @@ -139,14 +138,13 @@ EXAMPLES = ''' - name: fetch file from vm vmware_guest_file_operation: - hostname: myVSphere - username: myUsername - password: mySecret - datacenter: myDatacenter - validate_certs: True - vm_id: NameOfVM - vm_username: root - vm_password: superSecret + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + vm_id: "{{ guest_name }}" + vm_username: "{{ guest_username }}" + vm_password: "{{ guest_userpassword }}" fetch: src: "/root/test.zip" dest: "files/test.zip" diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_find.py b/lib/ansible/modules/cloud/vmware/vmware_guest_find.py index 94ed61ead81..e2118e80dd8 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_find.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_find.py @@ -46,9 +46,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Find Guest's Folder using name vmware_guest_find: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" validate_certs: no name: testvm delegate_to: localhost @@ -56,10 +56,9 @@ EXAMPLES = r''' - name: Find Guest's Folder using UUID vmware_guest_find: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - validate_certs: no + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" uuid: 38c4c89c-b3d7-4ae6-ae4e-43c5118eae49 delegate_to: localhost register: vm_folder diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_move.py b/lib/ansible/modules/cloud/vmware/vmware_guest_move.py index 3c2b4a4d66c..22077c486ab 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_move.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_move.py @@ -68,30 +68,30 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Move Virtual Machine vmware_guest_move: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: datacenter - validate_certs: False + validate_certs: no name: testvm-1 - dest_folder: datacenter/vm/prodvms + dest_folder: /"{{ datacenter }}"/vm delegate_to: localhost - name: Get VM UUID vmware_guest_facts: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no datacenter: "{{ datacenter }}" - folder: "/{{datacenter}}/vm" + folder: /"{{datacenter}}"/vm name: "{{ vm_name }}" delegate_to: localhost register: vm_facts - name: Get UUID from previous task and pass it to this task vmware_guest_move: - hostname: "{{ vcenter_ip }}" + hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_powerstate.py b/lib/ansible/modules/cloud/vmware/vmware_guest_powerstate.py index 653adaaa872..3d927978a1a 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_powerstate.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_powerstate.py @@ -84,24 +84,23 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Set the state of a virtual machine to poweroff vmware_guest_powerstate: - hostname: 192.0.2.44 - username: administrator@vsphere.local - password: vmware + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" validate_certs: no - folder: /testvms - name: testvm_2 + folder: /"{{ datacenter_name }}"/vm/my_folder + name: "{{ guest_name }}" state: powered-off delegate_to: localhost register: deploy - name: Set the state of a virtual machine to poweroff at given scheduled time vmware_guest_powerstate: - hostname: 192.0.2.44 - username: administrator@vsphere.local - password: vmware - validate_certs: no - folder: /datacenter-1/vm/my_folder - name: testvm_2 + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + folder: /"{{ datacenter_name }}"/vm/my_folder + name: "{{ guest_name }}" state: powered-off scheduled_at: "09/01/2018 10:18" delegate_to: localhost @@ -109,11 +108,10 @@ EXAMPLES = r''' - name: Wait for the virtual machine to shutdown vmware_guest_powerstate: - hostname: 192.0.2.44 - username: administrator@vsphere.local - password: vmware - validate_certs: no - name: testvm_2 + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ guest_name }}" state: shutdown-guest state_change_timeout: 200 delegate_to: localhost diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py b/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py index b94777f41d0..98f840ebff8 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py @@ -123,12 +123,12 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Create a snapshot vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - datacenter: datacenter_name - folder: /myfolder - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: present snapshot_name: snap1 description: snap1_description @@ -136,72 +136,78 @@ EXAMPLES = ''' - name: Remove a snapshot vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - name: dummy_vm - datacenter: datacenter_name - folder: /myfolder + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: absent snapshot_name: snap1 delegate_to: localhost - name: Revert to a snapshot vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - datacenter: datacenter_name - folder: /myfolder - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: revert snapshot_name: snap1 delegate_to: localhost - name: Remove all snapshots of a VM vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - datacenter: datacenter_name - folder: /myfolder - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: remove_all delegate_to: localhost - name: Take snapshot of a VM using quiesce and memory flag on vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: present snapshot_name: dummy_vm_snap_0001 - quiesce: True - memory_dump: True + quiesce: yes + memory_dump: yes delegate_to: localhost - name: Remove a snapshot and snapshot subtree vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: absent - remove_children: True + remove_children: yes snapshot_name: snap1 delegate_to: localhost - name: Rename a snapshot vmware_guest_snapshot: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + folder: /"{{ datacenter_name }}"/vm/ + name: "{{ guest_name }}" state: present snapshot_name: current_snap_name new_snapshot_name: im_renamed - new_description: "renamed snapshot today" + new_description: "{{ new_snapshot_description }}" delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot_facts.py b/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot_facts.py index e02964a0cf8..f2bc92d47f3 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_snapshot_facts.py @@ -61,13 +61,13 @@ extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' - - name: Gather facts about the virtual machine in given vCenter + - name: Gather snapshot facts about the virtual machine in the given vCenter vmware_guest_snapshot_facts: - hostname: 192.168.1.209 - username: administrator@vsphere.local - password: vmware - datacenter: datacenter_name - name: dummy_vm + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + datacenter: "{{ datacenter_name }}" + name: "{{ guest_name }}" delegate_to: localhost register: snapshot_facts ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_tools_wait.py b/lib/ansible/modules/cloud/vmware/vmware_guest_tools_wait.py index 5c8421b3ddc..67c7d5d3def 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_tools_wait.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_tools_wait.py @@ -62,21 +62,21 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Wait for VMware tools to become available by UUID vmware_guest_facts: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" validate_certs: no datacenter: "{{ datacenter }}" - folder: "/{{datacenter}}/vm" + folder: /"{{datacenter}}"/vm name: "{{ vm_name }}" delegate_to: localhost register: vm_facts - name: Get UUID from previous task and pass it to this task vmware_guest_tools_wait: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" validate_certs: no uuid: "{{ vm_facts.instance.hw_product_uuid }}" delegate_to: localhost @@ -85,12 +85,12 @@ EXAMPLES = ''' - name: Wait for VMware tools to become available by name vmware_guest_tools_wait: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" validate_certs: no name: test-vm - folder: "/{{datacenter}}/vm" + folder: /"{{datacenter}}"/vm delegate_to: localhost register: facts ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_datastore.py b/lib/ansible/modules/cloud/vmware/vmware_host_datastore.py index 5bab5fab553..092d70c19d9 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_datastore.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_datastore.py @@ -83,8 +83,8 @@ EXAMPLES = r''' - name: Mount VMFS datastores to ESXi vmware_host_datastore: hostname: '{{ vcenter_hostname }}' - username: '{{ vcenter_user }}' - password: '{{ vcenter_pass }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' datacenter_name: '{{ datacenter }}' datastore_name: '{{ item.name }}' datastore_type: '{{ item.type }}' @@ -97,8 +97,8 @@ EXAMPLES = r''' - name: Mount NFS datastores to ESXi vmware_host_datastore: hostname: '{{ vcenter_hostname }}' - username: '{{ vcenter_user }}' - password: '{{ vcenter_pass }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' datacenter_name: '{{ datacenter }}' datastore_name: '{{ item.name }}' datastore_type: '{{ item.type }}' @@ -115,8 +115,8 @@ EXAMPLES = r''' - name: Remove/Umount Datastores from ESXi vmware_host_datastore: hostname: '{{ vcenter_hostname }}' - username: '{{ vcenter_user }}' - password: '{{ vcenter_pass }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' datacenter_name: '{{ datacenter }}' datastore_name: NasDS_vol01 esxi_hostname: '{{ inventory_hostname }}' diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_facts.py b/lib/ansible/modules/cloud/vmware/vmware_host_facts.py index 122ffe8f4e6..670643e9d67 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_facts.py @@ -36,19 +36,18 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Gather vmware host facts vmware_host_facts: - hostname: esxi_ip_or_hostname - username: username - password: password + hostname: "{{ esxi_server }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" register: host_facts delegate_to: localhost - name: Get VSAN Cluster UUID from host facts vmware_host_facts: - hostname: esxi_ip_or_hostname - username: username - password: password + hostname: "{{ esxi_server }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" register: host_facts - - set_fact: cluster_uuid: "{{ host_facts['ansible_facts']['vsan_cluster_uuid'] }}" ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_powerstate.py b/lib/ansible/modules/cloud/vmware/vmware_host_powerstate.py index fd393c5131e..514e74e88d7 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_powerstate.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_powerstate.py @@ -66,33 +66,33 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Set the state of a host system to reboot vmware_host_powerstate: - hostname: 192.0.2.44 - username: administrator@vsphere.local - password: vmware + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' validate_certs: no - esxi_hostname: esxi01 + esxi_hostname: '{{ esxi_hostname }}' state: reboot-host delegate_to: localhost register: reboot_host - name: Set the state of a host system to power down to standby vmware_host_powerstate: - hostname: 192.0.2.44 - username: administrator@vsphere.local - password: vmware + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' validate_certs: no - esxi_hostname: power-down-to-standby + esxi_hostname: '{{ esxi_hostname }}' state: power-down-to-standby delegate_to: localhost register: power_down - name: Set the state of all host systems from cluster to reboot vmware_host_powerstate: - hostname: 192.0.2.44 - username: administrator@vsphere.local - password: vmware + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' validate_certs: no - cluster_name: DC0_C0 + cluster_name: '{{ cluster_name }}' state: reboot-host delegate_to: localhost register: reboot_host diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_service_manager.py b/lib/ansible/modules/cloud/vmware/vmware_host_service_manager.py index 18cc065d0fd..afe7ab36460 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_service_manager.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_service_manager.py @@ -68,7 +68,7 @@ EXAMPLES = r''' hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - cluster_name: cluster_name + cluster_name: '{{ cluster_name }}' service_name: ntpd state: present delegate_to: localhost diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_vmnic_facts.py b/lib/ansible/modules/cloud/vmware/vmware_host_vmnic_facts.py index 49d0317a40a..1dcd15f6668 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_vmnic_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_vmnic_facts.py @@ -51,7 +51,7 @@ EXAMPLES = r''' hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - cluster_name: cluster_name + cluster_name: '{{ cluster_name }}' delegate_to: localhost register: cluster_host_vmnics diff --git a/lib/ansible/modules/cloud/vmware/vmware_local_role_manager.py b/lib/ansible/modules/cloud/vmware/vmware_local_role_manager.py index 66cfa081373..e03407dacad 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_local_role_manager.py +++ b/lib/ansible/modules/cloud/vmware/vmware_local_role_manager.py @@ -58,30 +58,30 @@ EXAMPLES = ''' # Example vmware_local_role_manager command from Ansible Playbooks - name: Add local role to ESXi vmware_local_role_manager: - hostname: esxi_hostname - username: root - password: vmware - local_role_name: vmware_qa - state: present + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' + local_role_name: vmware_qa + state: present delegate_to: localhost - name: Add local role with privileges to ESXi vmware_local_role_manager: - hostname: esxi_hostname - username: root - password: vmware - local_role_name: vmware_qa - local_privilege_ids: [ 'Folder.Create', 'Folder.Delete'] - state: present + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' + local_role_name: vmware_qa + local_privilege_ids: [ 'Folder.Create', 'Folder.Delete'] + state: present delegate_to: localhost - name: Remove local role from ESXi vmware_local_role_manager: - hostname: esxi_hostname - username: root - password: vmware - local_role_name: vmware_qa - state: absent + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' + local_role_name: vmware_qa + state: absent delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_local_user_facts.py b/lib/ansible/modules/cloud/vmware/vmware_local_user_facts.py index 4cc5eb5caa7..a33cb4d2dab 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_local_user_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_local_user_facts.py @@ -36,9 +36,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Gather facts about all Users on given ESXi host system vmware_local_user_facts: - hostname: esxi_hostname - username: root - password: vmware + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' delegate_to: localhost register: all_user_facts ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_maintenancemode.py b/lib/ansible/modules/cloud/vmware/vmware_maintenancemode.py index f0929ca3c54..71a36e895bb 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_maintenancemode.py +++ b/lib/ansible/modules/cloud/vmware/vmware_maintenancemode.py @@ -70,10 +70,10 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Enter VSAN-Compliant Maintenance Mode vmware_maintenancemode: - hostname: vc_host - username: vc_user - password: vc_pass - esxi_hostname: esxi.host.example + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + esxi_hostname: "{{ esxi_hostname }}" vsan: ensureObjectAccessibility evacuate: yes timeout: 3600 diff --git a/lib/ansible/modules/cloud/vmware/vmware_migrate_vmk.py b/lib/ansible/modules/cloud/vmware/vmware_migrate_vmk.py index b6bac3aa846..87f4cd4f365 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_migrate_vmk.py +++ b/lib/ansible/modules/cloud/vmware/vmware_migrate_vmk.py @@ -57,10 +57,10 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Migrate Management vmk vmware_migrate_vmk: - hostname: vcsa_host - username: vcsa_user - password: vcsa_pass - esxi_hostname: esxi_hostname + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + esxi_hostname: "{{ esxi_hostname }}" device: vmk1 current_switch_name: temp_vswitch current_portgroup_name: esx-mgmt diff --git a/lib/ansible/modules/cloud/vmware/vmware_portgroup.py b/lib/ansible/modules/cloud/vmware/vmware_portgroup.py index c6cf070756d..ff9afd5ec00 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_portgroup.py +++ b/lib/ansible/modules/cloud/vmware/vmware_portgroup.py @@ -104,66 +104,66 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Add Management Network VM Portgroup vmware_portgroup: - hostname: esxi_hostname - username: esxi_username - password: esxi_password - switch_name: vswitch_name - portgroup_name: portgroup_name - vlan_id: vlan_id + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" + switch_name: "{{ vswitch_name }}" + portgroup_name: "{{ portgroup_name }}" + vlan_id: "{{ vlan_id }}" delegate_to: localhost - name: Add Portgroup with Promiscuous Mode Enabled vmware_portgroup: - hostname: esxi_hostname - username: esxi_username - password: esxi_password - switch_name: vswitch_name - portgroup_name: portgroup_name + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" + switch_name: "{{ vswitch_name }}" + portgroup_name: "{{ portgroup_name }}" network_policy: promiscuous_mode: True delegate_to: localhost - name: Add Management Network VM Portgroup to specific hosts vmware_portgroup: - hostname: vCenter_hostname - username: esxi_username - password: esxi_password + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" hosts: [esxi_hostname_one] - switch_name: vswitch_name - portgroup_name: portgroup_name - vlan_id: vlan_id + switch_name: "{{ vswitch_name }}" + portgroup_name: "{{ portgroup_name }}" + vlan_id: "{{ vlan_id }}" delegate_to: localhost - name: Add Management Network VM Portgroup to all hosts in a cluster vmware_portgroup: - hostname: vCenter_hostname - username: esxi_username - password: esxi_password - cluster_name: rh_engineering - switch_name: vswitch_name - portgroup_name: portgroup_name - vlan_id: vlan_id + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + cluster_name: "{{ cluster_name }}" + switch_name: "{{ vswitch_name }}" + portgroup_name: "{{ portgroup_name }}" + vlan_id: "{{ vlan_id }}" delegate_to: localhost - name: Remove Management Network VM Portgroup to all hosts in a cluster vmware_portgroup: - hostname: vCenter_hostname - username: esxi_username - password: esxi_password - cluster_name: rh_engineering - switch_name: vswitch_name - portgroup_name: portgroup_name - vlan_id: vlan_id + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + cluster_name: "{{ cluster_name }}" + switch_name: "{{ vswitch_name }}" + portgroup_name: "{{ portgroup_name }}" + vlan_id: "{{ vlan_id }}" state: absent delegate_to: localhost - name: Add Portgroup with teaming policy vmware_portgroup: - hostname: esxi_hostname - username: esxi_username - password: esxi_password - switch_name: vswitch_name - portgroup_name: portgroup_name + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" + switch_name: "{{ vswitch_name }}" + portgroup_name: "{{ portgroup_name }}" teaming_policy: load_balance_policy: 'failover_explicit' inbound_policy: True diff --git a/lib/ansible/modules/cloud/vmware/vmware_portgroup_facts.py b/lib/ansible/modules/cloud/vmware/vmware_portgroup_facts.py index b7cb6f9ce90..8f973e653d1 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_portgroup_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_portgroup_facts.py @@ -46,7 +46,7 @@ EXAMPLES = r''' hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - cluster_name: cluster_name + cluster_name: '{{ cluster_name }}' delegate_to: localhost - name: Gather portgroup facts about ESXi Host system diff --git a/lib/ansible/modules/cloud/vmware/vmware_resource_pool.py b/lib/ansible/modules/cloud/vmware/vmware_resource_pool.py index d80f7010467..95da91893c1 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_resource_pool.py +++ b/lib/ansible/modules/cloud/vmware/vmware_resource_pool.py @@ -95,25 +95,24 @@ extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' -# Create a resource pool - - name: Add resource pool to vCenter - vmware_resource_pool: - hostname: vcsa_host - username: vcsa_user - password: vcsa_pass - datacenter: datacenter - cluster: cluster - resource_pool: resource_pool - 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 - delegate_to: localhost +- name: Add resource pool to vCenter + vmware_resource_pool: + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + datacenter: '{{ datacenter_name }}' + cluster: '{{ cluster_name }}' + resource_pool: '{{ resource_pool_name }}' + mem_shares: normal + mem_limit: -1 + mem_reservation: 0 + mem_expandable_reservations: yes + cpu_shares: normal + cpu_limit: -1 + cpu_reservation: 0 + cpu_expandable_reservations: yes + state: present + delegate_to: localhost ''' RETURN = """ diff --git a/lib/ansible/modules/cloud/vmware/vmware_tag.py b/lib/ansible/modules/cloud/vmware/vmware_tag.py index 4a37b8234f3..46988825acf 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_tag.py +++ b/lib/ansible/modules/cloud/vmware/vmware_tag.py @@ -65,10 +65,10 @@ extends_documentation_fragment: vmware_rest_client.documentation EXAMPLES = r''' - name: Create a tag vmware_tag: - hostname: 10.65.223.91 - username: administrator@vsphere.local - password: Esxi@123$ - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + validate_certs: no category_id: 'urn:vmomi:InventoryServiceCategory:e785088d-6981-4b1c-9fb8-1100c3e1f742:GLOBAL' tag_name: Sample_Tag_0002 tag_description: Sample Description @@ -77,10 +77,9 @@ EXAMPLES = r''' - name: Update tag description vmware_tag: - hostname: 10.65.223.91 - username: administrator@vsphere.local - password: Esxi@123$ - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' tag_name: Sample_Tag_0002 tag_description: Some fancy description state: present @@ -88,10 +87,9 @@ EXAMPLES = r''' - name: Delete tag vmware_tag: - hostname: 10.65.223.91 - username: administrator@vsphere.local - password: Esxi@123$ - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' tag_name: Sample_Tag_0002 state: absent delegate_to: localhost diff --git a/lib/ansible/modules/cloud/vmware/vmware_tag_facts.py b/lib/ansible/modules/cloud/vmware/vmware_tag_facts.py index be6a48c852f..e8aded77e23 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_tag_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_tag_facts.py @@ -39,21 +39,19 @@ extends_documentation_fragment: vmware_rest_client.documentation EXAMPLES = r''' - name: Get facts about tag vmware_tag_facts: - hostname: 10.65.223.91 - username: administrator@vsphere.local - password: Esxi@123$ - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' delegate_to: localhost - name: Get category id from the given tag vmware_tag_facts: - hostname: 10.65.223.91 - username: administrator@vsphere.local - password: Esxi@123$ - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + validate_certs: no delegate_to: localhost register: tag_details - - debug: msg: "{{ tag_details.tag_facts['fedora_machines']['tag_category_id'] }}" diff --git a/lib/ansible/modules/cloud/vmware/vmware_target_canonical_facts.py b/lib/ansible/modules/cloud/vmware/vmware_target_canonical_facts.py index 3b51f5130be..0176cb38b5d 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_target_canonical_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_target_canonical_facts.py @@ -52,27 +52,27 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Get Canonical name of particular target on particular ESXi host system vmware_target_canonical_facts: - hostname: vcenter_hostname - username: vcenter_user - password: vcenter_pass + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' target_id: 7 esxi_hostname: esxi_hostname delegate_to: localhost - name: Get Canonical name of all target on particular ESXi host system vmware_target_canonical_facts: - hostname: vcenter_hostname - username: vcenter_user - password: vcenter_pass - esxi_hostname: esxi_hostname + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + esxi_hostname: '{{ esxi_hostname }}' delegate_to: localhost - name: Get Canonical name of all ESXi hostname on particular Cluster vmware_target_canonical_facts: - hostname: vcenter_hostname - username: vcenter_user - password: vcenter_pass - cluster_name: cluster_name + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + cluster_name: '{{ cluster_name }}' delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py index 5a5425f1624..d731db8ca2c 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py @@ -45,9 +45,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Gather all registered virtual machines vmware_vm_facts: - hostname: esxi_or_vcenter_ip_or_hostname - username: username - password: password + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' delegate_to: localhost register: vmfacts @@ -56,9 +56,9 @@ EXAMPLES = r''' - name: Gather only registered virtual machine templates vmware_vm_facts: - hostname: esxi_or_vcenter_ip_or_hostname - username: username - password: password + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' vm_type: template delegate_to: localhost register: template_facts @@ -68,9 +68,9 @@ EXAMPLES = r''' - name: Gather only registered virtual machines vmware_vm_facts: - hostname: esxi_or_vcenter_ip_or_hostname - username: username - password: password + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' vm_type: vm delegate_to: localhost register: vm_facts diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_shell.py b/lib/ansible/modules/cloud/vmware/vmware_vm_shell.py index cbf46876f35..679ce0c6299 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_shell.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_shell.py @@ -105,9 +105,9 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Run command inside a virtual machine vmware_vm_shell: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" datacenter: "{{ datacenter }}" folder: /"{{datacenter}}"/vm vm_id: "{{ vm_name }}" @@ -124,9 +124,9 @@ EXAMPLES = r''' - name: Run command inside a virtual machine with wait and timeout vmware_vm_shell: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" datacenter: "{{ datacenter }}" folder: /"{{datacenter}}"/vm vm_id: NameOfVM @@ -141,9 +141,9 @@ EXAMPLES = r''' - name: Change user password in the guest machine vmware_vm_shell: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" datacenter: "{{ datacenter }}" folder: /"{{datacenter}}"/vm vm_id: "{{ vm_name }}" @@ -155,9 +155,9 @@ EXAMPLES = r''' - name: Change hostname of guest machine vmware_vm_shell: - hostname: "{{ vcenter_server }}" - username: "{{ vcenter_user }}" - password: "{{ vcenter_pass }}" + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" validate_certs: no datacenter: "{{ datacenter }}" folder: /"{{datacenter}}"/vm diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_vm_drs_rule.py b/lib/ansible/modules/cloud/vmware/vmware_vm_vm_drs_rule.py index 3c172991058..10e8cf240b6 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_vm_drs_rule.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_vm_drs_rule.py @@ -73,7 +73,7 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = r''' - name: Create DRS Affinity Rule for VM-VM vmware_vm_vm_drs_rule: - hostname: "{{ esxi }}" + hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" cluster_name: "{{ cluster_name }}" @@ -89,7 +89,7 @@ EXAMPLES = r''' - name: Create DRS Anti-Affinity Rule for VM-VM vmware_vm_vm_drs_rule: - hostname: "{{ esxi }}" + hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" cluster_name: "{{ cluster_name }}" @@ -105,7 +105,7 @@ EXAMPLES = r''' - name: Delete DRS Affinity Rule for VM-VM vmware_vm_vm_drs_rule: - hostname: "{{ esxi }}" + hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" cluster_name: "{{ cluster_name }}" diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py b/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py index e5856aa9ea9..cddda21ebb8 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py @@ -40,11 +40,11 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Migrate VCSA to vDS vmware_vm_vss_dvs_migrate: - hostname: vcenter_ip_or_hostname - username: vcenter_username - password: vcenter_password - vm_name: virtual_machine_name - dvportgroup_name: distributed_portgroup_name + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + vm_name: '{{ vm_name }}' + dvportgroup_name: '{{ distributed_portgroup_name }}' delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_vmkernel.py b/lib/ansible/modules/cloud/vmware/vmware_vmkernel.py index 21197263507..5802ccf56e1 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vmkernel.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vmkernel.py @@ -116,12 +116,12 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Add Management vmkernel port using static network type vmware_vmkernel: - hostname: 192.168.127.9 - username: admin - password: supersecret123 + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' vswitch_name: vSwitch0 portgroup_name: PG_0001 - vlan_id: vlan_id + vlan_id: '{{ vlan_id }}' network: type: 'static' ip_address: 192.168.127.10 @@ -132,12 +132,12 @@ EXAMPLES = ''' - name: Add Management vmkernel port using DHCP network type vmware_vmkernel: - hostname: 192.168.127.9 - username: admin - password: supersecret123 + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' vswitch_name: vSwitch0 portgroup_name: PG_0002 - vlan_id: vlan_id + vlan_id: '{{ vlan_id }}' state: present network: type: 'dhcp' @@ -146,12 +146,12 @@ EXAMPLES = ''' - name: Delete VMkernel port using DHCP network type vmware_vmkernel: - hostname: 192.168.127.9 - username: admin - password: supersecret123 + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' vswitch_name: vSwitch0 portgroup_name: PG_0002 - vlan_id: vlan_id + vlan_id: '{{ vlan_id }}' state: absent delegate_to: localhost ''' diff --git a/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py b/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py index 2b4459af306..669b9308e46 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py @@ -47,9 +47,9 @@ EXAMPLES = ''' - name: Configure IP address on ESX host vmware_vmkernel_ip_config: - hostname: esxi_hostname - username: esxi_username - password: esxi_password + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' vmk_name: vmk0 ip_address: 10.0.0.10 subnet_mask: 255.255.255.0 diff --git a/lib/ansible/modules/cloud/vmware/vmware_vmotion.py b/lib/ansible/modules/cloud/vmware/vmware_vmotion.py index 24ce3027bc1..05e861ce4af 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vmotion.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vmotion.py @@ -63,30 +63,30 @@ extends_documentation_fragment: vmware.documentation EXAMPLES = ''' - name: Perform vMotion of virtual machine vmware_vmotion: - hostname: 'vcenter_hostname' - username: 'vcenter_username' - password: 'vcenter_password' - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + validate_certs: no vm_name: 'vm_name_as_per_vcenter' destination_host: 'destination_host_as_per_vcenter' delegate_to: localhost - name: Perform storage vMotion of of virtual machine vmware_vmotion: - hostname: 'vcenter_hostname' - username: 'vcenter_username' - password: 'vcenter_password' - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + validate_certs: no vm_name: 'vm_name_as_per_vcenter' destination_datastore: 'destination_datastore_as_per_vcenter' delegate_to: localhost - name: Perform storage vMotion and host vMotion of virtual machine vmware_vmotion: - hostname: 'vcenter_hostname' - username: 'vcenter_username' - password: 'vcenter_password' - validate_certs: False + hostname: '{{ vcenter_hostname }}' + username: '{{ vcenter_username }}' + password: '{{ vcenter_password }}' + validate_certs: no vm_name: 'vm_name_as_per_vcenter' destination_host: 'destination_host_as_per_vcenter' destination_datastore: 'destination_datastore_as_per_vcenter' diff --git a/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py b/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py index 6181a542ebc..a4446600afe 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py @@ -34,11 +34,8 @@ extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' -# Example command from Ansible Playbook - - name: Configure VMware VSAN Cluster hosts: deploy_node - gather_facts: False tags: - vsan tasks: diff --git a/lib/ansible/modules/cloud/vmware/vmware_vswitch.py b/lib/ansible/modules/cloud/vmware/vmware_vswitch.py index 2e5fbd72404..6129c0bb280 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vswitch.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vswitch.py @@ -68,11 +68,10 @@ extends_documentation_fragment: EXAMPLES = ''' - name: Add a VMware vSwitch - action: - module: vmware_vswitch - hostname: esxi_hostname - username: esxi_username - password: esxi_password + vmware_vswitch: + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' switch: vswitch_name nics: vmnic_name mtu: 9000 @@ -80,18 +79,18 @@ EXAMPLES = ''' - name: Add a VMWare vSwitch without any physical NIC attached vmware_vswitch: - hostname: 192.168.10.1 - username: admin - password: password123 + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' switch: vswitch_0001 mtu: 9000 delegate_to: localhost - name: Add a VMWare vSwitch with multiple NICs vmware_vswitch: - hostname: esxi_hostname - username: esxi_username - password: esxi_password + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' switch: vmware_vswitch_0004 nics: - vmnic1 @@ -101,9 +100,9 @@ EXAMPLES = ''' - name: Add a VMware vSwitch to a specific host system vmware_vswitch: - hostname: 192.168.10.1 - username: esxi_username - password: esxi_password + hostname: '{{ esxi_hostname }}' + username: '{{ esxi_username }}' + password: '{{ esxi_password }}' esxi_hostname: DC0_H0 switch_name: vswitch_001 nic_name: vmnic0 diff --git a/lib/ansible/modules/cloud/vmware/vmware_vswitch_facts.py b/lib/ansible/modules/cloud/vmware/vmware_vswitch_facts.py index 159555eebab..92d6c7521ec 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vswitch_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vswitch_facts.py @@ -45,7 +45,7 @@ EXAMPLES = r''' hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' - cluster_name: cluster_name + cluster_name: '{{ cluster_name }}' delegate_to: localhost register: all_hosts_vswitch_facts diff --git a/lib/ansible/modules/cloud/vmware/vsphere_copy.py b/lib/ansible/modules/cloud/vmware/vsphere_copy.py index eeca38c499f..ff5d0aa5365 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_copy.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_copy.py @@ -67,9 +67,9 @@ notes: EXAMPLES = ''' - vsphere_copy: - host: vhost - login: vuser - password: vpass + host: '{{ vhost }}' + login: '{{ vuser }}' + password: '{{ vpass }}' src: /some/local/file datacenter: DC1 Someplace datastore: datastore1 @@ -77,9 +77,9 @@ EXAMPLES = ''' delegate_to: localhost - vsphere_copy: - host: vhost - login: vuser - password: vpass + host: '{{ vhost }}' + login: '{{ vuser }}' + password: '{{ vpass }}' src: /other/local/file datacenter: DC2 Someplace datastore: datastore2