OctopusDeploy/OctopusDSC

Add script to install module programmatically

robdmoore opened this issue · 2 comments

I just created this and it seems to work:

if (-not (Test-Path "C:\Program Files\WindowsPowerShell\Modules\OctopusDSC")) {
    mkdir c:\temp -ErrorAction SilentlyContinue | Out-Null
    $client = new-object system.Net.Webclient
    $client.DownloadFile("https://github.com/OctopusDeploy/OctopusDSC/archive/master.zip","c:\temp\octopusdsc.zip")
    Add-Type -AssemblyName System.IO.Compression.FileSystem
    [System.IO.Compression.ZipFile]::ExtractToDirectory("c:\temp\octopusdsc.zip", "c:\temp")
    cp -Recurse C:\temp\OctopusDSC-master\OctopusDSC "C:\Program Files\WindowsPowerShell\Modules\OctopusDSC"
}

Just throwing out there, the possibility of doing this via the cChoco DSC module. Simply import the module like you normally would, add a dependency on the Chocolatey installer, then add your OctopusDSC stuff:

configuration MyConfig
{
     [CmdletBinding()]
     param( )
    Import-DscResource -ModuleName PSDesiredStateConfiguration,cChoco

    Node "localhost"
    {
     cChocoPackageInstaller "Install_Octopus_Tentacle"
     {
          Name = "octopusdeploy.tentacle"
          Ensure = "Present"
	}

        cTentacleAgent OctopusTentacle
        {
            Ensure = "Present"
            State = "Started"
            DependsOn = "[cChocoPackageInstaller]Install_Octopus_Tentacle"

            # Tentacle instance name. Leave it as 'Tentacle' unless you have more
            # than one instance
            Name = "Tentacle"

            # Registration - all parameters required
            ApiKey = $ApiKey
            OctopusServerUrl = $OctopusServerUrl
            Environments = $Environments
            Roles = $Roles

            # How Tentacle will communicate with the server
            CommunicationMode = "Listen"
            ListenPort = $ListenPort

            # Where deployed applications will be installed by Octopus
            DefaultApplicationDirectory = "C:\Applications"

            # Where Octopus should store its working files, logs, packages etc
            TentacleHomeDirectory = "C:\Octopus"
        }
    }
}

Thanks @robdmoore! Sorry it's taken so long. I've added some installation instructions to the main readme, and referenced this issue as well.

@ITGuyOU - I think I'm missing something, but why do you need to use the chocolatey package to install the Tentacle, when the DSC downloads and installs the Tentacle? @robdmoore's solution was about getting the DSC module onto the box, but from what I can tell, your script relies on the DSC module being installed already?

I'm gonna close this issue for now, but happy to keep the conversation going.