-
Notifications
You must be signed in to change notification settings - Fork 26
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
Implement post_create_command #96
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Thomas Heinen <[email protected]>
Signed-off-by: Thomas Heinen <[email protected]> Co-authored-by: Tim Smith <[email protected]>
Small reminder for this PR :) |
Signed-off-by: Thomas Heinen <[email protected]> Co-authored-by: Kimberly Garmoe <[email protected]>
Thank you Kimberly - that's much more readable now 👍 |
I'd like to ping again. The unsuccessful check is a pipeline-internal failure actually. This feature is the base for a follow-on PR which includes some support for static IPs without time-intensive customization and includes more flexible scripting options. It's been pending for several weeks now. |
default_config :vm_username, "vagrant" | ||
default_config :vm_password, "vagrant" | ||
default_config :vm_username, nil | ||
default_config :vm_password, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a breaking change for some people - to drop the default value of "vagrant". I'd prefer to keep the value if possible.
|
||
def kitchen | ||
require "binding_of_caller" | ||
binding.callers.find { |b| b.frame_description == "create" && b.receiver.class == Kitchen::Instance }.receiver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a TODO comment and reference test-kitchen/test-kitchen#1674
Kitchen.logger.debug format("Script execution: %s", script) | ||
|
||
tools = Support::GuestOperations.new(vim, vm, guest_auth, ssl_verify) | ||
output = tools.run_shell_capture_output(script, :auto, timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, when I run this with a Windows 2016 template with VMWare tools installed, this fails at this point because it fails to write a temporary file:
-----> Creating <default-windows-2016>...
Assigning network VM Network...
Cloning 'Templates/windows2016-template' to create the VM...
Waiting for VMware tools to become available (timeout: 90 seconds)...
Running post create script 'kitchen.yml'
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Failed to complete #create action: [FileNotFound: File C:\Windows\TEMP\vm_utils_run_out_0.2658098154379308 was not found] on default-windows-2016
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
My Kitchenfile:
driver:
name: vcenter
vcenter_username: (...)
vcenter_password: (...)
vcenter_host: (...)
platforms:
- name: windows-2016
driver:
targethost: (...)
network_name: VM Network
folder: cwolfe
clone_type: full
vm_wait_timeout: 180
datacenter: (...)
template: Templates/windows2016-template
post_create_script: |
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile="Public" new remoteip="any"
transport:
username: vagrant
password: vagrant
suites:
- name: default
provisioner:
name: chef_zero
verifier:
name: inspec
C:\Windows\Temp\
exists. Any advice?
Closing because of staleness. We can reopen if we hear from @tecracer-theinen . |
Description
In some cases, remote machines need to get brought into a certain condition before Kitchen can even connect to them. A strong use case might be opening firewalls for WinRM connections:
Customers should use production-grade images in Test Kitchen to achieve Dev/Prod Parity, so changing the firewall in the template is not desired. On the other hand, Kitchen cannot connect before the firewall allows it. By using the VMware Tools Guest Operations API (just as with the Active IP Discovery already present in the driver), such modifications can be made even before network connections are attached.
The solution would also offer the possibility to assign static IPs etc with some scripting. It creates a list of scripts to run, so future features can queue commands as well.
Additionally in this PR:
This makes the feature easier to use, as the credentials for both are likely identical.
benchmark_*
methods to use guards instead of litteringif
around.In the mid-term, this driver will need a plugin system to not include too many exotic features and make it testable. That's why I started cleaning the main control flow to be linear and pulled the logic into guards. I will open an issue for the discussion of plugins later.
Issues Resolved
Issue #69 is kind of relevant, but setting hostname/IP is better done with Guest customization. This PR would offer a way to automate it before that feature lands, though.
Check List