Skip to content

Instantly share code, notes, and snippets.

View sammcgeown's full-sized avatar
💭
Playing with GraphQL

Sam McGeown sammcgeown

💭
Playing with GraphQL
View GitHub Profile
@sammcgeown
sammcgeown / GenerateCertificates.sh
Last active August 27, 2020 15:05
Create Self-signed Certificates for Docker TLS using OpenSSL
export HOST="scmg-sc2-docker-host"
export IP="10.176.144.191"
# Condensed from https://docs.docker.com/engine/security/https/#create-a-ca-server-and-client-keys-with-openssl
# Run these commands individually
openssl genrsa -aes256 -out ca-key.pem 4096
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
openssl genrsa -out server-key.pem 4096
openssl req -subj "/CN=$HOST" -sha256 -new -key server-key.pem -out server.csr
echo subjectAltName = DNS:$HOST,IP:$IP,IP:127.0.0.1 >> extfile.cnf
echo extendedKeyUsage = serverAuth >> extfile.cnf
@sammcgeown
sammcgeown / CentOS7
Last active August 27, 2020 16:24
Allow Docker API Remote Access through Firewall
sudo firewall-cmd --state
sudo firewall-cmd --permanent --zone=public --add-rich-rule='
rule family="ipv4"
source address="[vRealize Appliance IP/Cloud Proxy IP]/32"
port protocol="tcp" port="2376" accept'
sudo firewall-cmd --permanent --zone=public --add-rich-rule='
rule family="ipv4"
source address="[vRealize Appliance IP/Cloud Proxy IP]/32"
port protocol="tcp" port="30000-32767" accept'
sudo firewall-cmd --permanent --zone=public --add-rich-rule='
@sammcgeown
sammcgeown / CentOS7.sh
Last active August 27, 2020 09:41
Code Stream Docker Hosts
# Condensed from https://docs.docker.com/engine/install/centos/
# Remove old versions
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
# Configure the Docker repository
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker Engine
sudo yum install docker-ce docker-ce-cli containerd.io
# Start and enable Docker
sudo systemctl start docker
@sammcgeown
sammcgeown / action.ps1
Created March 24, 2020 14:15
PowerShell ABX Rename Machine
function handler($context, $payload) {
$oldVMName = $payload.resourceNames[0]
$newVMName = $payload.customProperties.userDefinedName
$returnObj = [PSCustomObject]@{
resourceNames = $payload.resourceNames
}
$returnObj.resourceNames[0] = $newVMName
resource "vra_deployment" "this" {
name = "Terraform Deployment"
description = "Deployed from vRA provider for Terraform."
blueprint_id = vra_blueprint.this.id
project_id = vra_project.this.id
inputs = {
Flavor = "small"
Image = "ubuntu-bionic"
# Create a new Blueprint
resource "vra_blueprint" "this" {
name = "Ubuntu Blueprint"
description = "Created by vRA terraform provider"
project_id = vra_project.this.id
content = <<-EOT
formatVersion: 1
inputs:
Flavor:
provider vra {
url = var.vra_url
refresh_token = var.vra_refresh_token
}
# Set up the Cloud Account
resource "vra_cloud_account_aws" "this" {
name = "AWS Cloud Account"
description = "AWS Cloud Account configured by Terraform"
access_key = var.aws_access_key
resource "vra_cloud_account_aws" "this" {
name = "AWS Cloud Account"
description = "AWS Cloud Account configured by Terraform"
access_key = var.aws_access_key
secret_key = var.aws_secret_key
regions = ["us-east-1", "us-west-1"]
tags {
key = "cloud"
value = "aws"
provider vra {
url = var.vra_url
refresh_token = var.vra_refresh_token
}
mkdir -p ~/.terraform.d/plugins
wget https://github.com/vmware/terraform-provider-vra/releases/download/v0.1.8/terraform-provider-vra-darwin_amd64-v0.1.8.tgz
tar xvf terraform-provider-vra-darwin_amd64-v0.1.8.tgz
mv terraform-provider-vra ~/.terraform.d/plugins