chefspec is a torture device

hey all – i am back to blogging here instead of using another platform.  also i think i will be continue to writing stuff about my career, technologies i am working with and other crap like that.  i could occasionally go off script and discuss other subjects, but i guess that’s why it’s my blog.  anyway, here’s my post on test driven development.

as part of my career expanding, i’ve had to accept that i need to take on more complex projects that lean more heavily on software development rather than general operations duties.  we can have a discussion all day about devops but let’s skip that.  for now let’s talk about what i am starting to learn.

rspecchef is a huge part of my day.  i am constantly working on, reading or starting a new chef cookbook.   it’s been a very difficult road, but every part has been fulfilling.  the hardest part of this road has been perfecting testing.  testing is a fairly new theory to me as a software tool rather than monitoring tools to validate services.  doing chef in a test driven development method is pretty new to me, i was never much of a “dev”


getting to know rspec was like really the biggest part of understanding tests in a chef environment.  while i know many ruby developers in the rails world are already very familiar with it, i honestly did not spend much time creating things that required a ton of testing.  as i started learning more and more about chef i started to understand a real process of developing software i never really had put much thought in:


while i did write some tests in the past based in bash using “bats” it didn’t really translate to my new gig.  but yes, i do understand and love doing tests as part of building systems with chef.  i get why it’s so important but let me tell you something that i learned.

chefspec was created to torture me to learn how to write software.

i don’t personally know Seth Vargo, but i do believe he has created a github backed torture device that forces people who do not test code to learn how to test code.  but let me explain to you, for the novice it’s not that easy.

“just read the docs, it’s just ruby, it reads like english!” 11214380_10206035835668662_4166006889452580683_n

well that’s what i did of course.  i read the docs, wrote the tests, read more docs, read more tests.  copied and pasted tests, wrote tests from scratch, got my runners configured and whatnot… it kept giving return fails.  when i did get my rspec examples to pass, i would get pr comments about improperly configured runners or poorly used syntax.  even worse, my style was terrible.  i was getting so frustrated and started getting some nasty anxiety about it… basically it was a dumpster fire.


then i took a moment and talked it out with a peer who gave me some great advice about being part of a segment of “learning” crowd as i move forward and age in the tech industry.  he reminded me to continue to improve my quality and it will equate to more success than doing something fast and poor.  in the end, he was right.  but what was this process doing really?  is it getting me to solve a problem or is it get me to be better at what i do?

so i’ve spent a week or so on some tests and started really seeing some success lately.  the simple tests of successful converges are things i was able to take on with a very small amount of previous testing knowledge.  the more complex conditional types helped me get a greater idea about writing software in general and helped me expand my knowledge just a bit more.


nah i am just joking, i don’t KNOW IT quite the way Neo learned how to do some crazy helicopter stuff in the matrix.  but i really have a great base of knowledge today i didn’t yesterday.  it hurt a lot.  it took me really doubting myself to get to the point where making a negative condition check using a regex string to “not match” in my “with_content” statement made me feel like i was starting to do things a bit more profound.

the road i am going down is bumpy as hell, but it’s pretty fruitful.  i’m learning more about me every day when it comes to new aspects of operation and change management systems.  there’s more to what i do than reboot, install, maintain and patch.  there’s interesting ideas that can be placed into code i can repeat or iterate or refactor.  i don’t have to do the same thing over and over.  but i do have to make sure it works right the first time.

Get the right IP

Get the right IP

Was currently taking part in moving a WordPress site with a single webserver into a AWS Virtual Private cloud using an ELB to loadbalance multiple webservers.  Ran into an issue where IPs were not being grabbed properly and provided to the WordPress control panel for comment moderation.  I have already enabled the X-FORWARDED-FOR header in apache and wanted WordPress to capture this rather than the VPC IPs.

Placing the following in my wp-config.php made it possible to get the real IP via this header so we can better moderate without requiring registration.  It’s a hack, but it’s a useful one.

// ** bw 2012-08-12 wordpress reverse proxy x-forwarded-for ip fix ** //
  $xffaddrs = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
  $_SERVER['REMOTE_ADDR'] = $xffaddrs[0];
Tagged , ,

EC2 Instance Types – Quick link!

Here’s a great quick link to get all information on current AWS EC2 instance size and cost:

It’s come in handy lately when I need to compare against an existing physical system or create a system requiring specific vendor recommended memory/cpu resources.

Today I listened to Straight Ahead on my way to work this morning.  Listen to this:


super crappy script to make a ton of directories and files

