Giter VIP home page Giter VIP logo

dscr-for-vmware's Introduction

Desired State Configuration for VMware

Overview

The Desired State Configuration for VMware project contains VMware.vSphereDSC and VMware.PSDesiredStateConfiguration PowerShell modules.

The VMware.vSphereDSC module is a collection of DSC Resources. This module includes DSC resources that simplify the management of vCenter and ESXi settings, with a simple declarative language.

The VMware.vSphereDSC module contains resources for:

  • Datacenters, Folders and Clusters
  • Standard and distributed switches and portgroups and network migration between them
  • Host network adapters
  • Datastores (VMFS and NFS) and storage adapters
  • Host accounts, roles and permissions
  • vCenter and Host settings

The VMware.PSDesiredStateConfiguration module provides an alternative in-language way to compile and execute DSC Configurations. It does not require the use of LCM and supports PowerShell 7.0.

VMware.vSphereDSC

Getting Started with VMware.vSphereDSC
DSC Resources Documentation

VMware.PSDesiredStateConfiguration

Getting Started with VMware.PSDesiredStateConfiguration
Known Limitations

Branches

master

Build Status

VMware.vSphereDSC Coverage

VMware.PSDesiredStateConfiguration Coverage

This is the branch to which contributions should be proposed by contributors as pull requests. The content of the module releases will be from the master branch.

Contributing

The Desired State Configuration Resources for VMware project team welcomes contributions from the community. For more detailed information, refer to CONTRIBUTING.md.

Join us on Slack

If you have any questions about the project you can join us on Slack:

  1. Join VMware Code
  2. Join the following channel:
    powercli-dsc-contrib
    

License

The Desired State Configuration Resources for VMware is distributed under the BSD-2.

For more details, please refer to the BSD-2 License File.

dscr-for-vmware's People

Contributors

cwestwater avatar dmilov avatar dscautomation avatar kristiyangk avatar lucdekens avatar outek avatar rockaut avatar sdbrett avatar simeongerginov avatar vmwsrpbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dscr-for-vmware's Issues

Please update README.md

Now that we are merging all PRs into the master, I assume that each merge should also update the README.md file?

Since it is the first info a visitor/user sees, it would be handy to list at least all the available DSC resources.

And a related question, is README.md intended for the git administrators, or can all users contribute?

Who maintains the Wiki pages?

Currently the Wiki pages on this repo are not open sourced.
Is it the intention to open up these pages to the community?

Use a Try-Finally construct as a standard for Pester tests

A common best practice for Pester tests seems to be to encapsulate Pester tests in a Try-Finally construct.
Since a Finally block is always run, this allows for a cleanup of the environment, independent of the Try block outcome.

As a reference, have a look at the Pester Unit and Integration test templates that MSFT provides in their DSCResources repo.

The general layout:

function Invoke-TestSetup
{
    # Init code
}

function Invoke-TestCleanup
{
    # Cleanup code
}

Try
{
    Invoke-TestSetup
    # Tests
}
Finally
{
    Invoke-TestCleanup
}

Define target Code Coverage percentage for Pester Unit tests

Since you are looking at a build pipeline, what would be the targeted code coverage percent for the Pester Unit tests?
Currently there are no clear directives on what Pester Unit tests should cover.
With a potential risk of phantom, or even worse malicious, code in the contributions from the community.

Btw, Pester code coverage for DSC resource classes is an open issue.
See the Pester issue#731

Add .vscode to .gitignore

This commit added .vscode into the project directory to provide a settings.json file. While I understand the reason would be to help ensure consistency with linting, the .vscode directory is typically considered to be locally specific.

I can see issues with getting PRs which include changes to .vscode requiring changes etc and overall increasing overhead.

VSCode settings are already included in the formatting guidelines document.

Missing classes in Unit Tests

I got stuck on writing the unit tests for PR #5 as the tests failing with:

Executing script C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\Tests\Unit\VMHostPowerPolicySetting
Tests.ps1

  Describing VMHostPowerPolicySettings

    Describing VMHostPowerPolicySettings\Get

      Context Invoking with default resource properties
        [-] Should call the Connect-VIServer mock with the passed server and credentials once 263ms
          RuntimeException: Unable to find type [VMware.Vim.PowerSystemInfo].
          at ExecuteBlock, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.2\Functions\Mock.ps1: line 1123
          at Invoke-Mock, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.2\Functions\Mock.ps1: line 966
          at <ScriptBlock><Process>, <No file>: line 64
          at GetVMHost, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\VMware.vSphereDSC.psm1: line
          at Get, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\VMware.vSphereDSC.psm1: line 191
          at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\Tests\Unit\VMHostPowerPo
