Skip to content

Instantly share code, notes, and snippets.

@dblessing
dblessing / dependencies
Created April 7, 2015 19:27
Gem versions
[root@provisioner gems#] /opt/chef/embedded/bin/gem dependency
Gem activesupport-3.2.21
i18n (>= 0.6.4, ~> 0.6)
multi_json (~> 1.0)
Gem akami-1.3.0
gyoku (>= 0.4.0)
mocha (~> 0.13, development)
nokogiri (>= 0)
rake (~> 10.0, development)
================================================================================
Error executing action `create` on resource 'aws_route_table[AZ1_Private_w_NAT_Route_dev] (rtb-f8a48f9d)'
================================================================================
NoMethodError
-------------
undefined method `enable_vgw_route_propagation' for <AWS::EC2::RouteTable id:rtb-f8a48f9d>:AWS::EC2::RouteTable
Resource Declaration:
---------------------
@dblessing
dblessing / vpc.rb
Last active August 29, 2015 14:18
VPN Complete Example
# Below is adjusted to take the SDK options in to account
aws_vpn_gateway 'virtual-gateway' do
vpc 'top'
end
aws_customer_gateway 'customer-gateway' do
bgp_asn '65000' # optional...
public_ip 'x.x.x.x'
end
@dblessing
dblessing / gist:9f711d11dfe8743c17e9
Last active August 29, 2015 14:17
Stub IO.read
require 'spec_helper'
describe KnifeCookbookDoc::AttributesModel do
describe '#load_descriptions' do
before do
allow(IO).to receive(:read).with('attributes/default.rb').and_return(attributes)
end
let(:attributes) {
<<EOS
#<> Single line comment
2015-02-12_23:46:23.44859 Completed 500 Internal Server Error in 21ms
2015-02-12_23:46:23.44919 ** [Raven] Event not sent due to excluded environment: production
2015-02-12_23:46:23.45094
2015-02-12_23:46:23.45095 Module::DelegationError (Permission#organization delegated to entity.organization, but entity is nil: #<Permission id: "294034ba-578b-4790-8acd-dbb10c2b0705", properties: nil, name: "create", organization_id: "my_org", type: "Permission", search: "'creat':1", metaphone: "KRT">):
2015-02-12_23:46:23.45095 app/models/entities/permission.rb:19:in `rescue in organization'
2015-02-12_23:46:23.45096 app/models/entities/permission.rb:19:in `organization'
2015-02-12_23:46:23.45096 app/models/entity.rb:42:in `manage'
2015-02-12_23:46:23.45097 app/controllers/activities_controller.rb:9:in `index'
2015-02-12_23:46:23.45097
2015-02-12_23:46:23.45097
2015-01-19 10:30:50,698 [qtp2142065269-33] WARN com.dtolabs.rundeck.core.common.UpdateUtils - Unable to set modification time of temp file: /var/rundeck/projects/Intranet-Staging/var/urlResourceModelSourceCache/5ef9790389bf858d2f38f5929efea687efc7f1ac.temp.new
2015-01-19 10:30:51,741 [qtp2142065269-33] ERROR com.dtolabs.rundeck.core.resources.ExceptionCatchingResourceModelSource - [ResourceModelSource: 1.url (URL Source), project: Intranet-Staging]
com.dtolabs.rundeck.core.resources.ResourceModelSourceException: Error requesting URL Resource Model Source: http://puppet3.example.com:8141: com.dtolabs.rundeck.core.common.FileUpdaterException: Unable to retrieve content: result code: 500 Internal Server Error
at com.dtolabs.rundeck.core.resources.URLResourceModelSource.getNodes(URLResourceModelSource.java:287)
at com.dtolabs.rundeck.core.resources.ExceptionCatchingResourceModelSource.getNodes(ExceptionCatchingResourceModelSource.java:45)
at com.dtolabs.rundeck.core.common.FrameworkProject.getNodeSet(Framewor
# Assuming
template '/etc/foo' do
notifies :restart, 'service[apache2]'
end
# I can do this in ChefSpec
resource = chef_run.template('/etc/foo')
expect(resource).to notify('service[apache2]').to(:restart).delayed
# Now, if I create a custom LWRP and have this:
Given:
it { is_expected.to render_file('/etc/file').with_content('string1') }
RSpec (documentation) outputs as:
"should render file "/etc/file" with content "string1"
@dblessing
dblessing / gist:d7266db623f7a02cb3a2
Created January 2, 2015 20:13
ChefSpec test multiple content pieces
[
'string1',
'string2',
'string3',
'string4'
].each do |content|
it do
is_expected.to render_file('/etc/file')
.with_content(content)
end
require 'spec_helper'
describe 'bke_base::user' do
before do
stub_data_bag('users_ops').and_return(['op1'])
stub_data_bag_item('users_ops', 'op1').and_return(
id: 'op1',
uid: 1001,
comment: 'Operations User 1',
groups: %W{wheel, op1}