Azure dsc for Linux fails in second run

Pers 21 Reputation points
2022-03-16T10:14:55.707+00:00

I have setup DSC in Azure Automation Account and an Azure Ubuntu VM has been configured to pull dsc from the Automation Account.

I have a sample config as below:

Import-DSCResource -Module nx

Node $Node
{

   nxFile testConf
   {
      DestinationPath = "/etc/test.conf"
      Mode = "644"
      Type = "file"
      Contents = "hello test"
   }
}
}

It works well in first run and later on if I delete it the DSC doesn't create it.

I have similar issue with nxScript which runs script first time but afterwards it doesn't run the script (I'm always returning false in TestScript so it should always run).

It seems the issue is in Pull mode. For test I tried in Push mode and it works well.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,124 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 20,106 Reputation points
    2022-03-17T11:21:20.847+00:00

    Hi @Pers ,

    Welcome to Microsoft Q&A! Thanks for posting the question.

    Based on the information available in the question that - the "desired state configuration" for a machine gets applied only once, and then does not correct/restore "desired state" after onboarding the machine, it looks like the ConfigurationMode for Local Configuration Manager (LCM) is set to ApplyAndMonitor or ApplyOnly. Please refer to ConfigurationMode details in table available at Metaconfig basic settings.

    You can verify it by using the configuration management scripts available locally at /opt/microsoft/dsc/Scripts. If you have used the default options to register the machine from Portal or if you have used Az Module from PowerShell, the output of GetDscLocalConfigurationManager.py, would look like below:
    184060-image.png

    Once you set the ConfigurationMode to ApplyAndAutoCorrect, after initial application of a new configuration, if the target node drifts from the desired state, DSC reports the discrepancy in logs, and then re-applies the current configuration. To perform this update, you may either:

    1. use the SetDscLocalConfigurationManager.py locally on the machine (ref: Working with configurations locally) -- which is a bit complex

    2. use the Azure Portal to unregister the machine and register it again with the following options:
    184116-image.png

    Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful