configuration after reboot start before services

Welcome Forums DSC (Desired State Configuration) configuration after reboot start before services

This topic contains 6 replies, has 2 voices, and was last updated by

 
Participant
6 months ago.

  • Author
    Posts
  • #99841

    Participant
    Points: 0
    Rank: Member

    Hi,
    I am new to DSC, and I am trying to install our product on server using DSC.
    The installation has 2 phases, between the phases should be reboot.
    I succeeded to do it, but it looks like the second phase start before all the services are up, the process can't reach a sheared directory in the computer in a UNC.

    is there solution to that, or should i configure the ALM with :
    ActionAfterReboot = 'StopConfiguration'
    RebootNodeIfNeeded = $true
    ConfigurationMode = 'ApplyAndMonitor'
    ConfigurationModeFrequencyMins = '15'

    and wait 15 minutes after the reboot ?

    Thanks a lot,
    Jacky

  • #99850

    Participant
    Points: 0
    Rank: Member

    If you are building a custom resource, during Set you will need to include setting the following global variable. This will signal to LCM that it should manage a reboot.
    $global:DSCMachineStatus = 1

    If you are only building a configuration and the existing resources meet your needs, you might need to use the xPendingReboot resource to detect that a reboot is needed. That resources is designed specifically to look for signs that Windows Server needs a reboot and then sets the global variable to make LCM aware.

    Also you need to set ActionAfterReboot to ContinueConfiguration if you want DSC to continue on after the reboot has finished.
    https://docs.microsoft.com/en-us/powershell/dsc/metaconfig#basic-settings

    Thanks!
    Michael

  • #99910

    Participant
    Points: 0
    Rank: Member

    Hi Michael,
    Thanks for the quick response.

    what i am trying to do, is to install our product on machine.
    the product is installation include to executable files. the second one should run after reboot.
    i tried to use the Package and the WindowsProcess modules to install it but with out any success.
    so i am installing it with script module. and between of them i use another script module that run the $global:DSCMachineStatus = 1
    i configured the ALM with : ActionAfterReboot = 'ContinueConfiguration' & RebootNodeIfNeeded = $true
    the reboot indeed happen between the installation, but the second on happens before the system operation actually read, the shared folder are not accessible yet and the second installation fails.

    how can i tell the DSC to wait for the system to be ready before continue the configuration after the reboot ?

    Thanks a lot,
    Jacky

  • #100488

    Participant
    Points: 0
    Rank: Member

    Hi
    Any updates about my question ?
    Thanks
    Jacky

  • #100534

    Participant
    Points: 0
    Rank: Member

    This is a scenario often referred to as "waitfor". There are DSC resources "WaitForAll, WaitForAny, WaitForSome" that can be used to communicate across two machines using DSC. There are also implementations like xWaitForADDomain that look for external things to happen. That sounds like your scenario? You would want to run a loop during Set that holds progress until the share is available, with controls around how long to wait between checks and how many checks to do before timing out.

    Example:
    https://github.com/PowerShell/xActiveDirectory/blob/dev/DSCResources/MSFT_xWaitForADDomain/MSFT_xWaitForADDomain.psm1#L62

  • #100602

    Participant
    Points: 0
    Rank: Member

    Hi Michael,
    Thanks again.

    I am familiar with the DSC resource WaitForAll, i tried it.
    But my problem is on a single machine. I dont need to wait for other scenarios on different machines to happen. but in the same machine. the UNC path is an actually path on the machine that i am installing the second phase of the installation after reboot.
    from my experience, i tried WaitForAll to the reboot to happen, and then also gave sleep for more than few minuts, and just then configure the second phase of the installation. and after all that it's looks like it start before the UNC path on that machine was ready.
    i don't know why the second phase of the installation use UNC path, for a path in the same computer, but this is what i got...:(
    if there is any solution for waiting for all the system operation to load and just them continue with the configuration, i will be happy to hear.

    Thanks,
    Jacky

    • #100792

      Participant
      Points: 0
      Rank: Member

      You need a custom resource that is a WaitFor loop looking at the local UNC path during Set. The xADDomain resource linked above has a good example. Instead of checking for the domain to exist, try using something like Resolve-Path -Path '\\localhost\c$'.

The topic ‘configuration after reboot start before services’ is closed to new replies.