官术网_书友最值得收藏!

Syntax

DSC provides a DSL to help you create MOF files. We call the file that holds the DSL syntax the DSC configuration file. Even though it is a PowerShell script file (a text file with a .ps1 extension), it can't do anything on its own. You can try to execute a configuration file all you want; it won't do anything to the system by itself. A DSC configuration file holds the information for the desired state, not the execution code to bring the node to a desired state. We talked about this separation of configuration information and execution logic earlier, and we are going to keep seeing this repeatedly throughout our use of DSC.

The DSC DSL allows both imperative and declarative commands. What this means is that configuration files can both describe what has to be done (declarative) as well as have a PowerShell code that is executed inline (imperative).

Declarative code will typically be DSC functions and resource declarations and will make up the majority of code inside your DSC configuration file. Remember, the purpose of DSC is to express the expected state of the system, which you do by declaring it in these files in the human-readable language.

Imperative code will typically make decisions based on the metadata provided inside the configuration file, for example, choosing whether to apply a configuration to a target node inside the $AllNodes variable or deciding which files or modules to apply based on some algorithm. You will find that putting a lot of imperative code inside your configuration files will cause maintenance and troubleshooting problems in the future. Generally, a lot of imperative code indicates that you are performing actions or deciding on logic that should be in a DSC resource, which is the best place to put imperative code. We will cover what indicators for this are and other important aspects of DSC resources in Chapter 4, DSC Resources.

主站蜘蛛池模板: 寻乌县| 舞钢市| 湘潭市| 肇庆市| 新平| 定西市| 区。| 达州市| 南充市| 呈贡县| 桐庐县| 本溪市| 辽阳县| 长白| 轮台县| 香港 | 政和县| 湖北省| 闽侯县| 高唐县| 丽水市| 乌拉特后旗| 巍山| 莱西市| 磴口县| 嘉黎县| 孙吴县| 富宁县| 婺源县| 丰原市| 连云港市| 定西市| 灯塔市| 闻喜县| 陆丰市| 山阴县| 鹤壁市| 赫章县| 嘉义县| 邯郸市| 新宁县|