Skip to content

Commit

Permalink
Initial sketch of acceptance test environment.
Browse files Browse the repository at this point in the history
Relates to #3.
  • Loading branch information
tintoy committed Jun 24, 2017
1 parent c56c1d0 commit 8d6f6d4
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
33 changes: 33 additions & 0 deletions acc-test-environment/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Provider configuration

# The Id of the target Azure subscription.
variable "azure_subscription_id" { sensitive = true }

# The client Id used to authenticate to Azure.
variable "azure_client_id" { sensitive = true }

# The client secret used to authenticate to Azure.
variable "azure_client_secret" { sensitive = true }

# The Id of target Azure AD tenant.
variable "azure_tenant_id" { sensitive = true }

provider "azurerm" {
subscription_id = "${azure_subscription_id}"
client_id = "${azure_client_id}"
client_secret = "${azure_client_secret}"
tenant_id = "${azure_tenant_id}"
}

## Common configuration

# The name of the target Azure region (i.e. datacenter).
variable "region_name" { default = "West Central US" }

# The name of the resource group that holds the Octopus server used by acceptance tests.
variable "resource_group_name" { default = "terraform-provider-octopus-acctest" }

# Used to prevent naming clashes between multiple concurrent deployments.
variable "uniqueness_key" { default = "acctest" }

# TODO: Define other variables
41 changes: 41 additions & 0 deletions acc-test-environment/network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Public IP address for access to the target VM.
resource "azurerm_public_ip" "primary" {
name = "tf-octo-acc-test-${var.uniqueness_key}-pip"
location = "${var.region_name}"
resource_group_name = "${var.resource_group_name}"

public_ip_address_allocation = "static"
}

# The primary network for the target VM.
resource "azurerm_virtual_network" "primary" {
name = "tf-octo-acc-test-${var.uniqueness_key}-network"
address_space = ["10.7.0.0/16"]
location = "${var.region_name}"
resource_group_name = "${var.resource_group_name}"
}

# The primary subnet for the target VM.
resource "azurerm_subnet" "primary" {
name = "tf-octo-acc-test-${var.uniqueness_key}-subnet"
resource_group_name = "${var.resource_group_name}"
virtual_network_name = "${azurerm_virtual_network.primary.name}"
address_prefix = "10.7.1.0/24"
}

# The primary network adapter for the target VM.
resource "azurerm_network_interface" "primary" {
name = "octo-${var.uniqueness_key}-ni"
location = "${var.region_name}"
resource_group_name = "${var.resource_group_name}"

ip_configuration {
name = "octo-${var.uniqueness_key}-ni-config"
subnet_id = "${azurerm_subnet.primary.id}"

# Hook up public IP to private IP.
public_ip_address_id = "${azurerm_public_ip.primary.id}"

private_ip_address_allocation = "dynamic"
}
}
8 changes: 8 additions & 0 deletions acc-test-environment/storage.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Storage configuration

resource "azurerm_storage_container" "primary" {
name = "tf-octo-acc-test-${var.uniqueness_key}"
resource_group_name = "${var.resource_group_name}"
storage_account_name = "${var.storage_acct_name}"
container_access_type = "private"
}
41 changes: 41 additions & 0 deletions acc-test-environment/vm.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# The Octopus Deploy virtual machine.
resource "azurerm_virtual_machine" "octo" {
name = "octo-${var.uniqueness_key}"
location = "${var.region_name}"
resource_group_name = "${var.resource_group_name}"
network_interface_ids = [ "${azurerm_network_interface.primary.id}" ]

vm_size = "${var.instance_type}"

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "14.04.2-LTS"
version = "latest"
}

storage_os_disk {
name = "octo-${var.uniqueness_key}-osdisk1"
vhd_uri = "https://${var.storage_acct_name}.blob.core.windows.net/${azurerm_storage_container.primary.name}/octo-${var.uniqueness_key}-osdisk1.vhd"
caching = "ReadWrite"
create_option = "FromImage"
}

os_profile {
computer_name = "octo-${var.uniqueness_key}"
admin_username = "octo-admin"
admin_password = "${var.initial_admin_password}"
}

# os_profile_linux_config {
# disable_password_authentication = true
# ssh_keys {
# path = "/home/ubuntu/.ssh/authorized_keys"
# key_data = "${var.ssh_key}"
# }
# }

tags {
public_ip = "${azurerm_public_ip.primary.ip_address}"
private_ip = "${azurerm_network_interface.primary.private_ip_address}"
}

0 comments on commit 8d6f6d4

Please sign in to comment.