Powershell DSC 5.0 - Pull 模式 (HTTPS)
Powershell DSC 的Pull模式除了SMB以外,还可以使用HTTP或者HTTPS。这两个配置几乎一样,Https需要多配置一个证书。基本流程是配置pull server,配置节点的LCM,配置需要实现的状态,然后推送测试。
首先,我们需要一个web server的证书。我已经有PKI在域里了,因此从IIS生成一个证书非常容易。
具体步骤参考: http://beanxyz.blog.51cto.com/5570417/1331453
生成证书,绑定IIS之后,我需要获取该证书的指纹以便写入配置文件
和SMB一样,我需要下载导入模块
注意证书指纹的配置configuration HTTPSPullServer
{
# Modules must exist on target pull server
Import-DSCResource -ModuleName xPSDesiredStateConfiguration
Node sydit01
{
WindowsFeature DSCServiceFeature
{
Ensure = "Present"
Name = "DSC-Service"
}
WindowsFeature IISConsole {
Ensure = "Present"
Name = "Web-Mgmt-Console"
}
xDscWebService PSDSCPullServer
{
Ensure = "Present"
EndpointName = "PSDSCPullServer"
Port = 8080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
CertificateThumbPrint = '56B5DC192DE9AB004AE6FB3C96F7C00684537028'
ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
State = "Started"
DependsOn = "[WindowsFeature]DSCServiceFeature"
}
xDscWebService PSDSCComplianceServer
{
Ensure = "Present"
EndpointName = "PSDSCComplianceServer"
Port = 9080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCComplianceServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
State = "Started"
IsComplianceServer = $true
DependsOn = ("[WindowsFeature]DSCServiceFeature","[xDSCWebService]PSDSCPullServer")
}
}
}
# Generate MOF
HTTPSPullServer -OutputPath C:\DSC\HTTPS
生成Pull Server的配置文件
推送到指定的HTTPS服务器上
推送之后,需要测试一下是否成功
可以看见已经成功配置了
接下来需要配置节点的LCM文件[DSCLocalConfigurationManager()] Configuration LCM_HTTPSPULL { param ( [Parameter(Mandatory=$true)] [string[]]$ComputerName, [Parameter(Mandatory=$true)] [string]$guid ) Node $ComputerName { Settings { AllowModuleOverwrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' RefreshMode = 'Pull' ConfigurationID = $guid } ConfigurationRepositoryWeb DSCHTTPS { ServerURL = 'https://sydit01.omnicom.com.au:8080/PSDSCPullServer.svc' CertificateID = '56B5DC192DE9AB004AE6FB3C96F7C00684537028' AllowUnsecureConnection = $False } } } # Computer list $ComputerName='sydittest' # Create Guid for the computers $guid=[guid]::NewGuid() # Create the Computer.Meta.Mof in folder LCM_HTTPSPULL -ComputerName $ComputerName -Guid $guid -OutputPath c:\DSC\HTTPS生成LCM的meta.mof文件
推送给节点
接下来,配置我们需要实现的状态,这里的例子是确保SMTP服务始终不会安装。configuration SMTP {
Node HTTPSComputers {
WindowsFeature SMTP{
Name = 'SMTP-Server'
Ensure = 'Absent'
}
}
}
SMTP -OutputPath C:\DSC\HTTPS生成mof文件
和SMB一样,HTTPS Pull Server 也是使用GUID和checksum来校验的,因此需要改名字,生成配置文件的校验码
最后来测试一下,首先看看客户端(节点)已经安装了SMTP
更新一下状态,发现他开始自动卸载
再查看一下,已经成功卸载(提示需要重启)
实验成功。
阅读更多- Powershell DSC 5.0 - Pull 模式 (HTTPS)
- [7] Window PowerShell DSC 学习系列----如何被管理的设置节点注册到Pull Server?
- [1] Window PowerShell DSC 学习系列----DSC的定义和2种架构模式
- [21]Window PowerShell DSC学习系列---- 在Window 2012 R2 安装DSC 5.0 Pull服务器报错的解决方案
- PowerShell DSC(一)简单的推模式
- [6] Window PowerShell DSC 学习系列----如何安装最新的PowerShell DSC 5.1 Pull Server?
- Powershell DSC 5.0 - 配置Linux
- [10] Window PowerShell DSC 学习系列----目标节点和Pull 服务器底层通信原理剖析
- pyzmq的4种模式(PUSH/PULL)笔记
- ZeroMQ之PUSH/PULL模式
- 通过 Powershell 来替换 ARM 模式下虚拟机的网络接口
- 关于push和pull模式的说明
- 解决android 5.0 webview不能加载http与https混合内容的问题
- 水晶报表设计(二)----PULL模式——转自肖锰的专栏
- 微博feed系统的推(push)模式和拉(pull)模式和时间分区拉模式架构探讨
- [29] Window PowerShell DSC 学习系列----如何备份数据库和解决一个MS Server 2008上的大坑?
- 微博feed系统的push和pull模式和时间分区拉模式架构探讨
- 《Prism 5.0源码走读》 设计模式
- 解决Picasso在Android 5.0以下版本不兼容https导致图片不显示
- 微博feed系统的推(push)模式和拉(pull)模式和时间分区拉模式架构探讨