Skip to content

Instantly share code, notes, and snippets.

View tyler-ball's full-sized avatar

Tyler Ball tyler-ball

View GitHub Profile
@tyler-ball
tyler-ball / audit.md
Created August 13, 2015 13:50
chef provisioning output when running a failing audit recipe on provisioned node

recipe:

control_group "group" do
  control "foo" do
    it "should fail" do
      expect(1).to eq(2)
    end
  end
end
[1] pry(#<Chef::Provisioning::AWSDriver::Driver>)> actual_elb.subnets
=> [<AWS::EC2::Subnet id:subnet-5bbda12f>, <AWS::EC2::Subnet id:subnet-eacb348f>, <AWS::EC2::Subnet id:subnet-fa1e21bc>]
[2] pry(#<Chef::Provisioning::AWSDriver::Driver>)> actual_elb.availability_zones.to_a
=> [<AWS::EC2::AvailabilityZone name:us-west-2a>, <AWS::EC2::AvailabilityZone name:us-west-2c>, <AWS::EC2::AvailabilityZone name:us-west-2b>]
[3] pry(#<Chef::Provisioning::AWSDriver::Driver>)> elb.client.detach_load_balancer_from_subnets(load_balancer_name: actual_elb.name, subnets: ['subnet-5bbda12f'])
=> {:subnets=>["subnet-fa1e21bc", "subnet-eacb348f"], :response_metadata=>{:request_id=>"1807c203-be20-11e4-b84f-7bbb914bda43"}}
[4] pry(#<Chef::Provisioning::AWSDriver::Driver>)> actual_elb = load_balancer_for(lb_spec)
=> <AWS::ELB::LoadBalancer name:tyler-test-lb>
[5] pry(#<Chef::Provisioning::AWSDriver::Driver>)> actual_elb.availability_zones.to_a
=> [<AWS::EC2::AvailabilityZone name:us-west-2a>, <AWS::EC2::AvailabilityZone name:us-wes
@tyler-ball
tyler-ball / gist:f7c16e814265f34260e9
Last active March 14, 2016 23:15
Test Kitchen Shared Examples

Create the following folder structure in your cookbook:

test
└── integrationq
    ├── helpers
    │   ├── serverspec
    │   │   ├── shared_serverspec_tests
    │   │   │   └── shared_tests2.rb
    │   │   └── spec_helper.rb
@tyler-ball
tyler-ball / gist:dd98f8f99f461ee03528
Last active August 29, 2015 14:10
error_data examples

example:

  it "should have mysql service" do
    expect(service("mysql")).to be_enabled
    expect(service("mysql")).to be_running
  end

example_data:

@tyler-ball
tyler-ball / gist:82be00c5c88fbdfe0952
Last active August 29, 2015 14:10
Audit mode examples - error on duplicate controls blocks

Two controls blocks cannot be named the same. Doing so will raise a compilation error as seen with the following code:

# cookbook: example
# recipe: default
controls "mysql audit" do

  control "mysql package" do
    it "should be installed" do
      expect(package("mysql")).to be_installed.with_version("5.6")
    end
@tyler-ball
tyler-ball / gist:a877cf61b62e8ee937d5
Last active August 29, 2015 14:10
Audit mode examples - multiple controls blocks and include_recipe
# cookbook: example
# recipe: mysql
controls "mysql audit" do

  control "mysql package" do
    it "should be installed" do
      expect(package("mysql")).to be_installed.with_version("5.6")
    end
 end
@tyler-ball
tyler-ball / force_push.md
Last active August 29, 2015 14:10
2014-11-19 - `Chef` repo force pushed to master

19 Nov 2014 - Chef repo force pushed to master

Start every PM stating the following

  1. This is a blameless Post Mortem.
  2. We will not focus on the past events as they pertain to "could've", "should've", etc.
  3. All follow up action items will be assigned to a team/individual before the end of the meeting. If the item is not going to be top priority leaving the meeting, don't make it a follow up item.

Incident Leader: Tyler Ball

@tyler-ball
tyler-ball / gist:caccc555792a30332093
Last active August 29, 2015 14:06
Proposed module for defining to_json on Chef objects
module Chef::JSONable
# Serialize this object as a hash
def to_json(*a)
Chef::JSONCompat.to_json(for_json, *a)
end
def for_json
raise "You must define `for_json` in your JSONable class"
# Alternatively, return self?
end
class Chef
class Knife
module DataBagSecretOptions
include Mixlib::CLI
option :secret,
:short => "-s SECRET",
:long => "--secret ",
:description => "The secret key to use to encrypt data bag item values",
:proc => Proc.new { |s| Chef::Config[:knife][:secret] = s }