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

Make agent 'environment' optional #593

Open
nick-george opened this issue May 8, 2018 · 8 comments
Open

Make agent 'environment' optional #593

nick-george opened this issue May 8, 2018 · 8 comments

Comments

@nick-george
Copy link
Contributor

Hi,

It would be great if you could make the agent's environment setting in puppet.conf be optional (see https://github.com/theforeman/puppet-puppet/blob/master/manifests/agent/config.pp#L10). Quite often when I change an agent's environment (using Foreman), puppet fails all subsequent agent runs until I manually fix the puppet.conf on the agent to remove the environment setting, or change it to be the correct environment. I imagine this is a bug in puppet (agent v5.5.1), but it would also be handy if we could drop this setting entirely from the puppet.conf.

Given that most Puppet Foreman users would be forcing the directory environment from the server side, I'm surprised to see this setting is being forced.

Many thanks,
Nick George

@vchepkov
Copy link

vchepkov commented May 8, 2018

As a workaround I have been doing this trick:

environment => $server_facts['environment'],

@nick-george
Copy link
Contributor Author

Thanks for that tip Vadym.

I suspect if do this, I will still get errors when I change a host's directory environment. It seems the puppet master (or agent) can't handle the fact that the agent is specifying one environment when the master is specifying another. Unfortunately I don't have the error message on hand. When I'm next in the office, I'll see if I can get it.

Cheers,
Nick

@mmoll
Copy link
Contributor

mmoll commented May 27, 2018

PRs welcome :)

@nick-george
Copy link
Contributor Author

I'll ask my clients if they're happy for me to spend the time on it and if they are, I'll submit a PR.

@nick-george
Copy link
Contributor Author

For reference, the issue I mentioned earlier in this thread is PUP-7734 (https://tickets.puppetlabs.com/browse/PUP-7734). I'd be able to work around it if I could remove the environment setting from puppet.conf.

I'm still waiting for word on whether or not I can spend the time on this. I imagine the change itself would take a minute or two, but it's the associated tests that will take the time (for me).

Cheers,
Nick

@achevalet
Copy link

In the current implementation, the default value refers to the fact environment. To keep this behaviour, we could add a new flag use_environment_fact which is true by default. If set to false and $environment is empty the key is removed from puppet.conf. Thoughts?

@nod0n
Copy link

nod0n commented Dec 29, 2020

I do change the environment by running the agent once with --environment and then it changes the environment in the puppet agent config. But beeing able to drop the line from the config entirely, would also be nice. Some times I just run the agent twice:

  1. --environment temporary
  2. --environment default

@jplindquist
Copy link

jplindquist commented Apr 18, 2024

Sorry to dig up an old issue, but I'm wondering if there's a good solution for this to make environment optional, or configure it in some other way.

I've been running into this while trying to perform lookups from our Puppet servers. We're not specifying environment in our manifests or data, so it's using whatever the default from the module is, but when I try to perform a lookup from the Puppet server for a node, it errors as follows:

puppet lookup iptables_rules --node hostname.example.com --merge deep --compile
Error: Could not run: Evaluation Error: Error while evaluating a Function Call, Class[Puppet]: parameter 'environment' expects a String value, got Undef (file: /etc/puppetlabs/code/puppet-control/production/profile_modules/profile/manifests/init.pp, line: 51, column: 3)

All we have defined to include the class is include puppet along with some Hiera settings for configuring the server, port. The agent environment is derived by another script when the system is provisioned as part of a bootstrap process.

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

6 participants