简体   繁体   中英

How do I use the DSC package resource to install MongoDB?

I tried what seemed to be the straight-forward approach, and added a Package resource in my node configuration for the MongoDB MSI. I got the following error: "Could not get the https stream for file".

Here's the package configuration I tried:

    package MongoDB {
        Name = "MongoDB 3.6.11 2008R2Plus SSL (64 bit)"
        Path = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi"
        ProductId = "88F7AA23-BDD2-4EBE-9985-EBB5D2E23E83"
        Arguments = "ADDLOCAL=`"all`" SHOULD_INSTALL_COMPASS=`"0`" INSTALLLOCATION=`"C:\MongoDB\Server\3.6`""
    }

(I had $ConfigurationData references in there, but substituted for literals for simplicity)

I get the following error: Could not get the https stream for file

Possible TLS version issue? I found that Invoke-WebRequest needed the following to get it to work with that same mongo download URL. Is there a way to do this with the package resource? [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

Using nmap to interrogate both nodejs.org and fastdl.mongodb.org (which is actually on cloudfront) it was indeed true that TLS support differed. Node still supports TLS version 1.0, which so happens to work with PowerShell. But MongoDB's site only supports TLS versions 1.1 or 1.2.

As I mentioned in my question, I suspected that setting the .Net security protocol work, and indeed it does. There's no way to add arbitrary script to the DSC package resource, so I needed to make a script block just to run this code, and have the package resource depend on it.

This is what I got to work:

Node $AllNodes.Where{$_.Role -contains 'MongoDBServer'}.NodeName {

Script SetTLS {
    GetScript = { @{ Result = $true } }
    SetScript = { [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" }
    TestScript = { $false } #Always run
}

package MongoDB {
    Ensure = 'Present'
    Name = 'MongoDB 3.6.11 2008R2Plus SSL (64 bit)'
    Path = 'https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi'
    ProductId = ''
    Arguments = 'ADDLOCAL="all" SHOULD_INSTALL_COMPASS="0" INSTALLLOCATION="C:\MongoDB\Server\3.6"'
    DependsOn = '[Script]SetTLS'
}
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM