Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ohai plugin to add the output of kniferackspace server list to a node's attribute treat.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
files/default/plugins
README.md

README.md

ohai-rs

In cloud environments there's a split-brain problem with your source of truth. Chef contains all of your node's configuration data, but your cloud provider contains the current status of your instances. Ohai-rs is a dirt hack of an ohai plugin to put this data into your chef-server's attribute tree for better processing. Rackspace's API is not very performant, so I elected to run the knife rackspace server list process in cron rather than inside of the ohai plugin.

This script assumes that you already are able to run knife rackspace server list, and that you have the ohai cookbook installed:

Requires:

Here's how I use it:

  
    # Apply this cron entry to your knife server
    cron 'knife-rackspace-server-list' do
      minute "*/5"
      user 'knife-user'
      mailto 'ops@yourdomain.com'
      command 'knife rackspace server list > /tmp/rs-list.txt.new; /bin/rm /tmp/rs-list.txt; mv /tmp/rs-list.txt.new /tmp/rs-list.txt'
    end
  

Place rs.rb into cookbooks/ohai/files/default/plugins. This plugin will only execute if /tmp/rs-list.txt exists. To test, run

 ohai -d /etc/chef/ohai_plugins

Which should return something similar to:

  
    [
      [
        "s1_mhalligan_com",
        {
          "instance_id": "9998",
          "public_id": "5.5.5.4",
          "private_ip": "10.10.10.9",
          "flavor": "2",
          "image": "104",
          "state": "active"
        }
      ],
      [
        "s2_mhalligan_com",
        {
          "instance_id": "9999",
          "public_id": "5.5.5.5",
          "private_ip": "10.10.10.10",
          "flavor": "2",
          "image": "104",
          "state": "active"
        }
      ],
    ]
  

Note that the periods in the fqdn had to be replaced with underscores because of the way you address values in a Mash.

Something went wrong with that request. Please try again.