This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "tls_private_key" "vm1key" { | |
| algorithm = "RSA" | |
| rsa_bits = "4096" | |
| } | |
| output "tls_private_key" { | |
| value = tls_private_key.vm1key.private_key_pem | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - name: Destroy | |
| hosts: localhost | |
| connection: local | |
| gather_facts: false | |
| vars: | |
| resource_group_name: ansible-dev-win2019-yourinitials | |
| tasks: |