How to Run Test Kitchen on Cookbooks Directly from Chef Infra Server - ruby

I need to run the Chef Kitchen test directly from Chef Infra server without maintaining the cookbook locally. Is there a way we can configure Kitchen test to get the cookbook directly from Chef Infra server and run?

Related

My Vagrant machine from chef kitchen cannot access the internet

I am trying to learn how to do local development of chef recipes. I am following this guide https://gist.github.com/smford22/f00f46471047422bd8a7
I am prefixing all the kitchen commands with chef exec because if I try to run kitchen directly, I get all sorts of ruby/gem errors.
When I run chef exec kitchen converge it gets stuck on installing the Chef Omnibus, hanging on "Trying wget..."
If I login to the VM and try to run curl and wget commands like curl https://google.com it indeed cannot access the internet.
chef exec kitchen -v
Test Kitchen version 1.23.2
chef -v
Chef Development Kit Version: 3.5.13
chef-client version: 14.7.17
delivery version: master (6862f27aba89109a9630f0b6c6798efec56b4efe)
berks version: 7.0.6
kitchen version: 1.23.2
inspec version: 3.0.52
.kitchen.yml:
---
driver:
name: vagrant
## The private_network feature lets you setup a private network on the VM guest
## via localhost on the host.
## see also: https://www.vagrantup.com/docs/networking/private_network.html
# network:
# - ["private_network", {ip: "33.33.33.33"}]
provisioner:
name: chef_zero
## The verifier section determines which test platform you want to use.
verifier:
name: inspec
format: doc
platforms:
- name: centos-6.7
suites:
- name: default
run_list:
- recipe[chef_httpd::default]
attributes:
Are you accessing the internet through proxy?
If yes, you need to configure the same for your Vagrant VMs using vagrant-proxyconf plugin.
Documentation: http://tmatilai.github.io/vagrant-proxyconf/

Does Bamboo allows to SSH Jmeter master/slave public IPs or Bamboo always connects/SSH to Private IP only?

Automating the Jmeter distributed load testing using Bamboo agent (CI).
We have used Jmeter docker swarm for distributed load testing, used docker-machine to create Jmeter master and slave machines which will give public IPs of these instances (used dockerfiles for this). Able to run successfully from local machine (Linux/Windows), able to communicate master, slave and get results from local. However when wanted to use Bamboo agent to automate the process facing an issue. Bamboo is not able to SSH to these created master and slave machines (used .sh script task to run these docker files and create master/slave docker-machines). Does Bamboo allows to SSH Jmeter master/slave public IPs or Bamboo always connects/SSH to Private IP only?

Chef Test Kitchen Timeout during vagrant up

While working with Chef, Kitchen, Vagrant and Virtual Box today... I encountered a bizarre issue when attempting to use the bento boxes hosted by Hashicorp (https://atlas.hashicorp.com/bento/) to do some Chef cookbook development/testing.
While spinning up a new cookbook, I wanted to test some newer versions of CentOS 7.2 and Ubuntu 16.04 which are not currently live in our environment. I turned to hashicorp's bento boxes to pull them down into my .kitchen.yml config.
.kitchen.yml
---
driver:
name: vagrant
provisioner:
name: chef_zero
customize:
memory: 1024
platforms:
- name: ubuntu-16.04
suites:
- name: default
run_list:
- recipe[sandbox::default]
attributes:
Used chef generate cookbook to create a new cookbook and as you can see above, was using a very vanilla kitchen config to get things started.
When running kitchen create I kept encountering the following error as an SSH Timeout when provisioning the VM using Vagrant and Virtual Box.
ERROR:
Timed out while waiting for the machine to boot.
This means that Vagrant was unable to communicate with the guest machine
within the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
When observing the Virtual Box VM Console, I noted the following (see screen shot below)...
A start job is running for Raise network interfaces (2 min 39s / 5min 3s)
Observing that Vagrant would timeout prior to the start job completing... I attempted to resolve by increasing the boot_timeout from a default of 300 seconds to 600 seconds in my .kitchen.yml
However, further testing proved that this did not resolve the issue even though the VM would successfully initialize after 5mins 3s... Kitchen / Vagrant were unable to SSH to the Host and the failure and the Vagrant SSH timeout persisted.
Ultimately, to resolve this issue I upgraded ChefDK, Vagrant, and VirtualBox to the latest versions available.
Experienced the issue with...
Virtual Box 5.0.30 r112061
Vagrant 1.8.6
Chef Development Kit 0.19.6
Resolved the issue by upgrading to...
Virtual Box 5.1.10 r112026
Vagrant 1.9.0
Chef Development Kit Version: 1.0.3
Following the version upgrades, the Vagrant SSH Timeouts disappeared completely and the box was created successfully within a few seconds.
Virtual Box VM Console

Chef kitchen converge instance requires ssh password

To run kitchen converge and set up my test kitchen vagrant instance, such as in this guide, I have noticed that I must first create a $COOKBOOK_ROOT_DIR/.kitchen/default-centos-72.yml file. After the file has been created with kitchen converge I must then control + c edit the file to include the password: vagrant line and then run kitchen converge again. In the end the file will look something like this:
---
hostname: 127.0.0.1
port: '2222'
username: vagrant
password: vagrant
ssh_key: "$COOKBOOK_ROOT_DIR/.kitchen/kitchen-vagrant/kitchen-$COOKBOOK_NAME-default-centos-72/.vagrant/machines/default/virtualbox/private_key"
last_action: converge
How can I have chef kitchen automatically know to use password: vagrant before running kitchen converge? Or better yet how can I have chef create test instances without any ssh passwords?
Yep #coderanger got it. I needed to downgrade to vagrant 1.8.4 and virtualbox 4.3.4 because virtualbox version 5+ doesnt work with vagrant 1.8.4.

Transform a vagrant box provisioned with puppet into an EC2 AMI and upload it to AWS

What is the best way to transform a vagrant box provisioned with puppet into an EC2 AMI and upload it to AWS?
Transforming a Vagrant VM in to an AMI will be problematic. The easiest thing to do in this case is:
Prepare your Puppet manifests and test locally with Vagrant
Boot an EC2 instance, and use Puppet to configure that instance. You could use the cfn-init scripts, or manually run Puppet on the instance
Create an AMI from this instance
The process is exactly the same as running Puppet on a local VM or physical hardware, except you will need to create an AMI once the instance is configured.

Resources