Skip to content

Run commands on virtual machines in Azure. This can be used to bootstrap/install software or run administrative tasks. NOTE: This repo is archived and will be deleted soon.

License

Notifications You must be signed in to change notification settings

DO-DRock/terraform-azurerm-vm-run-command

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run Commmand in Azure VM

Uses the VM agent to run PowerShell scripts (Windows) or shell scripts (Linux) within an Azure VM. It can be used to bootstrap/install software or run administrative tasks.

Example Usage

Install cURL (Linux)

module "run_command" {
  source               = "innovationnorway/vm-run-command/azurerm"
  resource_group_name  = "${azurerm_resource_group.main.name}"
  virtual_machine_name = "${azurerm_virtual_machine.main.name}"
  os_type              = "linux"

  command = "apt-get install -y curl"
}

Install Chocolatey (Windows)

module "run_command" {
  source               = "innovationnorway/vm-run-command/azurerm"
  resource_group_name  = "${azurerm_resource_group.main.name}"
  virtual_machine_name = "${azurerm_virtual_machine.main.name}"
  os_type              = "windows"

  command = "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
}

Install Git (Linux)

module "run_command" {
  source               = "innovationnorway/vm-run-command/azurerm"
  resource_group_name  = "${azurerm_resource_group.main.name}"
  virtual_machine_name = "${azurerm_virtual_machine.main.name}"
  os_type              = "linux"

  script = <<EOF
add-apt-repository -y ppa:git-core/ppa
apt-get update
apt-get install -y git
EOF
}

Install Updates (Windows)

module "run_command" {
  source               = "innovationnorway/vm-run-command/azurerm"
  resource_group_name  = "${azurerm_resource_group.main.name}"
  virtual_machine_name = "${azurerm_virtual_machine.main.name}"
  os_type              = "windows"

  script = <<EOF
Install-Module -Name PSWindowsUpdate -Force -AllowClobber
Get-WUInstall -WindowsUpdate -AcceptAll -UpdateType Software -IgnoreReboot
Get-WUInstall -MicrosoftUpdate -AcceptAll -IgnoreUserInput -IgnoreReboot
EOF
}

Arguments

Name Type Description
resource_group_name string The name of the resource group.
virtual_machine_name string The name of the virtual machine.
os_type string The name of the operating system. Possible values are: linux and windows.
command string The command to be executed.
script string The script to be executed. Either this or command should be specified, but not both.
file_uris list List of URLs for files to be downloaded.
timestamp string Change this value to trigger a rerun of the script. Any integer value is acceptable, it must only be different than the previous value.

About

Run commands on virtual machines in Azure. This can be used to bootstrap/install software or run administrative tasks. NOTE: This repo is archived and will be deleted soon.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%