Skip to content

Instantly share code, notes, and snippets.

View vinyar's full-sized avatar

Mr. Pacman vinyar

  • Launch Consulting
  • Seattle
View GitHub Profile
@vinyar
vinyar / 1 - pega parser.rb
Last active August 29, 2015 14:27
Pulling out pega space requirements via ruby
require 'nokogiri'
file = File.open('/pega_cookbook/files/default/prpcUtils.xml')
doc = Nokogiri::XML(f)
needed = doc.xpath("//pega:hasenoughspace/@needed").text
@vinyar
vinyar / chef-shell output.rb
Last active August 26, 2015 18:00
chef-shell output
alex was here
Last login: Mon Aug 17 17:51:24 on ttys004
alexvinyar@seavinyar02 ~ $ chef-shell
loading configuration: none (standalone session)
Session type: standalone
Loading.......done.
This is the chef-shell.
Chef Version: 12.3.0
@vinyar
vinyar / gitconfig.sh
Created October 28, 2015 18:38
Git config file
# set your user tokens as environment variables, such as ~/.secrets
# See the README for examples.
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
same run in debug mode (pem/id/etc.. scrubbed)
Please let me know if you need a specific ID inside XML
```ruby
INFO: Using configuration from D:/base/.chef/knife.rb
INFO: validating...
DEBUG: Looking for key azure_mgmt_cert and found value
DEBUG: Looking for key azure_publish_settings_file and found value D:\base\.chef\myazure.publishsettings
DEBUG: Looking for key azure_publish_settings_file and found value D:\base\.chef\myazure.publishsettings
DEBUG: Looking for key azure_subscription_id and found value 11111111-660b-4165-9bff-11111111111
@vinyar
vinyar / check.md
Created November 14, 2015 01:37 — forked from kwilczynski/check.md
Recipe / Role check in Chef

If you want to check whether a node run_list includes a specific role (upon expansion), then you could use role? method on the Node object:

node.role?('name')

Alternatively, you can see whether either would work for you:

node.roles.include?('name')

node.run_list?('role[name]')

bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
yum install -y wget
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://rbel.co/rbel5
rpm -Uvh rbel5
yum install -y rubygem-chef
'
@vinyar
vinyar / vault_examples.rb
Created April 4, 2016 08:29 — forked from afiune/vault_examples.rb
Chef Bootstrap with Chef Vaults
# Chef Bootstrap with Chef Vaults
# Required chef version: 12
# Single Vault Item
$ knife bootstrap node1 -N node1 --sudo -r 'recipe[cookbook::default]' --bootstrap-vault-item 'vault:item'
# Multiple Vault through JSON
$ knife bootstrap node1 -N node1 --sudo -r 'recipe[cookbook::default]' --bootstrap-vault-json {"vault1":"item1","vault2":"item2"}
# Multiple Vault through File
@vinyar
vinyar / pre_create_command.yml
Created April 5, 2016 12:56
kitchen precreate command
# pre_create_command = <<-EOH
# if Vagrant.has_plugin?('vagrant-cachier')
# unless (is_windows)
# puts 'hello world'
# config.cache.scope = :box
# config.cache.enable :generic, {
# 'wget' => { cache_dir: '/var/cache/wget' }
# }
# end
# end

How do I set up compliance checks for an application or cookbook pipeline in delivery?

Delivery version: 0.4.109 or higher
Inspec version: 0.16.0 or higher

1) Create a compliance pipeline of a profile you are interested in, or use an existing one.

2) Configure the application or cookbook to depend on that profile.

@vinyar
vinyar / resources.md
Created May 6, 2016 05:01 — forked from lamont-granquist/resources.md
Three Ways to Write Correct Chef Resources

12.5 style custom resources

This is by far the most recommended way of writing resources for all users. There are two gotchas which we're working through:

  1. For helper functions that you used to write in your provider code or used to mixin to your provider code, you have to use an action_class do ... end block.
  2. The 12.5 resources allow for a shorthand notation in provider code where you can refer to properties by their bare name my_property and it works most of the time. Since it does not work all the time (because of the way ruby scopes things), its recommended to stick to referring to properties by new_resource.my_property.

You cannot subclass, and must use mixins for code-sharing (which is really a best practice anyway -- e.g. see languages like rust which do not support subclassing).

in resources/whatever.rb: