Skip to content
Brandon Olin edited this page Jan 4, 2016 · 13 revisions

##What are Secrets?

In a POSHOrigin configuration file, you normally define credentials needed by the DSC resource inline with the rest of the resource options and use Get-POSHOriginSecret to resolve the credential. When using a defaults file (.psd1) however, you can not run scripts or cmdlets. To get around this problem, you define a 'Secrets' hashtable in your defaults file (or your configuration file) and list all the needed information to resolve your credentials using the resolvers. Internally, POSHOrigin will inspect the Secrets entry, resolve the credentials and add them to your configuration object.

##Example Secrets

Defining credentials for the POSHOrigin_vSphere:VM resource.

vm_defaults.psd1
@{
    secrets = @{
        vCenterCredentials = @{
            resolver = 'passwordstate'
            options = @{
               endpoint = 'https://passwordstate.mydomain.com/api'
               credApiKey = '<your API key>'
               passwordId = 1234
            }
        }
        guestCredentials = @{
            resolver = 'pscredential'
            options = @{
                username = 'administrator'
                password = 'K33p1t53cR3tK33p1t5@fE'
            }
        }
    }  
}

The above is equivalent to using Get-POSHOriginSecret in the configuration file like so.

resource 'POSHOrigin_vSphere:VM' 'VM01' @{
    ###
    # Other options omitted for brevity
    ###
    vcenterCredentials = Get-POSHOriginSecret 'passwordstate' @{
        endpoint = 'https://passwordstate.mydomain.com/api'
        credApiKey = '<your API key>'
        passwordId = 1234
    }
    GuestCredentials= Get-POSHOriginSecret 'pscredential' @{
        username = 'administrator'
        password = 'K33p1t53cR3tK33p1t5@fE'
    }
}

Defining credentials for the POSHOrigin_NetScaler:LBServer resource.

ns_defaults.psd1
@{
    secrets = @{
        credential = @{
            resolver = 'pscredential'
            options = @{
                username = 'admin'
                password = '<your password>'
            }
        }
    }
}