Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DSC Push mode - best way to copy DSC resources

Tags:

dsc

I'm exploring DSC and wondering what's the best way to copy DSC resources to target host ?

When I try to push my configuration to the target host, It complain of missing DSC resource.

The PowerShell DSC resource xWebAdministration does not exist at the PowerShell module path nor is it registered as a WMI DSC resource.
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : DscResourceNotFound
    + PSComputerName        : server1.appman.net
like image 640
Adetiloye Philip Kehinde Avatar asked Jan 06 '23 04:01

Adetiloye Philip Kehinde


2 Answers

The easiest way to ensure resources are available is to setup a file share based repository for pulling down modules. This blog should help you out http://nanalakshmanan.com/blog/Push-Config-Pull-Module/

like image 87
Nana Lakshmanan Avatar answered Jan 08 '23 17:01

Nana Lakshmanan


I tried to install PS modules using DSC. It requires 3 separate configurations:

Configuration InitialConfiguration
{
    Import-DscResource -ModuleName 'PSDesiredStateConfiguration'

    Node MyServer
    {
        Script InstallModule
        {
            SetScript = { Install-Module PackageManagement -MinimumVersion 1.1.7 -Force }
            TestScript = { $version = (Get-Module PackageManagement -ListAvailable).Version; $version.Major -ge 1 -and $version.Minor -ge 1 }
            GetScript = { Get-Module PackageManagement -ListAvailable }
        }
    }
}

Configuration ModulesConfiguration
{
    Import-DscResource -ModuleName 'PackageManagement' -ModuleVersion 1.1.7.0

    Node MyServer
    {
        PackageManagement xWebAdministration
        {
            Name = 'xWebAdministration'
        }
    }
}

Configuration WebServerConfiguration
{
    Import-DscResource –ModuleName 'xWebAdministration'

    Node MyServer
    {
        xWebAppPool SampleAppPool
        {
            Name = 'SampleAppPool'
        }
    }
}

However, Microsoft uses simple script to install modules using WinRM in their example.

like image 28
Der_Meister Avatar answered Jan 08 '23 17:01

Der_Meister