Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment: Multiple Path entries : a conflict was detected between resources [Environment]SetMySQLBinaryPathVariable and [Environment]PHPPathEnvironmentVariable #59

Open
andy1547 opened this issue May 4, 2017 · 6 comments
Labels
documentation The issue is related to documentation only. help wanted The issue is up for grabs for anyone in the community.

Comments

@andy1547
Copy link

andy1547 commented May 4, 2017

Fails because the name value must be 'Path' but this this is used as a unique key.
Couldn't find any issues raised regarding this, still a problem in 2.6.0.0.
Is the general accepted solution to use a custom Script resource?

Related:
https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088876-dsc-environment-resource-does-not-allow-duplicate
https://powershell.org/forums/topic/why-are-the-resourcekey-combination-required-to-be-unique/

@alexkokkinos
Copy link

+1, this is really implemented poorly. You should definitely be able to set multiple path entries in one configuration.

@johlju johlju added the help wanted The issue is up for grabs for anyone in the community. label Apr 30, 2018
@johlju johlju changed the title Environment Resource multiple Path entries : a conflict was detected between resources [Environment]SetMySQLBinaryPathVariable and [Environment]PHPPathEnvironmentVariable Environment: Multiple Path entries : a conflict was detected between resources [Environment]SetMySQLBinaryPathVariable and [Environment]PHPPathEnvironmentVariable Apr 30, 2018
@johlju
Copy link
Contributor

johlju commented May 15, 2018

The resource is built to handle your scenario like this.

If either path in Value exist already it will not be added twice.

    Environment AddTwoPaths
    {
        Name   = "Path"
        Ensure = "Present"
        Path   = $true
        Value  = "C:\test123;C:\test456"
    }

To remove multiple paths.

    Environment RemoveTwoPaths
    {
        Name   = "Path"
        Ensure = "Absent"
        Path   = $true
        Value  = "C:\test123;C:\test456"
    }

I label this issue as documentation and help wanted so that the community can create an example and update the documentation for this.

@johlju johlju added documentation The issue is related to documentation only. and removed enhancement The issue is an enhancement request. labels May 15, 2018
@alexkokkinos
Copy link

alexkokkinos commented Jun 14, 2018

I tried to improve the documentation in xPSDesiredStateConfiguration to address this issue, but haven't submitted a similar PR to this repository.

I don't exactly know how code moves from experimental resources to non-experimental resources, or if it does at all, but I'll submit similar changes to this repository if they won't make their way here otherwise. (@johlju I wonder if you have any advice for me in that regard?)

@johlju
Copy link
Contributor

johlju commented Jun 15, 2018

You can see this resource module and xPSDesiredStateConfiguration resource module as separate with there own "life cycle". As this resource module do not allow breaking changes, only bug fixes and accepted enhancements, code are not moved from xPSDesiredStateConfiguration here. Updates to this resource module must be done through PR's.

For this issue, please send in a PR and I ask @kwirkykat to review it.

@gwimpey
Copy link

gwimpey commented Sep 13, 2018

The resource is built to handle your scenario like this.

If either path in Value exist already it will not be added twice.

That example from @johlju partially addresses the issue.

But, if I need to add one Value to Name, then remove a different Value from Name, it fails because Name must be unique. Or, if, multiple included resources need to modify the same path, it will fail as well. It may not be possible to combine all of them into one resource.

@johlju
Copy link
Contributor

johlju commented Sep 14, 2018

@gwimpey the resource make sure that the environment variable Path (refer to example above) is in desired state, and the resource must be unique in the final compiled mof. The desired state is that it should always have a path present, or always have a path absent - not both.
It Ensure is added as Key, then it would be possible to both remove one or more path, and add one or more path. The reason why this is not done here is because if the same path would be added to both resource instances (one with 'Present' and another with 'Absent') it would become a ping-pong behavior and the node will never be in desired state.

Example (assuming both Name and Enusre is key):

    Environment AddPath
    {
        Name   = "Path"
        Ensure = "Present"
        Path   = $true
        Value  = "C:\test123"
    }

    Environment RemovePath
    {
        Name   = "Path"
        Ensure = "Absent"
        Path   = $true
        Value  = "C:\test123"
    }

This configuration would never be in desired state.

A better solution would be to add two new properties AddValue and RemoveValue (and Value is not allowed to be used when either AddValue and RemoveValue is used) that will be used to add and remove values from the Name. But this change cannot be a breaking change (don't think so?), and must be approved. If it is not approved (or is a breaking change), the change can be done in xPSDesiredStateConfiguration.

@SteveL-MSFT SteveL-MSFT added this to Help Wanted in powershell/dscresources May 14, 2019
X-Guardian pushed a commit to X-Guardian/PSDscResources that referenced this issue Jun 4, 2019
Change Initialize-TestEnvironment to loads Module in Global Scope - Fixes PowerShell#59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation The issue is related to documentation only. help wanted The issue is up for grabs for anyone in the community.
Projects
Development

No branches or pull requests

5 participants