Closed maltman111 closed 6 years ago
What do you mean? The machine resource will take the name property and that's what appears in vmware.
machine "my-vm-name" do machine_options bootstrap_options: { } end
Correct. Under customization_spec, I have set hostname equal to my desired name. The box takes that name just fine. However, VSphere just takes default_Windows2012_hffjewivdshvsidjo. Something like that. Not sure where that default name is coming from.
Maybe i'm not understanding you correctly, but:
machine "this-is-your-vsphere-vmname" do
machine_options bootstrap_options: {
customization_spec: {
:hostname => "this-is-your-os-hostname"
},
}
end
Ah ok. I see. Is there a parameter that can be passed to the kitchen.yml under machine options? I have posted it below.
driver:
name: vsphere
driver_options:
host: 'host'
user: ‘user’
password: ‘password’
insecure: true
machine_options:
start_timeout: 600
create_timeout: 600
ready_timeout: 600
bootstrap_options:
use_linked_clone: true
datacenter: ‘DC’
template_name: 'Win 2012 R2 Standard'
template_folder: 'Templates’
resource_pool: ‘pool’
num_cpus: 2
memory_mb: 4096
network_name:
- "VLAN"
vm_folder: "Folder"
customization_spec: {
ipsettings: {
ip: 'IP,
subnetMask: '255.255.255.0',
gateway: ["Gateway"],
dnsServerList: [‘DNS1’,’DNS2’]
},
domain: ‘domain’,
domainAdmin: ‘user’,
domainAdminPassword: ‘password’,
win_time_zone: 4,
product_id: ‘product ID’,
org_name: ‘org’,
hostname: 'servername'
}
can you post the whole bottom portion?
From the documentation example - there are two portions, you posted the machine_options portion which are just additional attributes for the machine, the part where the name is assigned is at the machine creation portion (bottom part of the code block below - which you have not pasted):
with_machine_options :bootstrap_options => {
use_linked_clone: true,
num_cpus: 2,
memory_mb: 4096,
network_name: ["vlan_20_172.21.20"],
datacenter: 'datacenter_name',
resource_pool: 'cluster',
template_name: 'path to template',
customization_spec: {
ipsettings: {
dnsServerList: ['1.2.3.31','1.2.3.41']
},
:domain => 'local'
}
:ssh => {
:user => 'root',
:password => 'password',
:paranoid => false,
}
}
machine "my_machine_name" do
run_list ['my_cookbook::default']
end
Yeah here it is. So the name comes from the suite name? Didn't realize that.
provisioner:
name: chef_zero
always_update_cookbooks: true
verifier:
name: inspec
transport:
username: "administrator"
password: password
platforms:
- name: Windows2012R2
suites:
- name: default
run_list:
- recipe[recipe::default]
attributes:
I defer you to this answer since you are talking about kitchen: https://stackoverflow.com/questions/38682471/how-to-change-box-name-in-chef-kitchen-yml
"The name of the VM (e.g. kitchen-default-prodabcom_..default_1234..) is derived here in kitchen-vagrant and cannot easily be changed." https://github.com/test-kitchen/kitchen-vagrant/blob/236970afa3d64558ca7c7dfbff2d55269b10f4d8/lib/kitchen/driver/vagrant.rb#L396-L398
@hrmmmwhynot awesome, thanks for this. I'll close this now if any other discussion please reopen it.
Thanks guys. Don't like that last bit but I will figure out a way around it.
Versions:
Platform Details
Scenario:
Looking at the VSphere driver, I see options for host, user, password, path, etc. but no VM name. When I spin up a new VM, the actual machine name is correct but the VM name is some variation of "default-Windows2012R2-78fsugsd0gs". Can name be passed to VSphere?
Steps to Reproduce:
Spun up new Windows 2012 R2 machine with host, user, and password configured in driver_options.