Please feel free to provide feedback or file bugs here.

Enable service restart and similar scenarios in DSC configurations

Renamed from "Provide additional resource control methods in DSC" for clarity
Votes from Connect: 13

Original Date Submitted: 5/28/2015 12:15:20 AM

Description:
********Contact Information********
Handle: Ben Gelens
Site Name: PowerShell
Feedback ID: 1373894
***************************************

Problem Description:
Scenario:
A MOF file is compiled for a node serving a website. The service resource is used to declare the W3SVC service to be started and the file resource is used to copy in the web content.
Next an update is deployed to the website by compiling a new MOF file and for the new content to become active, the W3SVC service needs to be restarted.

Right now we need to do this in stages as we need to compile an intermediate MOF file to stop the W3SVC service.
When dealing with continues deployment / integration utilizing DSC Push or Pull, it would be greatly beneficial if DSC could leverage additional functionality so a resource could actually trigger a restart of a service by calling the service resource governing the status of that service and allowing this action to take place.

Of course this should not be implemented only for the service resource but would apply to others as well.

Chef has implemented this concept in all its resources where they can specify a Notify on one resource and an Action on another. For example: when a file mutation has taken place, it could notify the service resource to handle the restart action.

Suggestion:
Enrich DSC with additional native functionality to allow us to signal resources to take actions as the desired state of another resource is re-implemented / restored.

Code Example using registry:
configuration MyWebSite {

WindowsFeature SNMP-Service {
Name = 'SNMP-Service'
Ensure = 'Present'
}

service SNMP {
Name = 'SNMP'
StartupType = 'Automatic'
State = 'Running'
Action = 'Restart','Start','Stop'
DependsOn = '[WindowsFeature]SNMP-Service'
}

Registry Community {
Key = 'HKLM:\System\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities'
ValueName = 'MyCommunity'
ValueData = '10'
ValueType = 'Dword'
Ensure = 'Present'
Force = $true
Notify = '[Service]SNMP:Action:Restart'
}
}
In this example we make sure SNMP service is installed, the service has the desired state of started and a registry key is set to configure the SNMP service with a valid community setting.
The registry setting will only be activated once the SNMP service is restarted so we setup a notify on the registry resource and allow it to trigger the Action of restart on the resource governing the SNMP service.

Product Studio item created by Connect Synchronizer due to creation of feedback ID 1373894 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=1373894).

Repro Steps:

Internal BugId: 14519

72 votes
Sign in
(thinking…)
Password icon
Signed in as (Sign out)

We’ll send you updates on this idea

AdminJoey Aiello [MSFT] (Program Manager, Windows Server) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Jeremy Murrah commented  ·   ·  Flag as inappropriate

    I was just thinking about this actually. Another way to go about it could be to have a built-in property for all dsc resources "dependsonSetAssertion" that would be similar to the current dependsOn property. So something like this:

    customresource appdata {
    name = myApp
    setting = MakeItWork
    }
    service MyAppStop {
    name = myAppSVC
    State = Stopped
    dependsOnSetAssertion = [customresource]appdata
    }
    service MyAppStart {
    name = myAppSVC
    State = Started
    dependsOnSetAssertion = [customresource]appdata,[service]MyAppStop
    }

  • Luigi Grilli commented  ·   ·  Flag as inappropriate

    I like the idea. That would solve a few problems. Anyway, I think we should be able to run an "action" not only after setting a dsc resource but also before setting it. Like, If I needed to replace a service executable, I could do something like this:

    xService MyService
    {
    Name = 'SNMP'
    StartupType = 'Automatic'
    }

    Package MyPackage
    {
    Path = "myPackage.exe"
    BeforeSet = @(
    "[xService]MyService::Stop"
    )
    AfterSet = @(
    "[xService]MyService::Start"
    )
    }

    # in the xService dsc resource there will be a cmdlet like:

    function Start-TargetResource
    {
    param($Action, [the other resource parameters])

    # execute $Action
    }

  • AdminMark Gray (Admin, Windows Server) commented  ·   ·  Flag as inappropriate

    Changed the title to better reflect what this request is about and changed the status to survey. We have had lots of customers run into this issue and the current number of votes does not seem to reflect our current understanding of it's importance so if this is something that is important to you, vote it up.

Feedback and Knowledge Base