Skip to content

Instantly share code, notes, and snippets.

knife azure server create --azure-dns-name aos-chef-poc-01 --azure-vm-size Small `
--azure-source-image 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201409.01-en.us-127GB.vhd' --azure-service-location 'West US' `
--winrm-user myadmin --winrm-password 'P@ssw0rd' --bootstrap-protocol winrm --distro 'windows-chef-client-msi'
@mlapida
mlapida / Azure+ChefVM.ps1
Last active August 29, 2015 14:11
Azure + Chef VM Creation
New-AzureVMConfig -ImageName $image.ImageName -Name $VMName -InstanceSize Small -AvailabilitySetName $serviceName |
#Add VM to a domain
Add-AzureProvisioningConfig -EnableWinRMHttp -AdminUsername $VMUserName -Password $VMPassword -WindowsDomain -DomainUsername $DomainUserName -DomainPassword $DomainPassword -Domain $domain -JoinDomain $domain |
#Add a load balanced endpoint
Add-AzureEndpoint -Name "HTTP" -Protocol tcp -LocalPort "80" -LBSetName "HTTPforChef" -PublicPort "80" -DefaultProbe |
Add-AzureDataDisk -CreateNew -DiskSizeInGB 1023 -DiskLabel "Data" -LUN 0 |
Set-AzureSubnet -SubnetNames "Subnet-1" |
#Install the Chef extension
Set-AzureVMChefExtension -ValidationPem $chefpem -Windows -ClientRb $chefclient -RunList $runlist |
New-AzureVM -ServiceName $serviceName -VNetName $vnetName -Location "South Central US" -WaitForBoot
@mlapida
mlapida / AzureVMConfigXML.ps1
Created December 30, 2014 16:10
Azure: VM Export to XML
$subscription = "[Subscription here]"
Select-AzureSubscription -SubscriptionName $subscription
$cloudservice = '[Cloud Service Here]'
Get-AzureVM -ServiceName $cloudservice | foreach {
$path = 'c:\vms' + $_.Name + '.xml'
Export-AzureVM -ServiceName $cloudservice -Name $_.Name -Path $path
}
@mlapida
mlapida / Get-Hero.ps1
Last active August 29, 2015 14:16
A PowerShell script to spit out a random Marvel Superhero when called. This is great for random server naming and automation.
#Hat Tip http://www.virtuallyghetto.com/2014/02/having-some-fun-with-marvel-comics-api.html
#Instructions: Aquire a Marvel API key from https://developer.marvel.com and place them in lines 63 & 64. Import this module into a VM build script and call Get-Hero to grab a random Marvel super hero.
#Imported Get-Hash function (credits http://dbadailystuff.com/2013/03/11/get-hash-a-powershell-hash-function/)
function Get-Hash
{
Param
(

Keybase proof

I hereby claim:

  • I am mlapida on github.
  • I am mlapida (https://keybase.io/mlapida) on keybase.
  • I have a public key whose fingerprint is 4FA6 EF78 A865 B98E 3004 9A74 1FB2 D101 B85F 9F75

To claim this, I am signing this object:

@mlapida
mlapida / sleepsensor.cpp
Created February 26, 2016 17:17
A small Particle firmware for sending movement data to a web-hook.
// Make sure to include the spcial library for the internet button
#include "InternetButton/InternetButton.h"
// Create a Button named b. It will be your friend, and you two will spend lots of time together.
InternetButton b = InternetButton();
int ledOldPos = 0;
char ledPosTrust[5];
int moveCount = 0;
int loopCount =0;
@mlapida
mlapida / PlexToAlexa-Lambda.py
Last active December 7, 2017 08:00
This is my attempt to get Alexa to return Plex's On Deck and Recently Downloaded lists. It's not the prettiest, but Plex's API isn't the best at the moment. Step-by-step blog post may be found here: http://mlapida.com/thoughts/plex-alexa-interacting-with-your-media-server-through-voice
from __future__ import print_function
import urllib
import urllib2
import xml.etree.ElementTree
import logging
#enable basic logging to CloudWatch Logs
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@mlapida
mlapida / azureVMAgentCheck.ps1
Created January 1, 2015 18:42
Azure: Check VM Agent Health
param (
# Define Parameters
[parameter(Mandatory=$true)]
[string]$sub,
[parameter(Mandatory=$true)]
[string]$vm,
[parameter(Mandatory=$true)]
[string]$service
@mlapida
mlapida / SleepEndpoint-Lambda.py
Last active June 6, 2019 04:58
A Lambda Function for receiving data from an API Endpoint and sending it to a DynamoDB table.
from __future__ import print_function
import logging
import boto3
from datetime import *
from boto3.dynamodb.conditions import Key, Attr
# enable basic logging to CloudWatch Logs
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@mlapida
mlapida / CloudWatchLogsKinesisFirehose-Lambda.py
Last active October 3, 2019 01:01
A short Lambda Function the can be sent CloudWatch Logs (in the case Flow Logs) and send them to Kinesis Firehose for storage in S3. A full writeup can be found on my site http://mlapida.com/thoughts/exporting-cloudwatch-logs-to-s3-lambda
import boto3
import logging
import json
import gzip
from StringIO import StringIO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
client = boto3.client('firehose')