Code Monkey home page Code Monkey logo

azure-dsc-pipeline's Introduction

Description

The contents of this repo provide an example of how to insert Azure DSC workflow into a pipeline, end-to-end.

This also uses DSC Composite module, to compartmentalize your DSC code into managable sections.

Note: on the initial run, this set of pipelines will likely take over 30 minutes to complete.

To-Do: There is a bit of a chicken-egg scenario with the pipeline triggers. If I update the composite module, I need the module pipeline to run before the DSC import/compile pipeline. But the module doesn't need to be re-imported every time a change occurs within the repo, so I don't want to collapse it into one pipeline. Some linked dependency needs to be created here.

Prerequisites

  • An Azure Subscription in which to deploy resources
  • An Azure KeyVault that will be used to generate certificates
  • An Azure Storage Account with a container, to store composite module zip
  • An Azure DevOps organization you can create pipelines in
  • An Azure Service Principal with the following RBAC: (so that it can itself create new service principals)
    • must be "Application Administrator" on the Azure AD tenant
    • must be "Owner" on the subscription
    • must have appropriate rights to an access policy on the KeyVault to generate and retrieve Certificates
    • must have API permissions within the Azure Active directory for:
      • API: Azure Active Directory Graph | Type: Application | Permission: Application.ReadWrite.OwnedBy
      • API: Microsoft Graph | Type: Application | Permission: Application.ReadWrite.OwnedBy
  • An Azure DevOps Service Connection linked to the Service Principal above

Deployment

Assuming you're connecting to a GitHub repository containing this code:

  • Populate the "dsc_parameters.ps1" file with values as you desire
  • Within Azure DevOps, create a new Pipeline, and link it to your GitHub (creating a service connection using OATH login)
  • Select an existing yaml file to create the pipeline from
    • Do this twice for "ModuleDeploy-pipeline.yml" and "azure-pipelines.yml"
    • Don't forget to rename your pipelines in DevOps portal, to something meaningful
  • Manually run the "ModuleDeploy-pipeline.yml" pipeline

Results

  • ModuleDeploy-pipeline.yml pipeline runs and
    • takes module from repository and creates a zip file
    • uploads DSC composite module zip to blob storage
    • creates automation account if it doesn't exist
    • imports DSC composite module to automation account from blob storage (with SAS)
  • azure-pipelines.yml pipeline runs and:
    • creates automation account if it doesn't exist
    • imports/updates Az.Accounts module
    • imports/updates remaining modules identified in parameters
    • creates new automation runas account (and required service principal) if it doesn't exist (generating an Azure KeyVault certificate to do so)
    • performs a 'first-time' run of the "Update-AutomationAzureModulesForAccount" runbook (because automation account is created with out-of-date default modules)
    • imports DSC configuration
    • compiles DSC configuration against configuration data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.