Skip to content

Instantly share code, notes, and snippets.

View dhoer's full-sized avatar

Dennis Hoer dhoer

  • Zoox
  • San Francisco Bay Area
View GitHub Profile

Rancher on Mac 10.15.x+

Prerequisites

Helm and kubctl installed

brew install helm
brew install kubectl

Kubernetes docker-destkop enabled and 8gb of memory configured in preferences

@dhoer
dhoer / gist:db1034205bcaeaa689d3d8817b5555e4
Created September 8, 2017 21:18
choco call to powershell failing
```
Running Start-ChocolateyProcessAsAdmin -statements '& C:\ProgramData\chocolatey\lib\win10-initial-setup-script\tools\Win
10-Initial-Setup-Script-2.7\Win10.ps1 -preset C:\ProgramData\chocolatey\lib\win10-initial-setup-script\tools\Win10-Initi
al-Setup-Script-2.7\test\WinServer2016-ApplyAll.preset'
Test-ProcessAdminRights: returning True
Elevating permissions and running powershell block:
$noSleep = $False
#$env:ChocolateyEnvironmentDebug='false'
#$env:ChocolateyEnvironmentVerbose='false'
& import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1' -Verbose:$false | Out-Null;
conf = {}.merge(node['cookbook']['conf']) # a workaround for Chef dsl not supporting clone or deep copy

ruby_block 'keep sensitive values separate from conf attributes' do
  block do
    data_bag_app = node['cookbook']['data_bag']
    mysql_bag = Chef::EncryptedDataBagItem.load(data_bag_app, 'mysql')
    aws_bag = Chef::EncryptedDataBagItem.load(data_bag_app, 'aws')

 conf.merge!(
@dhoer
dhoer / Chef templates with sensitive data.md
Last active June 13, 2016 18:13
Chef templates with sensitive data

Here is how to pass sensitive data to a template and yet make it easy to dynamically add non-sensitive attributes. Have non-sensitive attributes follow this pattern: node[‘cookbook’][‘collection’][‘value_1’] = ‘value1’ where collection contains a collection of one or more attributes (one level deep). e.g.,

default['mycookbook']['conf']['db_driver'] = 'com.mysql.jdbc.Driver'
default['mycookbook']['conf']['db_user'] = 'db_user'
default['mycookbook']['conf']['db_pass'] = nil

Next step is create a separate hash, e.g.,

@dhoer
dhoer / macosx merge
Last active July 11, 2016 05:28
Retain macosx build script (.travis.yml) during merge
git merge --no-commit <merge-branch>
git reset HEAD .travis.yml
git checkout -- .travis.yml
git commit -m 'merged <merge-branch>'
@dhoer
dhoer / sonarqube_on_jenkins.md
Last active December 10, 2015 15:39
SonarQube on Jenkins

Sonar not only doesn't follow semantic versioning with their plugins, their documentation is also poor, and the beauty of simply selecting sonar as post-build action to get reports is gone (sorry Jenkins users!).

Here are the steps to get SonarQube to work today:

  1. Remove SonarQube from Post-build Action
  2. Select 'Prepare SonarQube Scanner environment' checkbox under Build Environment
  3. Change Maven 'Goals and options' under Build to: clean org.jacoco:jacoco-maven-plugin:prepare-agent install
@dhoer
dhoer / winodows_development_with_chef.md
Created December 7, 2015 16:16
Windows development with Chef

Windows development with Chef

General

Platform Version

You can use Ohai's node['platform_version'] version to determine the version, or use Windows Helpers (https://docs.chef.io/windows.html#helpers) to determine platform information. I would recommend using Ohai vs Windows Helpers because helpers will cause rspec testing issues. If you do use helpers, wrap the

@dhoer
dhoer / fetch_jdk.rb
Last active August 29, 2015 14:27
Download Oracle JDK via Ruby
require 'open-uri'
require 'open_uri_redirections'
require 'openssl'
def fetch(url, file, limit = 5)
fail ArgumentError, "too many download failures from #{url}" if limit == 0
load_open_uri_redirections
uri = URI(url)
begin
open(uri,
@dhoer
dhoer / bootstrap-windows.md
Last active January 30, 2018 21:00
Provision and Bootstrap Windows EC2 Instances With Chef

I borrowed this script from Scott Bradley's wonderful blog "Provision and Bootstrap Windows EC2 Instances With Chef," making the following changes:

  1. To make compatible with Windows Server 2012 R2, I added the following firewall rule to the powershell script section:

    netsh advfirewall firewall add rule name="WinRM in" protocol=TCP dir=in profile=any localport=5985 remoteip=any localip=any action=allow

  2. Used knife.rb instead of using AWS API credentials

  3. Added security-group-ids and subnet flags to provision to ec2 VPC

@dhoer
dhoer / dep.rb
Last active January 2, 2016 02:59
Resolves Chef cookbook dependencies for runlist using Berkshelf, and allows diff against a server.
require 'json'
require 'oliver/logging'
require 'chef/knife/bootstrap'
class Dep
class << self
include Logging
def list(deployment_name, knife_config_path, instance_details, options)