Showing posts with label chef. Show all posts
Showing posts with label chef. Show all posts

Tuesday, May 10, 2016

Touchy DNS in Kitchen/Vagrant VM's?

TL; DR

Add to your drive section in .kitchen.yml

1
2
  customize:
    natdnshostresolver1: "on"

Symptom

I often work remotely. It's a beautiful thing; however, "Thar be dragons!" Does your cookbook need private DNS? Resources behind the firewall? Well, let's connect to VPN. WooHoo... Wait... The chef-client install failed. It can't get to the internet? WHAT? 

Solution

My VPN client has split tunneling DNS and split tunnel networking. So... How do you working around it? Tell kitchen to tell vagrant to use your host workstation as the DNS server.





Monday, May 9, 2016

CoffeeScript Substrings

TL;DR


1
2
3
4
5
run_list = [ 'role[flexo]','role[bender]','role[roberto]']

run_list.forEach (result) ->
  role = result.match /\[(\S*)\]/i
  alert(role[1]) # Should yield a message box with "flexo" then "bender" then "roberto"

What I was looking for:

Given a Chef run_list, I needed the name of each role via CoffeeScript. I am working at having hubot tell our deployment processor to run a release. I wanted to help the user find the application they were looking for.

Helpful Links:

Try CoffeeScript - Paste your coffeescript and test it in browser

Friday, April 22, 2016

Finding assets in Chef

TL;DR

 knife search node "manufacturer:Dell* OR manufacturer:HP*" -a fqdn -a dmi.system.manufacturer -a dmi.system.product_name -a dmi.system.serial_number 

Background

Today I was asked if the data center inventory was up to date... Well, no, it wasn't... I was looking for ways to find out what was in the data center without having to make the hour round trip.

I thought, "I wonder what's in Ohai". Low and behold, node[:dmi][:system][:manufacturer] is the name of the hardware manufacturer. WooHoo! A little knife search magic, and I get: 
 knife search node "manufacturer:Dell* OR manufacturer:HP*" -a fqdn -a dmi.system.manufacturer -a dmi.system.product_name -a dmi.system.serial_number
host.mydomain.com:
  dmi.system.manufacturer:  Dell Inc.
  dmi.system.product_name:  PowerEdge R720xd
  dmi.system.serial_number: XX0099AA
  fqdn:                     host.mydomain.com

There it is, a one line asset inventory. This is specifically looking for Dell and HP hardware. It is pretty easy to extend this to any other hardware platform, including virtual guests. If you are using RedHat KVM, you can search "manufacturer:Red*".

There are a few formatting options as well, I tend to like JSON output. So, through in a -Fj and you get nice pretty JSON object.