Powershell DSC 5.0-pull mode (SMB)

Source: Internet
Author: User
Tags powershell dsc

With respect to push mode, the pull server mode is typically three ways, smb,http and HTTPS, respectively.


The basic process of pull mode is to configure the LCM of node, configure the server, and then push the configuration file to the node, which periodically checks the status and, if the status is not correct, where the new profile is downloaded from the pulling server. Pull server verifies the GUID value and then compares the client and server configuration file's checksum, if the match even if it does not match, downloads the new to the client node.


First look at the simplest SMB approach.


First create a file C:\DSCSMB and then assign share permissions

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A6/wKiom1YDRLLDA6bSAAKtcTQpQ64335.jpg "style=" float: none; "title=" 1.PNG "alt=" Wkiom1ydrllda6bsaaktctqpq64335.jpg "/>

Check it out.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A3/wKioL1YDRLaDoqZNAACbZier73M630.jpg "style=" float: none; "title=" 2.PNG "alt=" Wkiol1ydrladoqznaacbzier73m630.jpg "/>


The OKAY,SMB server is ready to build.


Next, we need to configure the MOF file.


Here is a ready-made module to help us generate the corresponding MOF, first download this module from PowerShell Gallery

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/A6/wKiom1YDRLTD9PVSAAD8Kd8mFVQ061.jpg "style=" float: none; "title=" 3.PNG "alt=" Wkiom1ydrltd9pvsaad8kd8mfvq061.jpg "/>

Download installation

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/A3/wKioL1YDRLewJXJbAAA6mvdze_c798.jpg "style=" float: none; "title=" 4.PNG "alt=" Wkiol1ydrlewjxjbaaa6mvdze_c798.jpg "/>

Confirm that it is installed

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/A6/wKiom1YDRLbCmpDMAAD5zlcLYGA536.jpg "style=" float: none; "title=" 5.PNG "alt=" Wkiom1ydrlbcmpdmaad5zlclyga536.jpg "/>


Okay, ready to generate a meta file of the LCM on node, note that the following is the PS 5.0 expression, and 4.0 of the difference


This configuration file and function are similar in wording, and can pass parameters as well. Note that my type is changed to pull, and also defines the SourcePath, which tells the node where to get the configuration file


[Dsclocalconfigurationmanager ()] configuration lcm_smbpull {    param          (            [parameter (Mandatory= $true)]             [string[]] $ComputerName,             [parameter (mandatory= $true)]             [string] $guid          )         Node  $ComputerName {         Settings {             allowmoduleoverwrite =  $True              configurationmode =  ' Applyandautocorrect '             refreshmode =  ' Pull '              ConfigurationID =  $guid         }                                      configurationrepositoryshare dscsmb {                              sourcepath =  "\\sydit01\DSCSMB"              }   }}# Computer list  $ComputerName = ' sydittest ' # create guid  for the computers$guid=[guid]::newguid () # create the computer.meta.mof in  folderLCM_SMBPULL -ComputerName  $Computername -guid  $guid  -OUTPUTPATH C:\DSCSMB 


After execution, generate the Meta.mof file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/A3/wKioL1YDRLnyD_qxAACdLNcqNio562.jpg "style=" float: none; "title=" 6.PNG "alt=" Wkiol1ydrlnyd_qxaacdlncqnio562.jpg "/>


Check it out.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A6/wKiom1YDRLiCggEOAACBsDC2h1U660.jpg "style=" float: none; "title=" 7.PNG "alt=" Wkiom1ydrlicggeoaacbsdc2h1u660.jpg "/>


And then, like the push mode, we need to push this LCM configuration to the node

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A3/wKioL1YDRL3TDeQWAAL6X9Dz2f0871.jpg "style=" float: none; "title=" 8.PNG "alt=" Wkiol1ydrl3tdeqwaal6x9dz2f0871.jpg "/>


Confirm that the LCM mode of the node has changed

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/A6/wKiom1YDRLyTYNRzAAJ_b39pZOU518.jpg "style=" float: none; "title=" 9.PNG "alt=" Wkiom1ydrlytynrzaaj_b39pzou518.jpg "/>


OKAY,LCM is ready, Next is the server configuration file, here I need to install a backup function

Configuration Backup {Node smbcomputers {windowsfeature backup{Name = ' Windows-server-backup ' ensure = ' Present '}}}backup-outputpath C:\DSCSMB


Execute the script to generate the corresponding MOF file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/A3/wKioL1YDRL_i1iF8AAEUefnFs-8823.jpg "style=" float: none; "title=" 10.PNG "alt=" Wkiol1ydrl_i1if8aaeuefnfs-8823.jpg "/>


Attention!!! The following steps are important.


In push mode, we push the MOF file with the same name as the node to the node. Pull mode, we do not judge by the name, but by the GUID to bind the node and the server, so here need to replace the name of the file with the name of the GUID

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A3/wKioL1YDRMGASEJWAAEMl8cJz8Y490.jpg "style=" float: none; "title=" 11.PNG "alt=" Wkiol1ydrmgasejwaaeml8cjz8y490.jpg "/>

You will then need to generate a checksum for this configuration file, because comparing checksum is more efficient than comparing the entire configuration file. If you make any changes to the configuration file, we must modify the checksum.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/A6/wKiom1YDRL_ydIofAAAlrnGogEg825.jpg "title=" 12.PNG "Style=" Float:none; "alt=" wkiom1ydrl_ydiofaaalrngogeg825.jpg "/>

The reason for using GUIDs and checksum here is that DSC is just a platform, not a product for certain requirements. Microsoft's partners write the corresponding product, making it easier for the user to operate, but the GUID and checksum can only be generated manually.


Take a look

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/A6/wKiom1YDRMDByWrmAAD6m4IdvtE005.jpg "style=" float: none; "title=" 13.PNG "alt=" Wkiom1ydrmdbywrmaad6m4idvte005.jpg "/>


Then look at our node computers, and now we have not installed Backup

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/A3/wKioL1YDRMPxVtaqAADGg5yLKk4579.jpg "style=" float: none; "title=" 14.PNG "alt=" Wkiol1ydrmpxvtaqaadgg5ylkk4579.jpg "/>


Update status

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A6/wKiom1YDRMGw2uf6AADQnH7bT1w738.jpg "style=" float: none; "title=" 15.PNG "alt=" Wkiom1ydrmgw2uf6aadqnh7bt1w738.jpg "/>

Check again after 5 seconds, it's installed automatically

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/A3/wKioL1YDRMTQVO4rAAC--XFL-Bc706.jpg "style=" float: none; "title=" 16.PNG "alt=" Wkiol1ydrmtqvo4raac--xfl-bc706.jpg "/>


The experiment was successful.


Next look at how HTTP and HTTPS are configured


This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1697683

Powershell DSC 5.0-pull mode (SMB)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.