tings.Unit.Tests.ps1: line 105
        [-] Should call Get-VMHost mock with the passed server and name once 34ms
          RuntimeException: Unable to find type [VMware.Vim.PowerSystemInfo].
          at ExecuteBlock, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.2\Functions\Mock.ps1: line 1123
          at Invoke-Mock, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.2\Functions\Mock.ps1: line 966
          at <ScriptBlock><Process>, <No file>: line 64
          at GetVMHost, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\VMware.vSphereDSC.psm1: line
          at Get, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\VMware.vSphereDSC.psm1: line 191
          at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\Tests\Unit\VMHostPowerPo
tings.Unit.Tests.ps1: line 115
        [-] Should return the resource with the properties passed from the server 49ms
          RuntimeException: Unable to find type [VMware.Vim.PowerSystemInfo].
          at ExecuteBlock, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.2\Functions\Mock.ps1: line 1123
          at Invoke-Mock, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.2\Functions\Mock.ps1: line 966
          at <ScriptBlock><Process>, <No file>: line 64
          at GetVMHost, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\VMware.vSphereDSC.psm1: line
          at Get, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\VMware.vSphereDSC.psm1: line 191
          at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\VMware.vSphereDSC\Tests\Unit\VMHostPowerPo
tings.Unit.Tests.ps1: line 125

It seams as Tests\Unit\TestHelpers\VMware.VimAutomation.Core is missing classes? How can we add the missing ones?

Proposal to introduce hierarchy structure in DSCResources folder

When we start to tackle more complex resources in a vSphere environment, there will be more and more separate resources that logically belong together.

This proposal suggests to organise these resources in separate subfolders under the DSCResources folder. These subfolders will help in visualising the relations between resources.

As an example, the standard Virtual Switch (VSS) would consist of the following separate, but related, resources:

  • VMHostVSS
  • VMHostVSSSecurity
  • VMHostVSSShaping
  • VMHostVSSTeaming
  • VMHostVSSAutoBridge
  • VMHostVSSBondBridge
  • VMHostVSSSimpleBridge

Under this proposal the files for these resources could be organised something like this.
folder

The build script only needs a minor change to support this afaik.

The same concept could eventually be adopted for other folders in the repository (Documentation, Configurations...)

Request to introduce a CHANGELOG document

While the repo is growing it might become difficult for contributors to discover what was added, removed or changed at what point in time.

To be able to easily see such changes, I propose to create a CHANGELOG document in the repo.

A PR should contain a standardised description of the changes, additions... it contains.
The build pipeline can insert that text into the CHANGELOG when the PR is merged.

The alternative is that the repo admins maintain the CHANGELOG document manually.

Or a mix of both.

[Feature] Add VSS resource

I would like to add a resource for a Standard Switch (VSS).

Until #11 is completed, the placement in a Network folder will be left out.

LCM DebugMode set to ForceModuleImport causes errors

When setting the LCM parameter DebugMode to ForceModuleImport, a configuration based on VMware.vSphereDsc resources fails with the errors

The specified mount name 'vis' is already in use.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NewDriveProviderException,Microsoft.PowerShell.Commands.ImportModuleCommand
    + PSComputerName        : localhost

The specified mount name 'vmstores' is already in use.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NewDriveProviderException,Microsoft.PowerShell.Commands.ImportModuleCommand
    + PSComputerName        : localhost

This DebugMode setting is useful when writing new DSC resources.
Other PS modules that provide PSDrives do not show this behaviour.

Can these errors be avoided?
Can the mounts be made more intelligent in order to not get these errors?

Add git-template to project

Can you please add a git-template to the project?
In the template I would like to have the line

Signed-off-by: Your Name [email protected]

Then with a one-time command, contributors can make sure that each commit is automatically signed.
The command

git config commit.template ~/dscr-for-vmware/git-template

[Feature] Add DSC resource for cluster configuratons

We have a large environment (300+ clusters) and a large number of engineers that can make changes (30+) but who may not be fully aware of the requirements for every cluster. We would like to do some enforcement of the settings on the cluster objects. These often get changed (whether inadvertently or on purpose but then not set back to the desired config).

  1. HA state
  2. Failure response settings
  3. Admission Control settings
  4. DRS state
  5. DRS automation level
  6. DRS thresholds
  7. DRS dristribution, memory load balancing, and CPU over-commit settings
  8. DRS and HA Advanced Settings

Cannot connect to vCenter

When attempting to perform a Test-DSCConfiguration I am getting errors during the process of connecting to vCenter.

Cannot establish connection to server vcsa.sdbrett.lab.
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
    + PSComputerName        : localhost

Connection with PowerCLI outside of DSC works ok.

Windows 10
PS version: 5.1
PowerCLI 11.0

VCSA 6.7U1

How shall we handle initial PowerCLI configuration settings?

When applying configurations or when running Unit and Integration tests on fresh environments, we hit issues.
For example, PowerCLI by default is not configured to ignore invalid certificates.
Not as critical, but equally annoying, the CEIP prompt and the deprecated warnings are there by default.

How should the DSCR handle this?
By default set this options via Set-PowerCLIConfiguration?
Or make that a separate DSC resource?

What goes under DSCResources vs VMware.vSphereDSC.Helper?

It is not entirely clear to me what type of code goes in the member functions (besides Test, Set and Get) of a DSC class, and what goes into the VMware.vSphereDSC.Helper module.

I see PowerCLI cmdlets and vSphere API methods/objects being used in both.
And I see resource specific functions in the VMware.vSphereDSC.Helper module as well.

Get-View TestHelper definition missing parametersets

The current definition of the Get-View cmdlet in the TestHelper module VMware.VimAutomation.Core, is as follows:

function Get-View {
param(
[PSObject] $Server,
[PSObject] $VIObject
)

return $null

}

This doesn't allow using the same definition for other formats of the Get-View cmdlet.
I propose to implement the actual parametersets, present on the actual Get-View cmdlet.

For example (note that this is not complete)

function Get-View {
param(
[PSObject] $Server,
[Parameter(ParameterSetName = 'GetViewByVIObject')]
[PSObject] $VIObject,
[Parameter(ParameterSetName = 'GetView')]
[VMware.Vim.ManagedObjectReference] $Id,
[Parameter(ParameterSetName = 'GetView')]
[string[]] $Property
)

return $null

}

The same remark goes for other PowerCLI cmdlets present in the TestHelpder module(s)

How to address components in DSCR?

Many vSphere components can be accessed via multiple paths.
For example a VM has a path in HostandCluster but also in VM.
The combination of these paths provide the unique location for an object.

How do we specify these different paths?
Shall these paths be keys, but perhaps not mandatory?
Do these paths belong in the BaseDsc class?

Please clarify before users start contributing, and each come up with their own solution.

[Improvement] Update build procedure to list folders and files

The build procedure should be updated - the section that iterates over all folders and files should be modified as right now there is a problem on Ubuntu when listing them(They are listed alphabetically and not by folder structure which breaks the build in some special cases).

Shall we always incorporate minimal version testing in resources?

When writing resources, some features might be version dependent.
How shall we handle this?
Or shall we always code a resource/feature assuming it is supported?
Do we cover the complete compatibility matrix in the resources, knowing that this will change over time?

The same question for coding features, which might depend on the PowerShell/PowerCLI version?
Do we use #requires directives for that?

Can we make the actual version numbers a property of the base classes?
I'm thinking of

  • vSphere API

  • vCenter

  • ESXi

  • PowerCLI

  • PowerShell

Why no MoRefs in the TestHelper VMware.VimAutomation.Core?

In the testhelper module VMware.VimAutomation.Core properties that should be of type ManagedObjectReference, are defined as the actual object.
For example:

public class HostConfigManager
{
public HostDateTimeSystem DateTimeSystem { get; set; }
public ManagedObjectReference NetworkSystem { get; set; }
public HostServiceSystem ServiceSystem { get; set; }
}

Where I would expect

public class HostConfigManager
{
public ManagedObjectReference DateTimeSystem { get; set; }
public ManagedObjectReference NetworkSystem { get; set; }
public ManagedObjectReference ServiceSystem { get; set; }
}

