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

Add an Environment Variable 'refresh' before installing package #255

Open
brywang-msft opened this issue Jan 12, 2017 · 5 comments
Open

Comments

@brywang-msft
Copy link
Contributor

From @gaelcolas on July 20, 2016 14:34

Some packages, like RabbitMQ in the Chocolatey Repo, can have their installation customized based on Environment Variables (questionable but common method in *nix environment, and ported applications).

When using DSC and setting variables via the Environment resource (which, btw does not support [EnvironmentVariableTarget]), you'd need to restart before being able to install such package. Would it be possible to add a refresh Environment variable to the process that runs the install-package?

Would you consider a PR with the above?

Here's what the resulting configuration could look like:

        Environment RMQBase {
            Ensure            = 'Present'
            Name              = 'RABBITMQ_BASE'
            Value             = $Node.RabbitMQBase
        }

        Environment ErlangHome {
            Ensure            = 'Present'
            Name              = 'ERLANG_HOME'
            Value             = 'C:\Program Files\erl8.0'
        }

        PackageManagement RabbitMQ
        {
            Ensure            = 'present' 
            Name              = 'RabbitMQ'
            Source            = 'Chocolatey'
            DependsOn         = '[Environment]ErlangHome'
        }

The workarounds atm are: restarting, wait for next run, hack by killing session and restarting it, create custom PackageManagement resource to add the functionality...

Copied from original issue: PowerShell/PackageManagementProviderResource#29

@brywang-msft
Copy link
Contributor Author

From @gaelcolas on July 25, 2016 15:56

By the way, the core functionality should probably be provided by PackageManagement module (as in, not the DSC resource), or the Chocolatey provider.
I believe this behaviour has been fixed in Chocolatey v9.10 (issue 664), but I believe we're still waiting for the full re-work of the Chocolatey provider.

@brywang-msft
Copy link
Contributor Author

From @jianyunt on July 25, 2016 16:40

@gaelcolas. We welcome contributions from the community, i.e., accept PR.
You are right. We do not have OneGet-Chocolatey provider yet.

@brywang-msft
Copy link
Contributor Author

From @gaelcolas on August 26, 2016 15:59

I talked with @grayzu about this, and I'm not sure about how to implement such refresh in the LCM, but would be happy to submit a PR if given a bit guidance.

@jianyunt
Copy link
Contributor

jianyunt commented Sep 6, 2017

We need to talk to DSC team to see if DSC Environment Resource can handle it.

@gaelcolas
Copy link

Thanks @jianyunt. The key here is that the host process for the LCM is not refreshed during a run, and each DSC Resource is then executed in a new thread. So if a resource refreshes the environment variables, it won't affect the calling thread. At the end of that resource processing, that thread being disposed, the next thread for the next resource is started from the parent process that did not refresh the environment variables, and hence inherits those 'old' values.

What we'd need is something like a flag to tell the LCM to refresh its environment variables, maybe the same way as the one asking for a reboot: $global:DSCMachineStatus = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants