我尝试了似乎是直截了当的方法,并在MongoDB MSI的节点配置中添加了Package资源。我收到以下错误:“无法获取文件的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:\MongoDB\Server\3.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(实际上是在云端),确实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:\MongoDB\Server\3.6"'
DependsOn = '[Script]SetTLS'
}
...