Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 moonshine
Octocat-spinner-32 spec
Octocat-spinner-32 README.mkdn
README.mkdn

Moonshine Ordered Hash

Some Moonshine users may have noticed unnecessary restarts of services or re-configuration of various resources.

The Problem

Currently shadow_puppet uses Ruby 1.8's built-in Hash for resources. The downside to this is that Hash in Ruby 1.8 is inherently unordered. This can lead to scenarios where a Hash is "different" only because the ordering of keys differs. This behavior is undesirable as it can cause unnecessary restarts of services, etc.

Example

Let's say you were doing something like this in your config/moonshine.yml:

:hosts:
  :127.0.0.1: localhost
  :4.2.2.1: dns

If you are generating a configuration file from this hash using a pattern like:

<% configuration[:hosts].each do |key, value| %>
  <%= key %> = <%= value %>
<% end %>

This file may be regenerated even though the configuration hasn't changed. This is due to Ruby 1.8's Hashes being unordered, meaning that YAML stanzas loaded into a Hash may change ordering at random.

Installation

Run:

script/plugin install git://github.com/railsmachine/moonshine_ordered_hash.git --force

Deploy.

The Fix

We understand that overriding the Hash class with the ActiveSupport::OrderedHash is pretty unorthodox, however in our testing we've yet to hit any problems with this change. You are safe to test this out in your existing deployments, however I strongly encourage doing a few deploys to staging before rolling it out to production, just to be extra safe.

Going Forward

Once we are confident that this change works the way we want, we will evaluate making it the default in shadow_puppet itself.

Something went wrong with that request. Please try again.