如何使用 DSC 包资源安装 MongoDB



我尝试了看似简单的方法,并在MongoDB MSI的节点配置中添加了一个包资源。 我收到以下错误:"无法获取文件的https流"。

这是我尝试过的软件包配置:

    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:MongoDBServer3.6`""
    }

(我在那里有$ConfigurationData引用,但为了简单起见,用文字代替了文字(

我收到以下错误: Could not get the https stream for file

可能的 TLS 版本问题? 我发现Invoke-WebRequest需要以下内容才能使其使用相同的 mongo 下载 URL。 有没有办法使用包资源执行此操作? [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

使用 nmap 询问 nodejs.org 和 fastdl.mongodb.org(实际上是在 Cloudfront 上(,TLS 支持确实不同。 Node 仍然支持 TLS 版本 1.0,因此恰好适用于 PowerShell。 但是MongoDB的网站只支持TLS版本1.1或1.2。

正如我在问题中提到的,我怀疑设置 .Net 安全协议是有效的,确实如此。 无法将任意脚本添加到 DSC 包资源,因此我需要创建一个脚本块来运行此代码,并使资源依赖于它。

这就是我的工作:

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:MongoDBServer3.6"'
    DependsOn = '[Script]SetTLS'
}
...

最新更新