前言

一般生产环境都使用Pull模式

配置Pull Server

配置Pull Server需要安装两个WindowsFeture:IIS、windows DSC,这两都可以通过UI界面化引导安装,也可以通过前面讲过的配置方式安装。

安装好之后,需要在IIS上部署一个用于和各Node交互的服务,指定后续的配置存放位置、资源存放位置等信息,具体配置如下:

configuration CreatePullServer
{
param
(
[string[]]$ComputerName = 'localhost'
) Import-DSCResource -ModuleName xPSDesiredStateConfiguration Node $ComputerName
{
WindowsFeature DSCServiceFeature
{
Ensure = "Present"
Name = "DSC-Service"
} xDscWebService PSDSCPullServer
{
Ensure = "Present"
EndpointName = "PSDSCPullServer"
Port = 8080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
State = "Started"
DependsOn = "[WindowsFeature]DSCServiceFeature"
}
}
} CreatePullServer

配置完之后,在IIS上会出现一个Site,可在浏览器访问,测试是否配置成功

配置各个Node

各Node主要是LCM发挥作用,所以主要是配置LCM:

[DSCLocalConfigurationManager()]
configuration LCMConfig
{
Node localhost
{
Settings
{
RefreshMode = 'Pull' #方式1:通过ConfigurationID
#注意:此方式RegistrationKey不是必须设置
ConfigurationID = '1d545e3b-60c3-47a0-bf65-5afc05182fd0'
}
} #定义节点请求配置文件
ConfigurationRepositoryWeb CONTOSO-PullSrv
{
ServerURL = 'https://CONTOSO-PullSrv:8080/PSDSCPullServer.svc'
RegistrationKey = '140a952b-b9d6-406b-b416-e0f759c9c0e4' #方式2:通过ConfigurationNames
#注意:此方式RegistrationKey必须要设置
ConfigurationNames = @('ClientConfig')
} #定义节点请求资源文件
ConfigurationRepositoryWeb CONTOSO-PullSrv
{
ServerURL = 'https://CONTOSO-PullSrv:8080/PSDSCPullServer.svc'
RegistrationKey = '140a952b-b9d6-406b-b416-e0f759c9c0e4'
} #定义节点汇报执行情况给PullServer
#PullServer默认会使用access数据库
#数据库可以修改为SQLServer
ReportServerWeb CONTOSO-PullSrv
{
ServerURL = 'https://CONTOSO-PullSrv:8080/PSDSCPullServer.svc'
RegistrationKey = 'fbc6ef09-ad98-4aad-a062-92b0e0327562'
}
}

生成mof文件(xxx.meta.mof)并应用即可

Set-DSCLocalConfigurationManager –ComputerName localhost –Path 'mof floder' –Verbose.

可以使用以下命令进行验证配置是否成功

Get-DSCLocalConfigurationManager

发布配置到Pull Server

以上服务器配置完成后,就需要进行交互工作了。我们根据业务写配置,编译,放到指定位置,等待Node到Pull Server上拉取,然后到Node中执行应用。

指定的位置是哪里?

上面我们配置Pull Server的时候,设置 ModulePath、ConfigurationPath,就分别是资源和配置要放置的地方。

需要强调的是资源和配置,都需要为其生成checksum文件,这样Node每次来拉取如果发现文件的checksum无变化,则不拉取。

所以配置文件夹下大概是这样的:

a.mof
a.mof.checksum
b.mof
b.mof.checksum
...

资源文件夹下面大概是这样的:

a_1.0.zip
a_1.0.zip.checksum
b_2.0.zip
b_2.0.zip.checksum
...

注意:资源文件命名必须要资源名称_版本号.zip

参考

Pull模式:https://www.red-gate.com/simple-talk/sysadmin/powershell/powershell-desired-state-configuration-pull-mode/

Pull Server配置:https://docs.microsoft.com/en-us/powershell/dsc/pull-server/pullserver

LCM配置:https://docs.microsoft.com/en-us/powershell/dsc/managing-nodes/metaconfig

注册Node到PulServer:

https://docs.microsoft.com/en-us/powershell/dsc/pull-server/pullclientconfignames

https://docs.microsoft.com/en-us/powershell/dsc/pull-server/pullclientconfigid

