Skip to content

Instantly share code, notes, and snippets.

View jesseloudon's full-sized avatar
:shipit:

Jesse Loudon jesseloudon

:shipit:
View GitHub Profile
@jesseloudon
jesseloudon / mmaAddCloudWorkspace.ps1
Created July 4, 2021 07:08
mmaAddCloudWorkspace.ps1
View mmaAddCloudWorkspace.ps1
param(
[string]$workspaceId,
[string]$workspaceKey
)
$mma = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'
if ($mma.GetCloudWorkspace($workspaceId).workspaceid -ne $workspaceId)
{
$mma.AddCloudWorkspace($workspaceId, $workspaceKey)
@jesseloudon
jesseloudon / actionGroup.bicep
Created March 19, 2021 00:10
AzureSpringClean2021 DINE policy example
View actionGroup.bicep
targetScope = 'resourceGroup'
// PARAMETERS
param actionGroupName string
param actionGroupEnabled bool
param actionGroupShortName string
param actionGroupEmailName string
param actionGroupEmail string
param actionGroupAlertSchema bool
@jesseloudon
jesseloudon / policyAssignment.bicep
Created March 19, 2021 00:09
AzureSpringClean2021 DINE policy example
View policyAssignment.bicep
targetScope = 'subscription'
// PARAMETERS
param bicepExampleInitiativeId string
param assignmentIdentityLocation string
param assignmentEnforcementMode string
// RESOURCES
resource bicepExampleAssignment 'Microsoft.Authorization/policyAssignments@2020-09-01' = {
name: 'bicepExampleAssignment'
@jesseloudon
jesseloudon / policyDefinition.bicep
Created March 19, 2021 00:07
AzureSpringClean2021 DINE policy example
View policyDefinition.bicep
targetScope = 'subscription'
// PARAMETERS
param actionGroupName string
param actionGroupRG string
param actionGroupId string
param metricAlertResourceNamespace string
param metricAlertName string
param metricAlertDimension1 string
param metricAlertDimension2 string
@jesseloudon
jesseloudon / main.bicep
Created March 19, 2021 00:05
AzureSpringClean2021 DINE policy example
View main.bicep
targetScope = 'subscription'
// PARAMETERS
param resourceGroupName string = 'BicepExampleRG'
param resourceGrouplocation string = 'australiaeast'
param actionGroupName string = 'BicepExampleAG'
param actionGroupEnabled bool = true
param actionGroupShortName string = 'bicepag'
param actionGroupEmailName string = 'jloudon'
param actionGroupEmail string = 'jesse.loudon@lab3.com.au'
@jesseloudon
jesseloudon / example.tf
Created February 7, 2021 08:16
Example of creating 1x Terraform AzureRM policyset and 1x assignment using built-in policies and passing in parameter_values
View example.tf
resource "azurerm_policy_set_definition" "example" {
name = "foundations"
policy_type = "Custom"
display_name = "Foundations"
description = "Contains built-in policies for Foundations"
metadata = jsonencode({ category = "Custom", version = "1.0.0", source = "Terraform" })
dynamic "policy_definition_reference" { #built-in policies without parameter_values
for_each = data.azurerm_policy_definition.builtin_policies_foundations
@jesseloudon
jesseloudon / ubuntu-setup-ansible.sh
Created November 9, 2020 23:55
ansible on azure part 2
View ubuntu-setup-ansible.sh
#!/bin/bash
# This file should be sourced
# Change directory to user home
cd /home/ansibleadmin
# Upgrade all packages that have available updates and remove old ones.
sudo apt-get update
sudo apt upgrade -y
sudo apt autoremove --assume-yes
@jesseloudon
jesseloudon / extension.tf
Created November 9, 2020 23:54
ansible on azure part 2
View extension.tf
resource "azurerm_virtual_machine_extension" "vm1extension" {
name = var.vmName
virtual_machine_id = azurerm_linux_virtual_machine.vm1.id
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.1"
settings = <<SETTINGS
{
"fileUris":["https://raw.githubusercontent.com/globalbao/terraform-azurerm-ansible-linux-vm/master/scripts/ubuntu-setup-ansible.sh"]
@jesseloudon
jesseloudon / shutdown.tf
Created November 9, 2020 23:54
ansible on azure part 2
View shutdown.tf
variable "vmShutdownTime" {
type = string
description = "virtual machine daily shutdown time"
default = "1900"
}
variable "vmShutdownTimeZone" {
type = string
description = "virtual machine daily shutdown time zone"
default = "AUS Eastern Standard Time"
@jesseloudon
jesseloudon / vm.tf
Created November 9, 2020 23:53
ansible on azure part 2
View vm.tf
variable "vmName" {
type = string
description = "virtual machine name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
variable "vmSize" {
type = string
description = "virtual machine size"
default = "Standard_B2s"