Skip to content

Instantly share code, notes, and snippets.

View grdnrio's full-sized avatar

Joe Gardiner grdnrio

View GitHub Profile
@grdnrio
grdnrio / win-bootstrap.ps1
Last active August 31, 2023 06:57
Powershell bootstrap script
## Set host file so the instance knows where to find chef-server
$hosts = "1.2.3.4 hello.example.com"
$file = "C:\Windows\System32\drivers\etc\hosts"
$hosts | Add-Content $file
## Download the Chef client
$clientURL = "https://packages.chef.io/files/stable/chef/12.19.36/windows/2012/chef-client-12.19.36-1-x64.msi"
$clientDestination = "C:\chef-client.msi"
Invoke-WebRequest $clientURL -OutFile $clientDestination
@grdnrio
grdnrio / .travis.yml
Last active March 23, 2017 08:10
Travis file for verifying YAML CFTs
language: ruby
git:
submodules: false
before_install:
- echo "Installing test gems"
- gem install yaml-lint
# skip install step
@grdnrio
grdnrio / automatecluster.parameters.local.json
Created April 3, 2017 12:30
ARM Automate deployment - local parameters example
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"prefix": {
// Prefix to be assigned to all machines
"value": "test"
},
On node 1 you will need something like this:
# package installation and configuration
# set an attribute key as the last action
node.set['master']['key'] = 6B0FEJFM
Then on node 2 you are looking for the key that you set during node 1’s run:
# all the node configuration up to master node requirement / dependency
@grdnrio
grdnrio / kitchen.yml
Last active May 15, 2017 10:56
Example Windows kitchen.yml
---
driver:
name: ec2
aws_ssh_key_id: your_key
region: eu-west-1
availability_zone: b
require_chef_omnibus: true
instance_type: m1.small
associate_public_ip: true
interface: dns
@grdnrio
grdnrio / .kitchen.local.yml
Last active June 13, 2017 15:07
Example kitchen file for Windows testing
---
driver:
name: ec2
aws_ssh_key_id: my_key
region: eu-west-1
availability_zone: b
require_chef_omnibus: true
instance_type: m1.small
associate_public_ip: true
interface: dns
@grdnrio
grdnrio / dotnet-install-sample1.rb
Created June 22, 2017 08:45
.NET package installation sample 1
reboot '.Net Install' do  
  reason 'Need to reboot after .NET installation'
  action :nothing
end
 
if version_arr[6][:data] != 394_271  
  package '.NET 4.6.1' do
    source 'https://download.microsoft.com/download/E/4/1/E4173890-A24A-4936-9FC9-AF930FE3FA40/NDP461-KB3102436-x86-x64-AllOS-ENU.exe'
    installer_type :custom
    action :install
@grdnrio
grdnrio / dotnet-install-sample2.rb
Created June 22, 2017 08:46
Installing .net with Chef - specific version check
reboot '.Net Install' do  
  reason 'Need to reboot after .NET installation'
  action :nothing
end
 
version_arr = registry_get_values('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', :x86_64)
 
if version_arr[6][:data] != 394_271  
  package '.NET 4.6.1' do
    source 'https://download.microsoft.com/download/E/4/1/E4173890-A24A-4936-9FC9-AF930FE3FA40/NDP461-KB3102436-x86-x64-AllOS-ENU.exe'
@grdnrio
grdnrio / secedit-custom.rb
Created June 22, 2017 09:37
Secedit.exe custom resource example
resource_name :security_policy
default_action :configure
property :policy_template, String, required: false, default: 'C:\Windows\security\templates\chefNewPolicy.inf'
property :database, String, required: false, default: 'C:\Windows\security\database\chef.sdb'
property :log_location, String, default: 'C:\Windows\security\logs\chef-secedit.log'
action :configure do
if node['platform'] == 'windows'
@grdnrio
grdnrio / sec-pol-metadata.rb
Created June 22, 2017 09:41
Include windows security policy
name 'windows-hardening'
maintainer 'Joe Gardiner'
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Hardening cookbook for Windows 2012 R2'
long_description 'Remediates critical issues identified by the DevSec Windows baseline'
version '0.9.0'
supports 'windows'
depends 'windows-security-policy'