Skip to content

Instantly share code, notes, and snippets.

def get_chef_zero_server_pid(port)
pid = ""
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
if is_windows
process = []
stdin, stdout = Open3.popen3("netstat -ao -p TCP -n")
stdout.each_line.select do |l|
if l.split[1] =~ /:#{port}/
C:\Users\Bryan\github\tk-windows>bundle exec kitchen test
-----> Starting Kitchen (v1.3.0)
-----> Cleaning up any prior instances of <default-windows2012r2-cloud>
-----> Destroying <default-windows2012r2-cloud>...
Finished destroying <default-windows2012r2-cloud> (0m0.00s).
-----> Testing <default-windows2012r2-cloud>
-----> Creating <default-windows2012r2-cloud>...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'windows2012r2_cloud'...
==> default: Matching MAC address for NAT networking...
@txag1995
txag1995 / New-VM.ps1
Last active March 12, 2017 21:28
PowerCLI Example
$Server = "VCENTER SERVER"
$datacenter = Get-Datacenter -Name "DATACENTER NAME"
$cluster = Get-Cluster -Name "CLUSTER NAME" -Location $datacenter
$TemplateName = "TEMPLATE NAME"
$Template = Get-Template -Name $TemplateName -Location $datacenter
$Datastore = Get-DatastoreCluster -Name "DATASTORE NAME"
$ResourcePool = Get-ResourcePool -Name "RESOURCE POOL NAME" -Location $cluster
$folder = "FOLDER NAME"
$vmname = "VM NAME"
source "https://rubygems.org"
gem "berkshelf"
group :test do
gem "chefspec"
gem "foodcritic"
gem "rubocop"
gem "guard"
gem "guard-rspec"
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "<USERNAME>"
client_key "#{current_dir}/user.pem"
chef_server_url "https://api.opscode.com/organizations/<ORGANIZATION>"
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path ["#{current_dir}/../cookbooks"]
@txag1995
txag1995 / SporkBump
Last active January 28, 2016 18:13
knife spork bump sample-cookbook $BUMP_LEVEL
COOKBOOK_VERSION=v`sed -n "s/^ *version *[\'\"]\(.*\)[\'\"]/\1/p" cookbooks/$JOB_NAME/metadata.rb`
echo COOKBOOK_VERSION=$COOKBOOK_VERSION >> build.properties
cd cookbooks/$JOB_NAME
if [ -b "Berksfile.lock" ]
then
berks update sample-cookbook
else
berks install
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.11">
<projectUrl>https://github.com/txag1995/sample-cookbook/</projectUrl>
</com.coravy.hudson.plugins.github.GithubProjectProperty>
</properties>
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.9.1">
<projectUrl>https://github.com/txag1995/sample-cookbook/</projectUrl>
</com.coravy.hudson.plugins.github.GithubProjectProperty>
</properties>
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.11">
<projectUrl>https://github.com/txag1995/chef-repo/</projectUrl>
</com.coravy.hudson.plugins.github.GithubProjectProperty>
<hudson.model.ParametersDefinitionProperty>
@txag1995
txag1995 / chef_identity.rb
Created April 21, 2015 19:42
Chef Identity
orgs = {}
jenkins_home = node['jenkins']['master']['home']
chef_orgs.each do |org|
# Create a has with org info so we can create the chef-identity
# configuration file.
org_info = {
# 'name' => org['id'],
'key' => org['pem'],