with a new object
public class ManagedObjectReference : System.IEquatable
{
public string Type { get; set; }
public string Value { get; set; }
...

This has impact on how the Mocks are set up.

Am I missing something?

Generate Add-Type content for TestHelpers

Isn't it possible to generate the C# code for the Add-Type in the TestHelpers module(s)?
I assume that the object definitions are available, and that a tool (swagger-like) should be able to generate that code?

Enums in Integration tests

How shall we integrate enums in the Integration tests?
In the current setup/layout, the enums created for the DSC resources, are not known in the integration test environment.
As an example, the VMHostService resource uses the [ServicePolicy] enum.
How can we use these enum values in the integration tests?

Align class definitions in mock modules with the API Reference

In the Unit Helper Modules we also define vSphere objects.
It would be handy to have the names of these classes correspond with the name of the corresponding object in the API Reference.

For example, the VMHost ExtensionData property should be a HostSystem object.

Can we flatten the Describe block layout for Pester Unit tests?

In the Coding Guidelines it is proposed to have the following layout

 Describe 'MyResource' {
     Describe 'MyResource\Set' {
         ...
     }

     Describe 'MyResource\Test' {
         ...   
     }

     Describe 'MyResource\Get' {
         ...
     }
 }

But since Pester currently only checks Tags (see issue #770) on the top level Describe, we always have to run the complete test file. Which can be annoying when developing the tests.
PS: the TestName parameter does the same

Would the following be an acceptable layout?

Since the MyResource is already present in the nested Describe blocks, I don't think we would miss anything.

   Describe 'MyResource\Set' -Tag 'Set' {
         ...
   }

   Describe 'MyResource\Test' -Tag 'Test' {
         ...   
   }

   Describe 'MyResource\Get' -Tag 'Get' {
         ...
   }
 }

And this will allow us to run a specific Describe block with

Invoke-Pester .\Unit\MyResource.Unit.Tests.ps1 -Tag 'Set'

Handling default values for resource properties

vSphere uses defaults for most of the optional properties.
How do we assign these defaults in a DSC resource?

Some options:

  • make each DSC property required
  • on the DSCProperty itself when it is not required
  • in the Test and Set methods
  • in a kind of Init method on each resource
  • via an external (JSON ?) file (different files when different API/vSphere versions change the defaults)

Each of these has pros and cons, but I feel we should define how it shall be done, before more resources are introduced.

Somewhat related, how do we handle property dependencies?
When property A, for example has value 1, property B can only have values 1 and 2 but not 3.
Do we bury that in the code, or do we use a kind of definition language to document such restrictions?

[Feature] Add Host Services as resource

I would like to contribute a Host Services resource to control those. Should be pretty easy i think as it's currently already included in PowerCLI. I just have to get in how DSCResources are implemented.

How and where shall DependsOn be tested?

When we have resources depending on other resources being present:

  • shall we do any tests for the DependsOn parameter?
  • shall these tests go under Unit and/or Integration testing?

Create Wiki page with tips & tricks

To avoid that every contributor to this repo makes the same mistakes and falls into the same pitfalls, it would be nice to have a kind of FAQ.
This FAQ should contain guidelines, but also workarounds for known issues.

Define some basic rules

Since this is an open source project, many contributors can participate.
While this is a great principle, this would also require some basic guidelines/conventions.

Some questions such guidelines might address:

  • Must each proposed new resource be announced via an Issue?
  • Who will review these new, proposed resources?
  • What will be the status/label of a new, proposed resource that is approved for development? Up for grabs?
  • Will participants be allowed to volunteer for such a new, proposed resource?
  • Is that a FIFO concept? Or will volunteers be reviewed and chosen by the owners of the repo?
  • When such a new resource is assigned, how does the assignee report on progress? Interval? Format?
  • Can the development of a new resource be assigned to multiple assignees?
  • When an assignee doesn't provide feedback for a longer, well defined period, will the Issue be opened up for a new Assignee?

Integration tests fail on missing Mandatory parameters

In the master and dev branch all Integration tests stop and prompt for parameters.
All Integration test scripts seem to have Mandatory parameters, hence the prompt.
The IntegrationTests.ps1 script doesn't provide any parameters when starting the Integration test scripts.

What would be the specs for Integration Test environments?

There are many builds of vSphere (ESXi and VCSA) out there that are still supported.
What would be the approach for running Integration Tests?

  • against the latest builds

  • against the oldest builds

  • against all supported builds

  • against all possible combinations of builds (including mixed environments)

We don't, at least most of us don't, have the test environments available that I would assume the PowerCLI Dev Team has.

Would creating and verifying correctness of said Integration Tests once, be sufficient for submitters of PRs?
And would the PowerCLI Dev Team run the same Integration Tests than against their battery of available/possible environments for final validation?

That sounds costly, more so since we are dealing with Open Source code.

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.