needed to create a really quick script to just generate a ton of directories and files to fill them mainly to create something to test backups with.  it’s not quite elegant, but to be honest it’s pretty quick and got the job done, anyway…


# a script to create content, creates 1500 directories, a 1MB file and a %K file and copies it into all subdirs
#creates the dummy content files
dd if=/dev/zero of=dummy bs=1024 count=1024
dd if=/dev/zero of=dummysmall bs=1024 count=5
#creates 1500 directories in current directory
mkdir foo{1..1500}
#copies the dummy files
find . -type d -exec cp dummy {}/ \;
find . -type d -exec cp dummysmall {}/ \;
#clean up
rm -r dummmy dummysmall
echo "done!"
Tagged , ,

don’t do the damn symlink yourself

setting up a vhost in apache on an ubuntu machine?  need to symlink it to sites-enabled?  don’t do it manually you big dummy.

following commands let you create/destroy symlinks for vhosts and apache modules:

a2dismod  a2dissite  a2enmod    a2ensite

so blahblah blah i add a new site for

create my vhost in /etc/apache2/sites-available/


Symlink is added, restart apache and you got your cool site.

Tagged ,

change that, son.

This was a great help.  Basically I had to take about 8 files with the word “stage” in them and replace it with “dev”

for i in ./*stage*;do mv -- "$i" "${i//stage/dev}";done

Bang, done!

Tagged , ,

get all of your ELB names for some sort of reason

so tony says i need to blog that shit.  so i am blogging that shit.

sometimes when i need to make a large amount of changes to several ELB’s i need a quick way to throw all of the names into a single file.  here’s a fast way to use the AWS API CLI tools to grab all of your ELB names.

prereq:  actual CLI access, your keypair (use dialt0ne’s aks to switch between your IAM accounts), the ELB CLI tools and a few minutes.

Put that shit into a text file:

$ elb-describe-lbs > elbs

cat that shit and pipe into awk printing only the second field which contains the actual ELB names:

$ cat elbs| awk '{print $2}' > elb-names

now look at that shit and confirm you got all your ELBs

$ cat elb-names

now go listen to slayer.

Tagged , , , ,

reflections on my last day

today’s my last day at the current job.  some thoughts on what i took from working here…

was able to gain some knowledge on using xen cli tools.

fussed around with multipath and how you can present luns from a dell san.  this was a neat skill to pick up.

took in some experience on dealing with hardware vendors, navigating quotes and making sure that i was not being overcharged, or sold more equipment than i needed.  this turned into a huge thing and i managed to recoup about $3k in overcharges for my employer.

learned how to install, administrate and maintain symantec’s netbackup.  this was a big undertaking.  no training what so ever, so it was just a matter of reading the documentation and getting some assistance from symatec’s team.

spent some more time around solaris, and i still don’t care for it.

i did way more documenting than i have in the past, which was already a lot.  i guess the less day to day contact you have with other members of a team, the more you have to document things.  so i did my best to document everything i did day to day.

i leave here without making big a mark as i hoped to.  but i am trying to follow a new career path that i hope really changes my future.  i am taking an opportunity that i couldn’t pass up.

more technical stuff to come…

enjoy this song from slapshot that kind of relates to my feelings:


Tagged , , ,



Gotta keep this for later, a neat wrapper to expand on my love for gnu screen.

looks like byobu expands on screen’s functionality by adding toggles and notification.

credit to @jeffreykaplan for the tip.

Tagged , , ,

why i am looking forward to using git more.

today i had to upgrade a wordpress blog with changes from an outside developer.  my current place of employment doesn’t really use much in the way of revision control and automated deployment.

here’s how the changes went today:

outside developer let’s me know that they have completed changes in their development environment via basecamp.

i send a tarball of the docroot along with a dump of the SQL db to basecamp.

they apply their changes to the docroot and db, upload them to basecamp.

download these new files to my local computer, then scp them to the server.  

i backup the old docroot and db, then rsync the changes from the tarballed docroot.  then i drop and reimport the new db.

that’s a lot of steps to be honest, if we used a centralized repository we could have really simplified this to the developer pushing their committed changes along with a db dump.  i could have pulled the changes with git and then imported the database.

i probably should have demanded some form of revision and deployment method earlier in the process, but to be honest i was not part of the contractual discussions between the developer (which also acts as a marketing company) and my employer.  that’s where the third wall sometimes has to be respected.  there are decisions at times that are made that are outside of the scope of what the sysadmin can do simply because project managers cannot think deeply enough about how to easily implement a new piece of code their developers create.


Tagged , , , , , ,