//
you're reading...
Chef, DevOps, Vagrant

DevOps Toolbox

Lately I’ve been doing more and more Chef cookbook development on my Mac.

While some tools i’m still trying to get my head around (Berkshelf for one), I found this site:

DevOps Toolbox

Vagrant is a great tool for Dev, and I just love how easy it is to make VM’s.

Since most of the stuff I’ve been seeing lately seems to be Ubuntu centric I figured I would post my experiences using my preferred OS, Centos 6.4 minimal.

I am already familiar with using kickstarts with CentOS, so I took a few things from my existing Cobbler infrastructure to use with Vagrant.

Here’s a couple mods I did from what the DevOps Toolbox does (everything is in the definitions area of the basebox):

base.sh

# Base install

sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers

rpm -ivh http://mirror.us.leaseweb.net/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh http://centos.alt.ru/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm

yum clean all
yum -y install gcc make gcc-c++ kernel-devel-`uname -r` zlib-devel openssl-devel readline-devel sqlite-devel perl wget dkms

chef.sh

# Chef Install
rpm -ivh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-11.6.0-1.el6.x86_64.rpm

definition.rb

Veewee::Session.declare({
  :cpu_count => '1',
  :memory_size=> '480',
  :disk_size => '10140',
  :disk_format => 'VDI',
  :hostiocache => 'off',
  :os_type_id => 'RedHat_64',
  :iso_file => "CentOS-6.4-x86_64-minimal.iso",
  :iso_src => "http://www.mirrorservice.org/sites/mirror.centos.org/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso",
  :iso_md5 => "4a5fa01c81cc300f4729136e28ebe600",
  :iso_download_timeout => 1000,
  :boot_wait => "10",
  :boot_cmd_sequence => [
    '<Tab> text ks=http://%IP%:%PORT%/ks.cfg<Enter>'
  ],
  :kickstart_port => "7122",
  :kickstart_timeout => 10000,
  :kickstart_file => "ks.cfg",
  :ssh_login_timeout => "10000",
  :ssh_user => "veewee",
  :ssh_password => "veewee",
  :ssh_key => "",
  :ssh_host_port => "7222",
  :ssh_guest_port => "22",
  :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
  :shutdown_cmd => "/sbin/halt -h -p",
  :postinstall_files => [
    "base.sh",
    "ruby.sh",
    "chef.sh",
    "vagrant.sh",
    "virtualbox.sh",
    "postinstall.sh",
    "cleanup.sh",
    "zerodisk.sh"
  ],
  :postinstall_timeout => 10000
})

ks.cfg

install
cdrom
lang en_US.UTF-8
keyboard us
network --bootproto=dhcp
rootpw --iscrypted SOME_ENCRYPTED_PASSWORD_STRING_FROM_A_SHADOW_FILE
firewall --enabled --service=ssh
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc America/Los_Angeles
bootloader --location=mbr

text
skipx
zerombr

clearpart --all --initlabel
autopart

auth  --useshadow  --enablemd5
firstboot --disabled
reboot

%packages --nobase
@core
sudo
%end

%post
/usr/sbin/groupadd veewee
/usr/sbin/useradd veewee -g veewee -G wheel
echo "veewee"|passwd --stdin veewee
echo "veewee        ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers.d/veewee
chmod 0440 /etc/sudoers.d/veewee
%end

postinstall.sh

# Make sure Udev doesn't block our network
echo "cleaning up udev rules"
rm /etc/udev/rules.d/70-persistent-net.rules
touch /etc/udev/rules.d/70-persistent-net.rules
rm -rf /dev/.udev/
rm /lib/udev/rules.d/75-persistent-net-generator.rules

echo "removing UUID from ifcfg-eth0"
sed -i 's/UUID.*//' /etc/sysconfig/network-scripts/ifcfg-eth0

echo "removing MAC from ifcfg-eth0"
sed -i 's/MAC.*//' /etc/sysconfig/network-scripts/ifcfg-eth0

echo "disabling network manager on ifcfg-eth0"
sed -i 's/NM_CONTROLLED="yes"/NM_CONTROLLED="no"/' /etc/sysconfig/network-scripts/ifcfg-eth0

echo "changing sshd settings"
sed -i 's/#TCPKeepAlive yes/TCPKeepAlive yes/' /etc/ssh/sshd_config
sed -i 's/#ClientAliveInterval 0/ClientAliveInterval 130/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config

These I left alone:
vagrant.sh
virtualbox.sh
zerodisk.sh

I had to add in the postinstall script to clear the udev persistent net rules or vagrant would hang when starting the virtualbox.

Advertisements

Discussion

2 thoughts on “DevOps Toolbox

  1. NOTES:

    Just ran into a little snag that wasn’t mentioned in the DevOps Toolbox.

    While doing the enabling the Iptables rules:

    http://chrislaco.com/devops-toolbox/customizing-recipes-for-our-application/#ENABLEMYSQLPORT

    I found that my metadata.rb had to have depends “iptables” in it, or I was getting an error like:

    “Cannot find a resource for iptables_rule on centos version 6.4”

    I also found that if you want to test chef-solo on the Vagrant VM itself, you can

    vagrant ssh db
    sudo su –
    chef-solo -c /tmp/vagrant-chef-1/solo.rb -j /tmp/vagrant-chef-1/dna.json

    Then you can edit the cookbooks on the VM in:

    /tmp/vagrant-chef-1/chef-solo-1/cookbooks

    Makes it fast to test changed, thouh the “vagrant provision db” isn’t that much slower.

    Posted by koaps | August 11, 2013, 12:02 pm

Trackbacks/Pingbacks

  1. Pingback: Dreaded “Waiting for VM to boot. This can take a few minutes.” | Nullworks - August 6, 2013

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s