Skip to content

Instantly share code, notes, and snippets.

View brentmcconnell's full-sized avatar

Brent McConnell brentmcconnell

  • Microsoft
  • Boston, MA
View GitHub Profile
@brentmcconnell
brentmcconnell / Dockerfile
Last active May 3, 2022 21:29
Dockerfile for SSH
FROM nginx:1.21.6-alpine
# Install OpenSSH and set the password for root to "Docker!". In this example, "apk add" is the install instruction for an Alpine Linux-based image.
RUN apk add openssh \
&& echo "root:Docker!" | chpasswd
# Copy the sshd_config file to the /etc/ssh/ directory
COPY sshd_config /etc/ssh/
# Copy and configure the ssh_setup file
trigger:
- main
pool:
vmImage: 'ubuntu-18.04'
variables:
imageName: 'fmc/hugo'
containerRegistryConnection: 'BLASTREGISTRY' #Setup a new container connection in ADO with this name
containerRegistryName: 'blastregistry'
@brentmcconnell
brentmcconnell / az-basic-project.sh
Last active January 4, 2022 21:04
Project Bootstrap Script
#!/bin/bash
# This script bootstraps a basic project for Azure DevOps
# Running this script will create a storage account.
# It also will create a Project oriented resource group and a service principle.
# The service principal has Owner for the resource group created and is
# stored in a keyvault that can be accessed by Azure DevOps to configure
# Azure access
set -o errexit # exit if any statement returns a non-true return value
@brentmcconnell
brentmcconnell / bootstrap
Created October 7, 2021 14:38
Bootstrap
# Bootstrap Project
Setup Resource Group, service principal and keyvault. The service principal is created and has Owner on the resource group as well as the ability to read and write to the storage account. This can be done manually but the follow gist can be used to perform these actions automatically if executed by someone who has the ability to create service principals and resource groups. See (https://gist.github.com/brentmcconnell/d1bb14d31ab69578c5d9ef816015ddda).
Example execution (no arguments are required but for instance -r is recommended as eastus is the default
./az-terraform-basic -g name_of_rg_to_create (optional) -r region (eastus by default).
After this program executes you will have a resource group that contains a storage account and a keyvault. These will be used by Azure DevOps to execute pipelines using the service principal's credentials in the keyvault.
### Steps performed by the script above.
1. Create Resource Group (take note of name will be used later)
@brentmcconnell
brentmcconnell / README.md
Last active October 7, 2021 14:37
Setup ADO

Bootstrap Project

Setup Resource Group, service principal and keyvault. The service principal is created and has Owner on the resource group as well as the ability to read and write to the storage account. This can be done manually but the follow gist can be used to perform these actions automatically if executed by someone who has the ability to create service principals and resource groups. See (https://gist.github.com/brentmcconnell/d1bb14d31ab69578c5d9ef816015ddda).

Example execution (no arguments are required but for instance -r is recommended as eastus is the default ./az-terraform-basic -g name_of_rg_to_create (optional) -r region (eastus by default).

After this program executes you will have a resource group that contains a storage account and a keyvault. These will be used by Azure DevOps to execute pipelines using the service principal's credentials in the keyvault.

Steps performed by the script above.

  1. Create Resource Group (take note of name will be used later)
@brentmcconnell
brentmcconnell / stopvm.ps1
Last active May 5, 2021 15:09
Powershell Runbook to StopVM
param
(
[Parameter (Mandatory = $false)]
[object] $WebhookData
)
# If runbook was called from Webhook, WebhookData will not be null.
if ($WebhookData) {
# Here for Debugging purposes
Write-Output $WebhookData
@brentmcconnell
brentmcconnell / az-terraform-helper.sh
Last active July 28, 2021 08:25
Setup RG and SP for a project and optionally create a provider.tf file for use by Terraform
#!/bin/bash
# This script bootstraps a resource group in Azure with a Service Principal
# that has Owner on the resource group. It will also create a Storage Account
# and Keyvault in the resource group and load the SP values into the Keyvault.
# You can optionally create a provider.tf file that references a tfstate
# container for use with Terraform.
# This can be used without any parameters and names will be generated or you
# can optionally pass in a (-g) resource group, (-r) region.
#!/bin/bash
set -o errexit # exit if any statement returns a non-true return value
shopt -s expand_aliases
# 3 digit random number
RND=$(echo $RANDOM | grep -o ....$)
echo "Check program requirements..."
(
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@brentmcconnell
brentmcconnell / cert-manager.sh
Last active February 23, 2022 07:06
ExternalDNS on AKS
#!/bin/bash
set -e
K8S_CONTEXT=$(kubectl config current-context)
echo -e "K8S_CONTEXT: $K8S_CONTEXT\n"
# Verify if we want to proceed
read -p "Are you sure you want to install cert-manager [y/N]?"
if [[ ! "$REPLY" =~ ^[Yy]$ ]]; then