The problem:
I am trying to use the kitchen-ssh driver in the .kitchen.yml file to run test kitchen on a remote node, but running kitchen commands simply uses the SSH connection to spin up a VM on that node’s ipaddress.
Rather than spinning up a new VM with every kitchen command, I want to make kitchen run the Inspec tests on the actual node itself, then withdraw from the SSH, returning the pass/fail log of the tests.
**My questions:**
Am I misusing kitchen-ssh here, or missing the point of test kitchen's create/test/destroy methodology? Or am I just combining the wrong tools to try to accomplish what I need?
When I run kitchen test or kitchen create/converge with the below .yml file everything runs perfectly fine, and I get no failures, but I don’t actually understand what’s going on with the SSH connection - I haven’t found much documentation on how kitchen-ssh works and what it does other than the following github link:
Thanks for your help.
My .kitchen.yml file:
driver:
name: ssh
hostname: 10.204.81.250
port: 22
username: egiese
ssh_key: /Users/egiese/.ssh/id_rsa
provisioner:
name: chef_zero
platforms:
suites:
- name: default
run_list:
- recipe[httpdtest::default]
attributes:
I think you want to use the built in proxy
driver instead of the ssh driver. That will not try to create a vm but simmply connects to a running instance. So your yaml would look like:
driver:
name: proxy
host: <ip or host name of server>
reset_command: "exit 0"
port: 22
username: <ssh user>
password: <ssh password>
You can use the reset_command
to reset any state if necessary. exit 0
is a good no op command to use.
InSpec (or rather kitchen-inspec
) doesn’t use Kitchen’s communication abstraction at all so which driver you use is moot. That said, if you don’t want the VM management features, you might just want to use InSpec on its own.
Oh wow, this is awesome! Just tried it and had great results! Thank you so much for your help!!!
I have another question as well about the reset_command functionality. Is there a way to use this to create a ‘snapshot’ of the server before the cookbook is fully converged (but after kitchen has proxied in), and then ‘reset’ the node back to the snapshot state. Essentially, a way to reset the node to what it was before the cookbooks and testing were run, but without destroying it, like kitchen normally does.
I was thinking of having some kind of system backup/restore command inside a recipe, but if the reset_command can do this that’d be even better.
Glad this worked for you!
The proxy driver is super minimal and does not really have any kind of snapshotting capability built in. You could have it run a shell script that has awareness of your convergence scenario and set everything back, but its really on you to do that work.
Hi Matt,
I know this is completely unrelated to this thread, but I have noticed a bug on this site that I wanted to point out. While at the top of the screen, 'Chef Mailing List' and the thread topic appear just fine, but as soon as you scroll down to view posts, the thread title, the Chef logo, and the forum tag (chef, chef-dev, etc) all merge on top of each other. Please see the screenshot below:
