diff --git a/acc-test-environment/database.tf b/acc-test-environment/database.tf index bab8ec6..e0be5b2 100644 --- a/acc-test-environment/database.tf +++ b/acc-test-environment/database.tf @@ -8,7 +8,7 @@ resource "azurerm_sql_server" "primary" { version = "12.0" administrator_login = "${var.admin_username}" - administrator_login_password = "${var.initial_admin_password}" + administrator_login_password = "${var.admin_password}" } # Database used by the environment's Octopus server diff --git a/acc-test-environment/main.tf b/acc-test-environment/main.tf index 37ca7df..ab3865e 100644 --- a/acc-test-environment/main.tf +++ b/acc-test-environment/main.tf @@ -40,4 +40,4 @@ variable "octo_vm_instance_type" { default = "Standard_A3" } variable "admin_username" { default = "octo-admin" } # The administrator password for the Octopus and SQL servers. -variable "initial_admin_password" { } +variable "admin_password" { } diff --git a/acc-test-environment/scripts/Provision-OctopusServer.ps1 b/acc-test-environment/scripts/Provision-OctopusServer.ps1 new file mode 100644 index 0000000..c09bf59 --- /dev/null +++ b/acc-test-environment/scripts/Provision-OctopusServer.ps1 @@ -0,0 +1,45 @@ +Param( + [Parameter(Mandatory = $true)] + [string] $SqlServerHost, + + [Parameter(Mandatory = $true)] + [string] $Database, + + [Parameter(Mandatory = $true)] + [string] $User, + + [Parameter(Mandatory = $true)] + [string] $Password +) + +Import-Module PowerShellGet +Install-Module OctopusDSC -Force +Import-Module OctopusDSC + +Configuration Octopus { + Import-DscResource -Module OctopusDSC + + Node "localhost" { + cOctopusServer OctopusServer { + Ensure = "present" + State = "started" + + Name = "OctopusServer" + + WebListenPrefix = "http://localhost:9081" + SqlDbConnectionString = "Server=$SqlServerHost;Database=$Database;UID=$User;PWD=$Password" + + OctopusAdminUsername = $User + OctopusAdminPassword = $Password + + # AllowUpgradeCheck = $false + # AllowCollectionOfAnonymousUsageStatistics = $false + # ForceSSL = $false + # ListenPort = 10943 + } + } +} +Octopus + +Start-DscConfiguration .\Octopus -Verbose -Wait +Test-DscConfiguration diff --git a/acc-test-environment/vm.tf b/acc-test-environment/vm.tf index 1437dc8..2cbf077 100644 --- a/acc-test-environment/vm.tf +++ b/acc-test-environment/vm.tf @@ -24,7 +24,7 @@ resource "azurerm_virtual_machine" "octo" { os_profile { computer_name = "octo-${var.uniqueness_key}" admin_username = "${var.admin_username}" - admin_password = "${var.initial_admin_password}" + admin_password = "${var.admin_password}" } os_profile_windows_config { @@ -42,4 +42,24 @@ resource "azurerm_virtual_machine" "octo" { } } +# Install Octopus Deploy +resource "null_resource" "octo_provisioning" { + provisioner "remote_exec" { + script = "scripts/Provision-OctopusServer.ps1" + + connection { + type = "winrm" + host = "${azurerm_public_ip.octo.ip_address}" + user = "${var.admin_username}" + password = "${var.admin_password}" + } + } + + depends_on = [ + "azurerm_virtual_machine.octo", + "azurerm_public_ip.octo", + "azurerm_network_security_group.default" + ] +} + # TODO: Add provisioner to install and configure Octopus Server.