question

Pers-100 avatar image
0 Votes"
Pers-100 asked Pers-100 commented

Azure dsc for Linux fails in second run

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnuragSingh-MSFT avatar image
0 Votes"
AnuragSingh-MSFT answered Pers-100 commented

Hi @Pers-100,

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.


image.png (19.0 KiB)
image.png (29.1 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks. That makes sense.

0 Votes 0 ·