Skip to content
Marcin Grzywa edited this page Mar 19, 2016 · 20 revisions

What is PSCI?

PSCI is a build and deployment automation library that provides a simple Powershell DSC-like language allowing to express configuration as code. The general flow is presented on the image below:

There are several possibilities to run the deployment code - see Remoting configuration for diagrams:

  • Powershell function run on local machine.
  • Powershell function run on destination machine.
  • DSC configuration run on destination machine.
  • Double-hop deployments - e.g. WebDeploy + DSC.

PSCI provides following features:

  • simple DSL to describe Environments, Server Roles, Server Connections and Tokens (per-environment parameters),
  • written entirely in Powershell (requires Powershell 3.0, or 4.0 for DSC support),
  • provisioning mechanism that is based on Powershell Desired State Configuration resources or custom Powershell functions,
  • agentless architecture - deployment to remote environments pushes packages and execute code remotely using Powershell Remoting (WinRM) or Web Deploy,
  • reliable logging mechanism throughout the whole build and deployment process - every step is logged to console, text file and event log (optionally), errors include full stack trace / script lines information and friendly messages,
  • building and deploying various types of packages (MsDeploy - e.g. ASP.NET MVC or WPF, SQL, DbDeploy, Entity Framework Migrations, SSRS, SSAS, SSIS), easily extensible with new types of packages,
  • supports several methods of tokenizing configuration files (e.g. Web.config) - directly replace tokens in files (using regex), transform using XDT (Web.<env_name>.config) or use Web Deploy parameterization,
  • supports Windows Server 2008 R2 SP1 / 7 and above (some available DSC resources like xWebsite have been fixed to work with pre-Server 2012).

Additionally, PSCI.teamcityExtensions provides set of TeamCity metarunners that makes use of PSCI functions.

Example

topology.ps1:

# Default environment - will run dsc configuration SimpleDscProvision and 
# function SimpleFunctionProvision on localhost
Environment Default {
  ServerConnection TestServer -Nodes localhost 
  ServerRole TestRole -Steps 'SimpleDscProvision', 'SimpleFunctionProvision' `
                      -ServerConnections TestServer
}

# Second environment - inherits from Default. Will run the same configuration 
# and function but with different tokens (see tokens.ps1).
Environment SecondEnv {
}

# In this environment PSCI will copy itself to the remote server and 
# then run SimpleDscProvision and SimpleFunctionProvision remotely.
Environment RemoteRun {
  ServerConnection TestServer -Nodes '<test_server>'
  ServerRole TestRole -RunRemotely
}

tokens.ps1:

Environment Default {
    Tokens TestCategory @{
        Directory = 'c:\test1'
    }
}

Environment SecondEnv {
    Tokens TestCategory @{
        Directory = 'c:\test2'
    }
}

steps.ps1:

Configuration SimpleDscProvision {
    param ($NodeName, $Environment, $Tokens)

    Node $NodeName {
        File TestFolder {
            DestinationPath = $Tokens.TestCategory.Directory
            Type = 'Directory'
        }
    }
}

function SimpleFunctionProvision {
    param ($NodeName, $Environment, $Tokens, $ConnectionParams)

    Write-Host ("Hello from SimpleFunctionProvision. I'm running at {0}." -f `
        [System.Environment]::MachineName)
}

Where to start?


Clone this wiki locally
You can’t perform that action at this time.