Dependson Question

This topic contains 3 replies, has 2 voices, and was last updated by  Don Jones 6 months, 3 weeks ago.

  • Author
    Posts
  • #67116

    turbo mcp
    Participant

    Hi
    I'm have been given many different servers using different images(some older some more recent)
    as beginning I'm trying to use dsc to configure three servers(later about 30 servers) to make sure that some have hyper-v and not iis and some I want both
    and all have snmp(for monitoring) installed before I even check for the two other windows features.
    will something like this work for me(it seem to work I'm just not sure my dependson is right):

    $ConfigurationData = @{
    AllNodes = @(
    @{NodeName = 'Demoserver1';Role='Web'},
    @{NodeName = 'DemoServer2';Role='Hyper-V'}
    @{NodeName = 'DemoServer3';Role='Hyper-V','web'}

    )
    }

    configuration RoleConfiguration
    {
    param ($Roles)

    switch ($Roles)
    {
    'Hyper-V' {
    WindowsFeature FileSharing
    {
    Name = 'Hyper-V'
    }
    }
    'Web' {
    WindowsFeature Web
    {
    Name = 'web-Server'
    Ensure = 'absent'
    }
    }
    }
    }

    configuration ExtraConfig
    {
    node $allnodes.NodeName
    {
    WindowsFeature snmp
    {
    Name = 'SNMP-Service'
    }

    RoleConfiguration MyServerRoles
    {
    Roles = $Node.Role
    }
    }
    }

    configuration ExtraConfig
    {
    node $allnodes.NodeName
    {
    WindowsFeature snmp
    {
    Name = 'SNMP-Service'
    }

    RoleConfiguration MyRoles
    {
    Roles = $Node.Role
    DependsOn = '[WindowsFeature]snmp'
    }
    }
    }

    Thanks

  • #67353

    Don Jones
    Keymaster

    The code's a bit hard to follow since you didn't format it, but yeah – broadly, I think you've got it, if I'm understanding your intent. "MyRoles" won't run until "SNMP" returns success.

    • #67464

      turbo mcp
      Participant

      Thanks Don
      i actually used one of your posts to "build" a concept for this
      i have 2 more small questions:
      1.if i list the feature like this:
      'Hyper-V' {
      WindowsFeature Hyper-v
      {
      Name = 'Hyper-V'

      but i dont include Ensure will it also install it if needed?

      2. on dependson, if i put snmp as "prereq" will it install it also or will it just check to see if its installed and if not will not run the upper portion of the code ?

      Thanks

  • #67470

    Don Jones
    Keymaster

    1. Why not try and see?

    2. If it isn't installed it will attempt to install it. If that doesn't throw an error it will – that's the whole point of DSC, right? And then proceed.

You must be logged in to reply to this topic.