Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsphere_guest: Allow configuration of manual mac address #35504

Merged
merged 1 commit into from Mar 1, 2018

Conversation

megamisan
Copy link
Contributor

SUMMARY

Allows user to explicitly specify the mac address of a virtual nic.

By default, ESXi or vSphere generate a MAC address for any virtual nic. However, in some circumstances, user will need to specify it. This change allows the user to manually specify the address.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

cloud/vmware/vsphere_guest

ANSIBLE VERSION
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]
ADDITIONAL INFORMATION

@ansibot
Copy link
Contributor

ansibot commented Jan 30, 2018

@ansibot ansibot added cloud community_review In order to be merged, this PR must follow the community review workflow. feature_pull_request module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Jan 30, 2018
@Akasurde Akasurde removed the needs_triage Needs a first human triage before being processed. label Jan 30, 2018
@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_module This PR includes a new module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Feb 7, 2018
@Akasurde
Copy link
Member

@megamisan Can you please rebase the branch ? Also, add -vvvv output here so that we can take it forward.

In one of the IRC meeting of VMware SIG, we decided to merge all vsphere_guest PRs based on -vvv output. This decision was taken as vsphere_guest is deprecated in version 2.5. You can find the details here

Let me know if you need any other information.

@Akasurde
Copy link
Member

@megamisan Could you please rebase the branch and add -vvvv output here so that we can take it forward?

In one of the IRC meeting of VMware SIG, we decided to merge all vsphere_guest PRs based on -vvv output. This decision was taken as vsphere_guest is deprecated in version 2.5. You can find the details here

Let me know if you need any other information.

@ansibot ansibot added deprecated This issue/PR relates to a deprecated module. community_review In order to be merged, this PR must follow the community review workflow. and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html new_module This PR includes a new module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 28, 2018
@megamisan
Copy link
Contributor Author

Output with -vvv:

$ ansible-playbook /etc/ansible/provision-vsphere.pb.yaml -l test1 --ask-sudo-pass -vvv
ansible-playbook 2.6.0 (vsphere_guest_nic_mac 44e0229738) last updated 2018/02/28 23:43:16 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/pierrick/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/pierrick/ansible/lib/ansible
  executable location = /home/pierrick/ansible/bin/ansible-playbook
  python version = 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]
Using /etc/ansible/ansible.cfg as config file
[DEPRECATION WARNING]: The sudo command line option has been deprecated in favor of the "become" command line arguments. This feature will be removed in version 2.6. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
SUDO password: 
Parsed /etc/ansible/hosts inventory source with ini plugin
[DEPRECATION WARNING]: vsphere_guest is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAYBOOK: provision-vsphere.pb.yaml ********************************************************************************************************************************************************************
1 plays in /etc/ansible/provision-vsphere.pb.yaml

PLAY [Create virtual machines] *************************************************************************************************************************************************************************
META: ran handlers

TASK [Create instance] *********************************************************************************************************************************************************************************
task path: /etc/ansible/provision-vsphere.pb.yaml:20
Using module file /home/pierrick/ansible/lib/ansible/modules/cloud/vmware/_vsphere_guest.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: pierrick
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994 `" && echo ansible-tmp-1519914961.32-246872448440994="` echo /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994 `" ) && sleep 0'
<localhost> PUT /home/pierrick/.ansible/tmp/ansible-local-19474Y3PcsD/tmpZOzSc1 TO /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994/_vsphere_guest.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994/ /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994/_vsphere_guest.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=khiwduuxyhphgggoitojidopmnufhgub] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-khiwduuxyhphgggoitojidopmnufhgub; /usr/bin/python /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994/_vsphere_guest.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/pierrick/.ansible/tmp/ansible-tmp-1519914961.32-246872448440994/ > /dev/null 2>&1 && sleep 0'
[DEPRECATION WARNING]: The 'vsphere_guest' module has been deprecated. Use 'vmware_guest' instead.. This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [test1 -> localhost] => {
    "ansible_facts": {
        "hw_eth0": {
            "addresstype": "manual", 
            "ipaddresses": null, 
            "label": "Network adapter 1", 
            "macaddress": "00:50:56:0b:2a:cb", 
            "macaddress_dash": "00-50-56-0b-2a-cb", 
            "summary": "Server External Network"
        }, 
        "hw_guest_full_name": "Debian GNU/Linux 8 (64-bit)", 
        "hw_guest_id": "debian8_64Guest", 
        "hw_instance_uuid": "522185f7-37a3-a020-3b0a-703a52fb5525", 
        "hw_interfaces": [
            "eth0"
        ], 
        "hw_memtotal_mb": 4096, 
        "hw_name": "Test1", 
        "hw_power_status": "POWERED OFF", 
        "hw_processor_count": 4, 
        "hw_product_uuid": "564d2cae-cfa7-732d-11e0-d64bc6df77d9", 
        "module_hw": true
    }, 
    "changed": true, 
    "changes": "Created VM Test1", 
    "invocation": {
        "module_args": {
            "cluster": null, 
            "esxi": {
                "datacenter": "ha-datacenter", 
                "hostname": "devhost.dasbu.ro"
            }, 
            "force": false, 
            "from_template": null, 
            "guest": "Test1", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "power_on_after_clone": true, 
            "resource_pool": "/Resources/Principal", 
            "snapshot_to_clone": null, 
            "state": "present", 
            "template_src": null, 
            "username": "ansible-deploy", 
            "validate_certs": true, 
            "vcenter_hostname": "devhost.dasbu.ro", 
            "vm_disk": {
                "disk1": {
                    "datastore": "temp", 
                    "size_gb": 20, 
                    "type": "thin"
                }
            }, 
            "vm_extra_config": {
                "notes": ""
            }, 
            "vm_hardware": {
                "memory_mb": "4096", 
                "num_cpus": "4", 
                "osid": "debian8_64Guest", 
                "scsi": "paravirtual", 
                "vm_cdrom": {
                    "iso_path": "ISO/debian-9.2.1-amd64-netinst-test.iso", 
                    "type": "iso"
                }
            }, 
            "vm_hw_version": null, 
            "vm_nic": {
                "nic1": {
                    "mac_address": "00:50:56:0b:2a:cb", 
                    "network": "Server External Network", 
                    "network_type": "standard", 
                    "type": "vmxnet3"
                }
            }, 
            "vmware_guest_facts": null
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP *********************************************************************************************************************************************************************************************
test1                      : ok=1    changed=1    unreachable=0    failed=0   

@Akasurde
Copy link
Member

Akasurde commented Mar 1, 2018

Based on output, merging.

@Akasurde Akasurde merged commit 808f45d into ansible:devel Mar 1, 2018
@Akasurde
Copy link
Member

Akasurde commented Mar 1, 2018

@megamisan Thanks for your contribution.

@megamisan megamisan deleted the vsphere_guest_nic_mac branch March 1, 2018 16:02
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 5, 2018
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cloud community_review In order to be merged, this PR must follow the community review workflow. deprecated This issue/PR relates to a deprecated module. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants