community.vmware
                                
                                 community.vmware copied to clipboard
                                
                                    community.vmware copied to clipboard
                            
                            
                            
                        [WIP] fix(vmware_guest): parameter not correct nicsettings:adapter:ip
SUMMARY
Usage of Customization Spec, when configured to prompt user for Network settings, caused error Failed to create a virtual machine: A specified parameter was not correct: nicsettings:adapter:ip.
This fix ensure IP Address, Subnet Mask and Hostname will be set based on parameter networks and name if parameter customization_spec is used.
Based on not merged PR https://github.com/ansible/ansible/pull/61329/ Fixes https://github.com/ansible-collections/community.vmware/issues/599 Fixes https://github.com/ansible/ansible/issues/55560
ISSUE TYPE
- Bugfix Pull Request
COMPONENT NAME
vmware_guest
ADDITIONAL INFORMATION
Build failed.
- ansible-test-cloud-integration-govcsim-python38_1_of_3 : FAILURE in 9m 51s
- ansible-test-cloud-integration-govcsim-python38_2_of_3 : SUCCESS in 8m 05s
- ansible-test-cloud-integration-govcsim-python38_3_of_3 : SUCCESS in 7m 52s
- ansible-tox-linters : FAILURE in 5m 36s
- build-ansible-collection : SUCCESS in 3m 29s
- ansible-test-sanity-docker-devel : FAILURE in 9m 04s (non-voting)
- ansible-test-sanity-docker-milestone : FAILURE in 11m 58s
- ansible-test-sanity-docker-stable-2.11 : FAILURE in 11m 30s
- ansible-test-sanity-docker-stable-2.12 : FAILURE in 9m 06s
- ansible-test-units-community-vmware-python27 : SUCCESS in 11m 55s
- ansible-test-units-community-vmware-python36 : SUCCESS in 9m 21s
- ansible-test-units-community-vmware-python37 : SUCCESS in 6m 57s
- ansible-test-units-community-vmware-python38 : SUCCESS in 13m 58s
- ansible-test-cloud-integration-vcenter7_only-python36-stable211 : SUCCESS in 25m 34s
- ansible-test-cloud-integration-vcenter7_2esxi-python36-stable211 : FAILURE in 18m 27s
- ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_1_of_2 : FAILURE in 22m 08s
- ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_2_of_2 : RETRY_LIMIT in 1m 14s
- ansible-galaxy-importer : SUCCESS in 3m 48s
Build failed.
- ansible-test-cloud-integration-govcsim-python38_1_of_3 : SUCCESS in 11m 21s
- ansible-test-cloud-integration-govcsim-python38_2_of_3 : SUCCESS in 7m 41s
- ansible-test-cloud-integration-govcsim-python38_3_of_3 : SUCCESS in 7m 49s
- ansible-tox-linters : SUCCESS in 3m 33s
- build-ansible-collection : SUCCESS in 2m 16s
- ansible-test-sanity-docker-devel : FAILURE in 7m 27s (non-voting)
- ansible-test-sanity-docker-milestone : SUCCESS in 11m 17s
- ansible-test-sanity-docker-stable-2.11 : SUCCESS in 13m 37s
- ansible-test-sanity-docker-stable-2.12 : SUCCESS in 9m 09s
- ansible-test-units-community-vmware-python27 : SUCCESS in 6m 38s
- ansible-test-units-community-vmware-python36 : SUCCESS in 6m 27s
- ansible-test-units-community-vmware-python37 : SUCCESS in 7m 31s
- ansible-test-units-community-vmware-python38 : SUCCESS in 7m 29s
- ansible-test-cloud-integration-vcenter7_only-python36-stable211 : SUCCESS in 23m 35s
- ansible-test-cloud-integration-vcenter7_2esxi-python36-stable211 : SUCCESS in 23m 13s
- ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_1_of_2 : SUCCESS in 58m 03s
- ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_2_of_2 : FAILURE in 19m 59s
- ansible-galaxy-importer : SUCCESS in 3m 33s
Thanks for your Feedback @mariolenz, let me try to explain in a little more detail why in my opinion the behavior as it is today isn't optimal and we should consider some improvements.
I won't start an argument with you on this. The code is quite complex, and I'm not sure if I fully understand your problem yet. But I agree, we should consider some improvements ;-)
But I'm not sure how those improvements should look like. As I've said, the module is quite complex and changing something here might easily introduce a problem there that nobody thought about. But I'll try to understand more and work with you on this.
Parameter
customization_specas it's implemented today, only works when eitherDHCPorcustom settingsis selected in Section Network of the VM Customization Specifications. Using settings from parameternetworksin combination withcustomization_specjust isn't possible because those will be ignored, same for the parameterhostname.
Yes, it looks like all other customization parameters in networks are ignored when customization_spec is defined. I'll try to find the time and have another look at your code. Something tells me there's still a problem, and I want to make sure that my feeling is wrong or that I find out what's wrong.
But I'm not sure how those improvements should look like. As I've said, the module is quite complex and changing something here might easily introduce a problem there that nobody thought about. But I'll try to understand more and work with you on this.
Agree it's complex indeed, as far I can see customization_spec is only used in vmware_guest.py and vmware_guest_instant_clone.py, so it looks like the risk to break things somewhere else in the module seem quite low. But sure, it definitely need further investigation and testing.
Yes, it looks like all other customization parameters in
networksare ignored whencustomization_specis defined. I'll try to find the time and have another look at your code. Something tells me there's still a problem, and I want to make sure that my feeling is wrong or that I find out what's wrong.
Thanks, appreciated. I used the code in this PR successfully in my Environment to deploy quite a lot of Server yet, so it seems at least like a good starting boot.
I will try to implement and test the support of the following scenario probably next week:
One Interfaces in networks, two in the customization_spec profile, settings of the first one will be set based on values in networks, independent what's configured in the VM Customization Specification, the second one will be left untouched.
There hasn't been any activity on this PR for quite some time, so I'll close it for now. Feel free to re-open it or open a new one if you think it's important.
@mariolenz apologies that I never finished the PR, needed it to solve a problem in my old Job, were the code probably still run today as custom patch of the ansible collection. But I don't have access to a VMWare Environment anymore to do some refactoring to get it officially merged. Maybe someone else find the work which was done so far useful and might want to finish it one day.