Getting Started With Chef on Windows

Getting started on Chef can be accomplished in different ways to suit each of our styles for learning:

  • There is a walk through of using Chef on Windows at They provide a VM in the cloud for you to use exclusively with Chef on Windows for a 24 hour period.
  • Chef Client MSI is readily available with the complete Chef software for installation on your windows OS.
  • If you prefer to install it in a VM, you have options:
    • For vagrant you can use Box-Cutter configuration for making windows boxes using packer.
    • For using windows on Amazon the Knife Windows plugin can be used.

The approach I used was to do the walk through at and used the virtual machine templates provided by Box-Cutter. What approach do you think would be best for you?

Next I’ll be using the Chocolatey-Cookbook to install packages on windows through Chef.

Free Up Space on Windows Drives

Reducing Pagefile.sys Size

Minimize the paging configuration, which by default will create a file “C:\pagefile.sys” the same size as your availble memory. Its important that the “\” be escaped with a “\”.

Minimize pagefile.sys
wmic pagefileset where name="C:\\pagefile.sys" set InitialSize=800, MaximumSize=1000

This command lists existing page files.

List configured paging files.
wmic pagefile list /format:list

The following commands add and delete page files if you would like to move it to another drive. After creating it you can then set the initialSize and MaximumSize as stated above. Its important that the “\” be escaped with a “\”.

List configured paging files.
wmic pagefileset create name="<Path to file>"
wmic pagefileset where name="<Path to file>" delete

Removing hiberfil.sys

Turning hibernate mode off will remove the C:\hiberfil.sys file. You will still have sleep mode available.

Turn off hibernate mode
powercfg -h off

Empty Recycle Bin

Empty Recycle bin on Windows 7
rd /s c:\$Recycle.Bin

Guide to Freeing Up Disk Space Under Windows 7

Redirect Blogger Blog to New Blog Site

Recently I created my new blog site that you are reading now, however I also needed my old blog to redirect to this one. I found the answer on this blog post: “How to automatically redirect Blogger blog to another blog or website”.

It only takes a small amount of javascript put in the “head” tag of the template used for my blogger blog site. From the blogger dashboard, go to the template for your site and click on edit HTML. In the “head” tag area put the following code, making sure to replace my blog site with your own:

Redirect Code for Blogger Site, Put in Head tag.
<script type='text/javascript'>
var d='<data:blog.url/>';
d=d.replace(/.*\/\/[^\/]*/, '');
location.href = '';
Virtualization With Vagrant

Curious about how to efficiently build a workstation to work on a variety of projects using reliable repeatable processes? Then this post is for you. It is part 1 in a series that I will write about this topic.

There are a variety of hardware workstations that you may be using: a desktop, laptop, maybe two laptops. The OS on these computers could also be of different types: Windows (7,8), Mac OS X, or linux (RedHat,Centos,etc.). We can normalize (or make same) the process of working on projects across these profiles (hardware & OS) with a group of tools designed to work together efficiently. These are virtualization and bootstrap automation tools (or CLI). Two specific tools in these categories are VirtualBox and Vagrant. There are others, however these serve as working examples for this post. Both tools are open source and free. You can easily download and install them on all the before mentioned profiles (hardware & OS).

Now that you have the tools to create new virtual machines easily you still need to have base image. The base image is the OS of your choosing that you would like available for working on projects. You are not restricted to just one though, you may have multiple projects on different operating systems and you can have base images for each. I use a centos 7 minimum install base image often and it will work well for the purpose of this blog. The centos 7 minimum image is available to everyone from the online service Atlas. I’ve uploaded my base image there and made it available to the public. Atlas is built by Hashicorp, the same makers of Vagrant, additionally having built my own base image I can be confident in the reliability of it being accessible and working.

Now that we have identified tools and a base image. The only final necessary component to get my virtual machine running is to create a “Vagrantfile”. The file can be as simple as the following:

Vagrant.configure(2) do |config| = "abrooke/centos-7min"

In the same directory as the before mentioned file. Simply run:

Startup the Vagrant instance in Virtual Box
vagrant up

Once the output indicates successful completion the machine will be online and ready to be accessed using SSH. With a properly configured SSH client you will be able to access the virtual machine with the simple command:

Login through ssh to Vagrant instance
vagrant ssh

In the next part in the series we will explore more features of the VagrantFile and configuring the Virtual Machine with Chef.

Create Centos Vagrant Box for Atlas

[Task time 2 hours]

Use Atlas, a recently released product of Hashicorp, to host virtualbox images. I already created an account, which was easy and free. I’ve also created my first box “abrooke/centos-7” from the web GUI at atlas. However, I need to now create a “box” for vagrant to upload it after configuring a “virtualbox” provider in my new box’s configuration in Atlas and that is where the blog post is picking up the story…

  1. Download a minimal ISO from centos.
  2. Create a new VirtualBox VM and use the ISO to install centos.
    • Use “Nat” for the first network adapter.
    • Note the MAC address for later.
    • The minimal install doesn’t come with dhclient running, so no IP. So addition setup instructions:
      1. List the interfaces with “nmcli d”
      2. Set the disconnected interface to automatically connect with “nmtui”
      3. Then finally restart the network “systemctl restart network”
  3. Then follow the instructions for createing a base box and Virtual Box specifics:
    • Set root password to “vagrant”
    • Add “vagrant” user using command: “adduser vagrant”
    • Set “vagrant” password to “vagrant” using command: “passwd vagrant”
    • Give “vagrant” user sudo permissions:
      1. Run “visudo”
      2. Add to the file “vagrant ALL=(ALL) NOPASSWD: ALL”
      3. Remove “requiretty” so that sudo can run without a tty.
    • Add insecure key to authorized_keys file of the vagrant user.
      1. Install wget as root: “yum install wget”
      2. Wget the public key from vagrant on github and put it in the “authorized_keys” file of the “vagrant” user in the “~/.ssh/” directory.
      3. Set modes for ssh files:
        1. “chmod 600 ~/.ssh/authorized_keys”
        2. “chmod 700 ~/.ssh”
    • Install Virtual Box guest additions:
      1. REQUIRES bzip2, kernel-devel, kernel-headers, gcc:
        1. “yum install bzip2”
        2. “yum install kernel-devel-$(uname -r)”
        3. “yum install kernel-headers-$(uname -r)”
        4. “yum install gcc”
      2. Troubleshooting: you might need to reboot.
        1. Mount the Virtualbox guest additions:
        2. Make sure the virtual cd with the additions is loaded.
        3. Make mount point “/media/cdrom”
        4. Now mount the “mount /dev/cdrom /media/cdrom”
    • Set “UseDNS no” in the “/etc/ssh/sshd_config” to speed up the box when not connected to the internet.
  4. HACK Vagrant version 1.7.1 to actually package the Vagrant Box:
    • Modify “/opt/vagrant/embedded/gems/gems/vagrant-1.7.1/lib/vagrant/machine.rb”
      • Remove “**” from line 153, next to “opts”
  5. Package box in current working directory with “vagrant package –base [name of VM]”.

After the Vagrant box has been created, the testing of the box can be done by loading it into vagrant’s box list using: “vagrant add box [box name] [box path from package process]

After testing the box, the box can be uploaded to Atlas. Then subsequently a “Vagrantfile” can be configured to use it. Then “vagrant up” will use the “Vagrantfile” and download the box from Atlas. If the box is private in Atlas, then “vagrant login” will be necessary.