Skip to content

Instantly share code, notes, and snippets.

Avatar
☑️

Jesse jesseloudon

☑️
View GitHub Profile
@jesseloudon
jesseloudon / example.tf
Created Feb 7, 2021
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
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 Nov 9, 2020
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 Nov 9, 2020
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 Nov 9, 2020
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"
@jesseloudon
jesseloudon / tls.tf
Created Nov 9, 2020
ansible on azure part 2
View tls.tf
resource "tls_private_key" "vm1key" {
algorithm = "RSA"
rsa_bits = "4096"
}
output "tls_private_key" {
value = tls_private_key.vm1key.private_key_pem
}
@jesseloudon
jesseloudon / pip-nic.tf
Created Nov 9, 2020
ansible on azure part 2
View pip-nic.tf
variable "vmPublicIPDNS" {
type = string
description = "virtual machine public IP DNS name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
data "azurerm_subnet" "default" {
name = var.vnetSubnetName
virtual_network_name = var.vnetName
resource_group_name = var.rgName
@jesseloudon
jesseloudon / nsg.tf
Created Nov 9, 2020
ansible on azure part 2
View nsg.tf
variable "nsgName" {
type = string
description = "network security group name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
variable "nsgRule1" {
type = map
description = "network security group rule 1 - remember to modify 'source_address_prefix' with your own local Public IP address https://www.whatismyip.com/"
default = {
@jesseloudon
jesseloudon / vnet.tf
Created Nov 9, 2020
ansible on azure part 2
View vnet.tf
variable "vnetName" {
type = string
description = "virtual network name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
variable "vnetAddressSpace" {
type = list
description = "virtual network address space"
default = ["10.0.0.0/24"]
@jesseloudon
jesseloudon / rg.tf
Created Nov 9, 2020
ansible on azure part 2
View rg.tf
variable "rgName" {
type = string
description = "resource group name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
variable "rgLocation" {
type = string
description = "resource group location"
default = "australiaeast"