profile for Gajendra D Ambi on Stack Exchange, a network of free, community-driven Q&A sites

Monday, April 2, 2018

Setting up chef + vagrant + virtualbox on windows for aws, azure and google cloud

So spinning up VMs on aws, gcp and azure via GUI, vagrant, SDK and their native cli was okay
but when you want to do configuration management and automation tools like chef then it gets a lot more interesting.

  1. chef sdk
  2. vagrant
  3. Virtualbox 5.1 or higher

My plan was/is/will be (mostly)---
step 1. deploy workload via GUI on gcp/aws/azure
step 2. deploy workload via SDK on gcp/aws/azure
step 3. deploy workload via vagrant+virtualbox on gcp/aws/azure
step 4. deploy workload via chef --> vagrant+virtualbox on gcp/aws/azure
So now i have to do step 4.
Download and install chef sdk for windows from
Launch your powershell 5.x or 6 if you are brave and run

PS C:\WINDOWS\system32> chef -v
Chef Development Kit Version: 2.5.3
chef-client version: 13.8.5
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.20.0
inspec version: 1.51.21

PS C:\WINDOWS\system32> vagrant --version
Vagrant 2.0.3
and my god takes soooooo much of time on windows just to report the installed sdk info. On any nix systems it is just a second.
PS D:\> mkdir chef

    Directory: D:\

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       03-04-2018  12.19 AM                chef

PS D:\> cd chef
PS D:\chef> vagrant box add bento/centos-7.2
==> box: Loading metadata for box 'bento/centos-7.2'
    box: URL:
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) parallels
2) virtualbox
3) vmware_desktop

Enter your choice: 2
==> box: Adding box 'bento/centos-7.2' (v2.3.1) for provider: virtualbox
    box: Downloading:
    box: Progress: 100% (Rate: 1902k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'bento/centos-7.2' (v2.3.1) for 'virtualbox'!
PS D:\chef>
I created a chef directory
added a box to my vagrant from the vagrant cloud. bento/centos-7.2 is the box maintained by chef so I want to play safe and want to start with that. Since I did not mention the provider it gave me 3 choices and I chose virtualbox.
So now vagrant has a box added and ready to deploy on virtualbox.
Now run

vagrant init

vagrant up
 and we have our chef centos box ready to play with.
Let us ssh to our new box with

vagrant ssh
Then go to /home/vagrant and install the downloaded chef rpm
sudo rpm -ivh chefdk*.rpm
If you get some permission errors then do a chmod 777 on that rpm to set proper permissions.
Run the following to verify what you have
# chef verify
# chef-client -v
# chef --version
# sudo yum install vim, nano -y
The above will install some text editors which we will need.

No comments:

Post a Comment