Examples/cDSCDockerSwarmExample.ps1

$swarmConfig = @{    
    AllNodes = @(
        @{
            NodeName = "localhost"          
        }
    );
    NonNodeData =  @{
        masterip = (Get-VMNetworkAdapter node1).IPAddresses | Where-Object {$_ -notmatch "::"} #Replace with the IP of the node you want the initial master
    }   
}

configuration TestDockerSwarm
{

    Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
    Import-DSCResource -ModuleName xDSCFirewall
    Import-DscResource -ModuleName cDSCDockerSwarm -ModuleVersion 0.9
    node $AllNodes.NodeName
    {
        xDSCFirewall DisablePrivate
        {
          Ensure = "Absent"
          Zone = "Private"
        }

         WindowsFeature ContainerInstall
        {
            Ensure = "Present"
            Name   = "Containers"
        }

       cDockerBinaries Docker
       {
            Ensure = 'Present'
            DependsOn = '[WindowsFeature]ContainerInstall'
            version = '17.06.0-ce'
            DownloadChannel = 'Stable'
        }        

        cDockerConfig Config
       {
            Ensure = 'Present'
            DependsOn = '[cDockerBinaries]Docker'
            RestartOnChange = $true
            ExposeAPI = $true
            InsecureRegistries = 'myregistry:5000'
            Labels = "my.environment=test", "my.winver=core"
        }

       cDockerSwarm Swarm {
            DependsOn = '[cDockerConfig]Config'
            SwarmMasterURI = "$($ConfigurationData.NonNodeData.masterip):2377"
            SwarmMode = 'Active'
            ManagerCount = 3
            SwarmManagement = 'Automatic'
       } 

       cInsecureRegistryCert registry
       {
            Ensure = 'Present'
            DependsOn = '[cDockerBinaries]Docker'
            registryURI = 'myregistry:5000'
            Certificate = '-----BEGIN CERTIFICATE-----
MIIDGzCCAgOgAwIBAgIJAODTn5nU1n6/MA0GCSqGSIb3DQEBBQUAMCQxIjAgBgNV
BAMMGWltYWdlcmVnaXN0cnkuY29udG9zby5jb20wHhcNMTcwNzE0MDEwMDA1WhcN
MjcwNzEyMDEwMDA1WjAkMSIwIAYDVQQDDBlpbWFnZXJlZ2lzdHJ5LmNvbnRvc28u
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw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