Is it possible to have common configuration in DSC configuration block?

26 Views Asked by At

I'm wondering if it's possible in configuration block which contains 2 nodes to have also configuration which will be common between 2 nodes without duplicating code (some sort of include configuration) Something like below

Configuration {
   Node One {
      ...
      $commonResources
   }
   Node Two
   {
      ...
      $commonResources
   }

   $commonResouces = 
   {
   File CommonFile
   {
      
   }
   }
}
1

There are 1 best solutions below

3
joske On BEST ANSWER
Configuration {
   Node $AllNodes.NodeName {
      $commonResources
      File CommonFile
      {
      
      }
   }
   Node One {
      ...
   }
   Node Two
   {
      ...
   }
}

All common configurations can be placed under the $AllNodes.NodeName node. All configurations under this node will be on all nodes. I hope this answers your question.