Skip to content

Add support for actions #1470

Description

@SteveL-MSFT

Summary of the new feature / enhancement

As part of configuring a service, like sshd, the changes don't take effect until after the service is restarted. This can, today, be worked around by using the Microsoft.Windows/Service to stop and start it, but an action to restart would be better and also only restart if settings have changed since restarting a service can, for example, disconnect active clients.

Proposed technical implementation details (optional)

Ideally, it would work like:

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Install PowerShell 7
  type: Microsoft.WinGet/Package
  properties:
    id: Microsoft.PowerShell
- name: Install SSHD
  type: Microsoft.Windows/FeatureOnDemandList
  properties:
    capabilities:
    - identity: OpenSSH.Server~~~~0.0.1.0
      state: Installed
- name: Add PS7 SSH Subsystem
  type: Microsoft.OpenSSH.SSHD/Subsystem
  properties:
    subsystem:
      name: powershell
      value: C:/progra~1/powershell/7/pwsh.exe -sshs
- name: Restart SSHD, if changed
  type: Microsoft.WIndows.Action/RestartService
  condition: "[stateChanged(resourceId('Microsoft.OpenSSH.SSHD/Subsystem','Add PS7 SSH Subsystem'))]"
  properties:
    name: sshd

This would need a new stateChanged() function that takes a resourceId() and returns true only if that resource resulted in a state change. Otherwise, the restart would be skipped.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions