PowerShell DSC (ii) split configuration information

Source: Internet
Author: User
Tags powershell dsc

What does the PowerShell DSC configuration file support the "detach" format, and what does that mean? As if the enterprise has a compliance requirement that is consistent with both the development test environment and the production environment, it is clear that the development test is not the same as the size of the production environment and the hardware configuration, which leads to the content defined in DSC as "what" and "where", That's what the administrator does and where to do it.

##################################################################################

As shown, we can simply understand that the configuration definition for DSC contains both the environment and structural "chapters", which describe the scope of the DSC should be applied (for example, which nodes), and the structure configuration contains exactly what to do ( such as deploying web-server roles, and so on).

650) this.width=650; "class=" Transparent "alt=" http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/ Communityserver-blogs-components-weblogfiles/00-00-00-63-74-metablogapi/1565.image001_5f00_1243aa8f.png "Src=" http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/ 00-00-00-63-74-metablogapi/1565.image001_5f00_1243aa8f.png "/>

Three special variables are built into the DSC:

1 The first of these is that $allnodes is used to reference the node data collected by Allnodes and can be used. where () and. ForEach () are filtered,

2 Once filtered by $allnodes, you can refer to $node for more detailed instructions, such as:

Configuration myconfiguration{import-dscresource-modulename xwebadministration-name msft_xwebsite node $AllNodes. Where{$_. Role-eq "WebServer"}. NodeName {xwebsite Site {Name = $Node. SiteName physicalpath = $Node. SiteC ontents ensure = "Present"}}}

3 The last one is $configurationdata, which allows the "Environment configuration" to be passed into the directive when the MOF file is finally generated, such as the data collected in the $mydata I mentioned later in this article.

In my test environment, I split the contents of the DSC configuration script into two parts, $mydata primarily to define my "environment configuration" (i.e. where), which is still defined as "structure configuration" (that is, what). $mydata is actually associated with a Hashtable, the hash table is an array, the hash table must have at least one key field is "Allnodes", I collected through $mydata two servers are Server01 and Server02, Different deployment requirements for different node roles in the configuration, such as Server01 is my appserver, I want it to install asp4.5, and Server02 is my web server, I want it to install Web-server and the console.

Here you can see the benefits of defining "environment configuration" and "Structure configuration" separately, perhaps my development test environment for these two servers, but the production environment may be 10, then I only need to modify the $mydata, and for "structural configuration" do not need to change, Because I do not need to change the role of AppServer and webserver.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6C/7A/wKiom1VJ49bA9yMHAAYcBKLEK_Y338.jpg "title=" 2015-05-01_16-47-50.png "alt=" Wkiom1vj49ba9ymhaaycbklek_y338.jpg "/>

Follow the configuration above, run the PS1 script, and then execute the myconfig in my C:\script directory and specify the-configurationdata parameter, passing in the node information $mydata collected, and successfully generated two MOF files, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/79/wKiom1VJ3vjz76LAAAaAxpMfACs964.jpg "style=" float: none; "title=" 2015-05-01_16-50-54.png "alt=" Wkiom1vj3vjz76laaaaaxpmfacs964.jpg "/>

Next you can verify that the first time the push process in addition to a small accident, because I am the domain environment of azure, not the DNS of the specified virtual network, so the last restart after the DNS has changed, so there is a link in the problem.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/75/wKioL1VJ4GvhIeFeAAnvO4dCYk4486.jpg "style=" float: none; "title=" 2015-05-01_17-00-47.png "alt=" Wkiol1vj4gvhiefeaanvo4dcyk4486.jpg "/>

Here's a hint. If you are deploying a domain controller in azure, in addition to configuring the AZUREVM static IP for the DC, you need to point the DNS to the IP of the DC in the virtual network, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/79/wKiom1VJ3vqjpU1tAANvb-1zxyM168.jpg "style=" float: none; "title=" 2015-05-01_17-48-49.png "alt=" Wkiom1vj3vqjpu1taanvb-1zxym168.jpg "/>

Perform the Start-dscconfiguration push action again successfully, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/75/wKioL1VJ4GySr-5yAAtxXTE5Upc601.jpg "style=" float: none; "title=" 2015-05-01_17-56-04.png "alt=" Wkiol1vj4gysr-5yaatxxte5upc601.jpg "/>

Run to two servers and verify that ASP. NET 4.5 has been deployed on Server01, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/79/wKiom1VJ3vui4HnYAAY5vUcx8R8067.jpg "style=" float: none; "title=" 2015-05-01_17-57-06.png "alt=" Wkiom1vj3vui4hnyaay5vucx8r8067.jpg "/>

The web-server on the Server02 can also be used, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/75/wKioL1VJ4G7yq2WrAAexOq5Ucsw850.jpg "style=" float: none; "title=" 2015-05-01_17-59-17.png "alt=" Wkiol1vj4g7yq2wraaexoq5ucsw850.jpg "/>

Of course, you can also use Test-dscconfigruation to verify that "the desired configuration is satisfied", as shown as true.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/77/wKioL1VJ7tCB5CjgAAZBo34fTVI457.jpg "title=" Untitled. png "alt=" wkiol1vj7tcb5cjgaazbo34ftvi457.jpg "/>

With a few special variables provided by DSC to design scripts flexibly, it is convenient to apply configuration modification to different environments, such as a development project from development to testing to final deployment to production environment, using POWERSEHLL DSC can realize part of the DevOps concept, can effectively reduce the " Development environment inside run well, an on-line so I do not know why, strange "such a situation ...

This article is from the "Technology Not Home" blog, please be sure to keep this source http://maomaostyle.blog.51cto.com/2220531/1643568

PowerShell DSC (ii) split configuration information

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.