A vCloud Air Servers driver for Test Kitchen!
Originally based on the Rackspace driver (from Jonathan Hartman's)
Add this line to your application's Gemfile:
gem 'kitchen-vcair'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kitchen-vcair
Provide, at a minimum, the required driver options in your .kitchen.yml
file:
driver:
name: vcair
vcair_username: [Your vCloud Air username]
vcair_password: [Your vCloud Air password]
vcair_api_host: [Your vCloud Air API Host]
vcair_vm_password: [Initial system password used for bootstrap]
vcair_org: [Your vCloud Air Organization ID]
require_chef_omnibus: [e.g. 'true' or a version number if you need Chef]
platforms:
- name: [A PLATFORM NAME, e.g. 'centos-6']
By default, the driver will spawn a 1GB server on the base image for your specified platform. Additional, optional overrides can be provided:
image_id: [SERVER IMAGE ID]
vcair_net: [ROUTED_NETWORK_WITH_ACCESS_TO_CHEF_SERVER]
flavor_id: [SERVER FLAVOR ID]
server_name: [A FRIENDLY SERVER NAME]
public_key_path: [PATH TO YOUR PUBLIC SSH KEY]
wait_for: [NUM OF SECONDS TO WAIT BEFORE TIMING OUT, DEFAULT 600]
no_ssh_tcp_check: [DEFAULTS TO false, SKIPS TCP CHECK WHEN true]
no_ssh_tcp_check_sleep: [NUM OF SECONDS TO SLEEP IF no_ssh_tcp_check IS SET]
If targeting windows, be sure to add transport
and ```verifier`` options:
transport:
name: winrm
connection_retries: 15
connection_retry_sleep: 15
max_wait_until_ready: 600
username: 'administrator'
password: 'Password1'
verifier:
name: pester
You also have the option of providing some configs via environment variables:
export VCAIR_API_HOST='API_HOST.vchs.vmware.com'
export VCAIR_VM_PASSWORD='SOME_INITIAL_PASSWORD'
export VCAIR_ORG='MNNNNNNNNN-NNNN'
export VCAIR_USERNAME='YOUR_USERNAME'
export VCAIR_PASSWORD='YOUR_PASSWORD'
Execution:
KITCHEN_YAML=.kitchen.vcair.yml kitchen test
You must populate :vcair_vm_password in your kitchen.yml
You must populate :vcair_net OR create a non-isolated network (it will use the first available)
You may find it easier to use a provisioning node within the same network you nodes will be provisioned on
Both of these can be worked around by including a :customization_script
that sets the password manually, removes the expiry, opens the firewall for and enables winrm.
platforms:
- name: win2012-chef12
driver_config:
image_id: W2K12-STD-64BIT
size: 2gb
customization_script: 'install-winrm-vcair.bat'
@echo off
@rem First Boot...
if “%1%” == “precustomization” (
echo Do precustomization tasks
@rem during this boot the hostname is set, which requires a reboot
@rem we also enable winrm over http, plaintext, long timeout, more memory etc
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig -transport:http
cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
@rem Make sure winrm is off for this boot, but enabled on next
@rem as we don't want a tcp connection available until we are
@rem past postcustomization
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
@rem make sure the default on password age is unlimited
@rem this ensures we don't have a password change forced on us
cmd.exe /c net accounts /maxpwage:unlimited
@rem write out a timestamp for this first boot / customization completes
echo %DATE% %TIME% > C:\vm-is-customized
) else if “%1%” == “postcustomization” (
@rem Second Boot / start winrm, just incase, and fix firewall
cmd.exe /c net start winrm
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985 for WinRM"
@rem Password Setting and Autologin currently seem broken
@rem when done via the API, so we MUST set it in the postcustomization phase
cmd.exe /c net user administrator Password1
@rem in some environments we found the need to specify a DNS address
@rem cmd.exe /c netsh interface ipv4 add dnsserver "Ethernet" address=8.8.8.8
@rem cmd.exe /c netsh interface ipv4 add dnsserver "Ethernet0" address=8.8.8.8
@rem this is our 'ready' boot, password and winrm should be up
echo %DATE% %TIME% > C:\vm-is-ready
)
CentoOS64-64BIT is the only image that allowed setting the password CentOS and Ubuntu failed to set the password correctly
Only routed networks supported for now
- github.com/vulk/kitchen-vcair
- vchs.vmware.com
- Walkthrough steps for cloning, building gem
- git clone git@github.com:/vulk/kitchen-vcair.git
- cd kitchen-vcair
- gem build kitchen-vcair.gemspec
- gem install ./kitchen-vcair-0.1.0.gem
- quick look through code
- git clone git@github.com:chef-cookbooks/httpd.git
- walkthrough of .kitchen.vcair.yml
- walkthrough of environment variables
- kitchen test
- vchs.vmware.com virtualmachine list, showing creation of helloworldtest VM
- knife vcair server list showing creation of helloworld test VM
- instance provisionied, waiting for ssh
- ssh available, installing chef-client
- chef-client starting
- chef-client finished, apache install completed
- Kitchen Setup and Verify
- Kitichen Destroy
- Kitchen is finished
- vchs.vmware.com and knife vcair shows vm destroyed
- vmwair-vcair.env.example
- .kitchen.vcair.yml
- .yml / platforms:customization_script note
- customization_script install-winrm-vcair.bat
- git clone opscode-cookbooks/iis
- start coping files into iis cookbooks
- Add kitchen-vcair and kitchen-pester to the Gemfile
- bundle install kitchen vcair and pester
- KITCHEN_YAML=.kitchen.vcair.yml bundle exec kitchen verify
- Server is allocated.
- 'pre'/'post' customization script
- 'pre' customization reboot
- 'post' customization boot
- winrm is online
- installing chef omnibus
- chef-client starts
- iis:default recipe runs
- verification via kitche-pester
- kitchen verify complete!
- iis default web page via links
- kitchen verify again
- kitchen destroy
- Fork it
bundle install
- Create your feature branch (
git checkout -b my-new-feature
) bundle exec rake
must pass- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request