Skip to content

Instantly share code, notes, and snippets.

View mefellows's full-sized avatar

Matt Fellows mefellows

View GitHub Profile
@mefellows
mefellows / bootstrap.ps1
Last active April 6, 2018 01:06
Bootstrap Vagrant + Packer for Windows Development and Automation
try {
Write-Host -ForegroundColor green "Bootstrapping machine ${remoteHost}"
Write-Host "Setting up package management and installing required packages for Dev."
# Install Choco (if not already installed) + required packages
if ( (Get-Command "choco" -errorAction SilentlyContinue) ) {
Write-Host "Chocolatey already installed. Skipping."
} else {
Write-Host "Installing Chocolatey"
$wc=new-object net.webclient; $wp=[system.net.WebProxy]::GetDefaultProxy(); $wp.UseDefaultCredentials=$true; $wc.Proxy=$wp; iex ($wc.DownloadString('https://chocolatey.org/install.ps1'))
@mefellows
mefellows / MyWebsite.ps1
Last active March 1, 2021 15:07
Machine Factories with Windows Part 1: Local Development with Vagrant
Configuration MyWebsite
{
param ($MachineName)
Import-DscResource -Module MyWebapp
Import-DscResource -Module cNetworking
Node $MachineName
{
WindowsFeature IIS
@mefellows
mefellows / boxstarter.ps1
Last active September 12, 2016 17:27
TC 2012r2 Build Agent - BoxStarter
# START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/mefellows/6c9faf342817b8412b76/raw/953665c62ce975af136cf2e3e8b93beb3a395b9c/boxstarter.ps1
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
Disable-UAC
Disable-InternetExplorerESC
cinst git.install -y -params '"/GitAndUnixToolsOnPath"'
cinst virtualbox -y
cinst vagrant -y
@mefellows
mefellows / build.log
Created April 14, 2015 11:56
Packer Community - Windows Plugins: Issue 43 Repro
2015/04/14 21:27:31 [INFO] Packer version: 0.7.5 1b07d7eb5efd51dec5407e82240166d1fe8d6c85+CHANGES
2015/04/14 21:27:31 Packer Target OS/Arch: darwin amd64
2015/04/14 21:27:31 Built with Go Version: go1.4.1
2015/04/14 21:27:31 [DEBUG] Discovered plugin: amazon-chroot = /Users/mfellows/go/bin/packer-builder-amazon-chroot
2015/04/14 21:27:31 [DEBUG] Discovered plugin: amazon-ebs = /Users/mfellows/go/bin/packer-builder-amazon-ebs
2015/04/14 21:27:31 [DEBUG] Discovered plugin: amazon-instance = /Users/mfellows/go/bin/packer-builder-amazon-instance
2015/04/14 21:27:31 [DEBUG] Discovered plugin: amazon-windows-ebs = /Users/mfellows/go/bin/packer-builder-amazon-windows-ebs
2015/04/14 21:27:31 [DEBUG] Discovered plugin: digitalocean = /Users/mfellows/go/bin/packer-builder-digitalocean
2015/04/14 21:27:31 [DEBUG] Discovered plugin: docker = /Users/mfellows/go/bin/packer-builder-docker
2015/04/14 21:27:31 [DEBUG] Discovered plugin: googlecompute = /Users/mfellows/go/bin/packer-builder-googlecompute
@mefellows
mefellows / ChocolateyInstall.ps1
Last active August 29, 2015 14:19
Machine Factories with Windows Part 2: AWS Environments
# This is a workaround to deal with the fact that
# 1) New Chocolatey now sets the UI Culture to invariant
# 2) DSC Tries to Import-LocalizedData (line 57 of C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1)
# which uses implicit UI Culture, but of course is not available in this mode.
If ( -not ( Test-Path "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.Resource.psd1" ) ) {
cmd /c mklink C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.Resource.psd1 C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\en-US\PSDesiredStateConfiguration.Resource.psd1
}
$outputPath = $env:TEMP
$webAppPath = $(Join-Path $env:chocolateyPackageFolder "/lib/_PublishedWebsites/ShortUrlWebApp")
@mefellows
mefellows / credulous.ps1
Created April 23, 2015 14:24
Credulous Powershell wrapper
If ($args[0] -eq "source" ) {
$res = iex "$credulous source mfellows@onegeek -force" | out-string
Write-Host "Exporting AWS environment into shell"
iex $($res)
If ( $LastExitCode -eq 0) {
Write-Host $res
} else {
Write-Error "Failed to load credentials into environment."
Exit 1
@mefellows
mefellows / ec2ssh.sh
Created May 1, 2015 06:32
AWS EC2 SSH onto an instance with one command, given an instance id
#!/bin/bash
INSTANCE_ID=$1
IP=$(aws ec2 --region $AWS_REGION describe-instances --instance-id $INSTANCE_ID | jq -r .Reservations[0].Instances[0].PrivateIpAddress)
KEYPAIR_NAME=$(aws ec2 --region $AWS_REGION describe-instances --instance-id $INSTANCE_ID | jq -r .Reservations[0].Instances[0].KeyName)
ssh -i ~/.ssh/$KEYPAIR_NAME.pem "ec2-user@$IP"
@mefellows
mefellows / BundleConfig.ps1
Last active December 25, 2023 23:33
Sysprepped Windows AMI using Packer
$EC2SettingsFile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Settings\\BundleConfig.xml"
$xml = [xml](get-content $EC2SettingsFile)
$xmlElement = $xml.get_DocumentElement()
foreach ($element in $xmlElement.Property)
{
if ($element.Name -eq "AutoSysprep")
{
$element.Value="Yes"
}
@mefellows
mefellows / destroy.sh
Last active August 29, 2015 14:20
Machine Factories with Windows Part 3: Terraform your cloud
terraform destroy -var access_key=$AWS_ACCESS_KEY_ID -var secret_key=$AWS_SECRET_ACCESS_KEY --var ami_id=ami-12345678
@mefellows
mefellows / packer.json
Last active August 29, 2015 14:21
Packer - Issue 48 repro
{
"builders": [ {
"type": "virtualbox-windows-ovf",
"name": "vagrantbox",
"source_path": "/Users/mfellows/Downloads//output-virtualbox-iso/packer-virtualbox-iso-1417096689.ovf",
"guest_additions_mode": "disable",
"headless":false,
"boot_wait":"15s",
"winrm_username": "vagrant",
"winrm_password": "vagrant",