Skip to content

Instantly share code, notes, and snippets.

@lorengordon
lorengordon / gist:88e0fc8ee8f9fe312b2f
Last active November 10, 2015 21:34
Salt state to extract zip archive on Windows
{%- load_yaml as myarchive %}
name: 'C:\minionpath\to\save\my\archive.zip'
source: 'path/from/the/salt/master/to/my/archive.zip'
source_hash: 'hash_of_source_archive'
extract_dir: 'C:\minionpath\to\extract\my\archive.zip\'
{%- endload %}
# Get the zip archive
GetZipArchive:
@lorengordon
lorengordon / win_lgpo.py
Last active February 4, 2016 22:01
Salt execution module to manage local group policy via Apply_LGPO_Delta.exe
# -*- coding: utf-8 -*-
r'''
Manage Local Policy Group Policy Objects on Windows
This module uses ``Apply_LGPO_Delta.exe``, the license for which restricts it
from being distributed by a third-party application. According to Microsoft[1],
users must obtain it from the site below[2] and may then distribute it within
their own organization.
[1] https://blogs.technet.microsoft.com/fdcc/2010/03/24/sample-files-for
#cloud-config
bootcmd:
- |
/bin/bash <<-'EOS'
#!/bin/bash
exec > >(tee /root/log.txt)
exec 2>&1
set -x
set -e
if [ -e /new ]; then
packer : 2016/04/21 10:35:09 [INFO] Packer version: 0.10.0 0d4ee09ea5b0458d6e85a52ae82eb5add16bf6bb
At line:1 char:1
+ packer build .\packer-issue-3399.json *> packer-issue-3399.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (2016/04/21 10:3...82eb5add16bf6bb:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
2016/04/21 10:35:09 Packer Target OS/Arch: windows amd64
2016/04/21 10:35:09 Built with Go Version: go1.6
@lorengordon
lorengordon / packer-download-file.json
Last active April 26, 2016 11:58
packer-download-file-create-directory
{
"builders": [
{
"type": "amazon-ebs",
"ami_name": "packer-download-file",
"communicator": "ssh",
"instance_type": "t2.micro",
"region": "us-east-1",
"source_ami": "ami-1c221e76",
"ssh_username": "centos",
@lorengordon
lorengordon / tmpfsroot-el6.sh
Created June 20, 2016 13:36
Create AWS AMIs from Scratch
#!/bin/bash
#
# Pivot the root partition to a tmpfs mount point so that the root volume can
# be re-partitioned.
#
##############################################################################
set -x
set -e
# Prevent selinux from interfering
@lorengordon
lorengordon / .travis.yml
Last active August 26, 2016 10:51
Update __version__ for travis deployment to testpypi
before_deploy:
- python $TRAVIS_BUILD_DIR/ci/travis_set_build.py --file-paths '("<project>", "__init__.py")' --skip "$TRAVIS_TAG"
deploy:
- provider: pypi
server: https://testpypi.python.org/pypi
distributions: sdist
user: <username>
password:
secure: <encrypted_password>
skip_cleanup: true
@lorengordon
lorengordon / Manage-R53RecordSet.ps1
Last active May 30, 2023 11:18
PowerShell Script to Create/Delete/Update AWS Route53 Record Set
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
[String] $HostedZoneId,
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
[ValidateSet("CNAME","A","AAAA","MX","TXT","PTR","SRV","SPF","NS","SOA")]
[String] $Type,
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
@lorengordon
lorengordon / salt-development-install.txt
Last active June 30, 2017 13:24
Install salt for development on EL6/7
sudo -i
REPO="https://github.com/<your-fork>/salt"
BRANCH="<your-branch>"
# EL6
#yum -y install centos-release-SCL
#yum -y install python27 python27-python-devel python27-python-setuptools python27-python-tools python27-python-virtualenv
#yum -y --enablerepo=epel install git gcc gcc-c++ swig openssl-devel python27-python-pip
#scl enable python27 bash
@lorengordon
lorengordon / TfExternal.py
Created September 22, 2017 18:32
Python helper for a Terraform External provider
import json
class TfExternal(object):
"""Wrap Terraform External provider."""
@staticmethod
def query_args(obj):
"""Load json object from stdin."""
return {} if obj.isatty() else json.load(obj)