9.PowerShell DSC之Pull的更多相关文章

  1. 10.PowerShell DSC之细节

    mof文件到各Node放在哪里了? 在C:\Windows\System32\Configurtion文件夹下: 你可能会注意到mof的文件名称和Pull Server上的不一致,并且多出了几个.不用 ...

  2. 8.PowerShell DSC之Push

    前言 LCM的默认mode就是push,所以对于push模式,我们直接就三步走 以下是示例: 1.编写配置 Authoring Configuration WebsiteTest { # Import ...

  3. 6.PowerShell DSC核心概念之LCM

    什么是LCM? 本地配置管理器 (LCM) 是DSC的引擎. LCM 在每个目标节点上运行,负责分析和执行发送到节点的配置. 它还负责 DSC 的许多方面,包括以下各方面. 确定刷新模式(推送或请求) ...

  4. 5.PowerShell DSC核心概念之资源

    什么是资源? 资源为 DSC 配置提供构建基块. 资源公开可配置的属性,并包含本地配置管理器 (LCM) 调用以"使其如此"的 PowerShell 脚本函数. 系统内置资源 可在 ...

  5. 4.PowerShell DSC核心概念之配置

    什么是配置 DSC 配置是定义某一特殊类型函数的 PowerShell 脚本. 配置的语法 Configuration MyDscConfiguration { #配置块 Import-DscReso ...

  6. 3.PowerShell DSC核心概念

    PowerShell DSC有三个核心概念 配置 配置是声明性的PowerShell 脚本,用于定义和配置资源实例. DSC 配置是幂等的. 资源 资源是 DSC 的"实现器"部分 ...

  7. 1.PowerShell DSC概述

    什么是PowerShell DSC DSC 是一个声明性平台,用于配置.部署和管理系统. PowerShell PowerShell 是构建于 .NET 上基于任务的命令行 shell 和脚本语言. ...

  8. PowerShell DSC学习资料

    官网 https://docs.microsoft.com/zh-cn/powershell/dsc/overview/overview CSDN中文博客(专题,32篇) https://blog.c ...

  9. 7.PowerShell DSC之模式

    DSC两种模式 DSC有两种模式,Push模式和Pull模式 Push模式 基本流程 写配置--编译生成mof--推送到目标服务器,由目标服务器LCM执行mof并进行指定的配置 优点 架构简单.成本低 ...

随机推荐

  1. 【Docker】Docker启动停止重启 Redirecting to /bin/systemctl start docker.service

    [root@liuawen local]# docker -v Docker version 1.13.1, build cccb291/1.13.1 [root@liuawen local]# 启动 ...

  2. 3610:20140827:161308.483 No active checks on server: host [192.168.1.10] not found

    3610:20140827:161308.483 No active checks on server: host [192.168.1.10] not found

  3. Arduino—学习笔记—基础语法

    图解 函数具体讲解 pinMode(工作接脚,模式) 工作接脚 工作接脚编号(0--13与A0--A5) 模式 工作模式:INPUT或OUTPUT 例子 将8接口设置为输出模式 pinMode(8,O ...

  4. window安装nvm

    先说一下背景,最近做的两个项目一个是祖传angularjs1.X版本另一个是react hooks结合tailwindcss,前者angularjs的node版本比较低,而tailwindcss的no ...

  5. java进阶(33)--IO流

    一.IO流概念:1.基本概念2.IO流分类3.java.io流的四大家族4.流的close和flush方法5.java.id下常用的16个流 二.FileInputStream字节输入流1.FileI ...

  6. 从零搭建一个IdentityServer——项目搭建

    本篇文章是基于ASP.NET CORE 5.0以及IdentityServer4的IdentityServer搭建,为什么要从零搭建呢?IdentityServer4本身就有很多模板可以直接生成一个可 ...

  7. js input相关事件(转载)

    1.onfocus  当input 获取到焦点时触发. 2.onblur  当input失去焦点时触发,注意:这个事件触发的前提是已经获取了焦点再失去焦点的时候才会触发该事件,用于判断标签为空.3.o ...

  8. Linux网卡没有eth0显示ens33原因以及解决办法

    原因 首先说明下eth0与ens33的关系: 目前的主流网卡为使用以太网络协定所开发出来的以太网卡 (Ethernet),因此我们 Linux 就称呼这种网络接口为 ethN (N 为数字). 举例来 ...

  9. 下面给出一个child-parent的表格,要求挖掘其中的父子辈关系,给出祖孙辈关系的表格。

    package org.apache.hadoop.examples; import java.util.HashMap; import java.io.IOException; import jav ...

  10. Java 常见关键字总结:final、static、this、super!

    final,static,this,super 关键字总结 final 关键字 final关键字,意思是最终的.不可修改的,最见不得变化 ,用来修饰类.方法和变量,具有以下特点: final修饰的类不 ...