Skip to content

Document --environment in puppet agent help - #653

Open
miharp wants to merge 2 commits into
OpenVoxProject:mainfrom
miharp:agent-help-environment
Open

miharp wants to merge 2 commits into
OpenVoxProject:mainfrom
miharp:agent-help-environment

Conversation

@miharp

@miharp miharp commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #652, raised by @defnull while reviewing OpenVoxProject/openvox-docs#477.

puppet agent --help listed about twenty options in USAGE and nothing else, so it read as an exhaustive list. The only hint that any puppet.conf setting is accepted as a long argument was a prose note fifty lines further down at the top of OPTIONS, which is easy to miss when scanning for a specific flag.

Changes to the help text in lib/puppet/application/agent.rb:

  • Add --environment to USAGE and OPTIONS. It is the one setting whose command-line form changes agent behaviour beyond overriding the config value: lib/puppet/configurer.rb checks set_by_cli?(:environment) and, when true, skips both the last-run environment and the node request. That is the documented way to move an agent out of an environment it switched to on an earlier run. The entry also notes that an ENC can still redirect the run unless strict_environment_mode is set.
  • Add a generic [--<setting> <VALUE>] to USAGE with a sentence pointing at the OPTIONS note.
  • Drop the "Note the special 'no-' prefix" sentence from the --no-daemonize entry. That entry is itself the no- form, and the OPTIONS intro already uses --daemonize / --no-daemonize as its worked example.
  • Regenerate man/man8/puppet-agent.8. Only the agent page is included; the other pages changed by rake gen_manpages differed only in the date header.

Verification

  • bundle exec rubocop lib/puppet/application/agent.rb: no offenses
  • bundle exec rspec spec/unit/application/agent_spec.rb: 87 examples, 0 failures
  • bundle exec puppet agent --help: USAGE and the new --environment entry render as intended
  • mandoc -Tlint on the regenerated page: only the pre-existing date-format warning

Assisted by Claude.

The agent help listed about twenty options in USAGE and nothing else, so
it read as an exhaustive list. The only hint that any puppet.conf setting
is accepted as a long argument was a prose note fifty lines further down
at the top of OPTIONS, which is easy to miss when scanning for a flag.

Add --environment to USAGE and OPTIONS. It is the one setting whose
command-line form changes agent behaviour beyond overriding the config
value: when set on the command line the agent skips both the last-run
environment and the node request, which is the documented way to move an
agent out of an environment it switched to on an earlier run. Note that
an ENC can still redirect the run unless strict_environment_mode is set.

Add a generic [--<setting> <VALUE>] to USAGE with a sentence pointing at
OPTIONS, and drop the "Note the special 'no-' prefix" sentence from the
--no-daemonize entry, which is itself the no- form and already covered
by the OPTIONS intro.

Regenerate man/man8/puppet-agent.8.

Fixes OpenVoxProject#652

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
@miharp
miharp force-pushed the agent-help-environment branch from d8d9759 to d0d43d1 Compare September 7, 2026 17:53
agent out of an environment it switched to on an earlier run. The server
can still return a catalog for a different environment, for example when
an ENC assigns one, unless 'strict_environment_mode' is set.
(This is an OpenVox setting, and can go in puppet.conf.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting strict_environment_mode does make it fail. As far as I know it's not possible to switch the environment if it is set through ENC. (don't know if you can overwrite it if set in the cert).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, and the wording was misleading. --environment can't beat an ENC in either mode. Without strict_environment_mode the agent follows the ENC and re-requests the catalog; with it, the agent refuses the mismatched catalog and the run fails. Reworded in a7196fd to say exactly that.

On the cert: the pp_environment extension exists as an OID but nothing in the agent, node, or catalog code reads it to pick an environment. It only surfaces as a trusted fact, so an ENC or site.pp would have to act on it explicitly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a great openvox-server 9 feature to enforce the environment from pp_environment

The previous wording implied that strict_environment_mode lets the
command-line environment override an ENC assignment. It does not: the
agent still cannot beat an ENC. Without strict mode it switches to the
server's environment and re-requests the catalog; with strict mode it
refuses the mismatched catalog and fails the run.

Reword the entry to say that, and regenerate the agent man page.

Addresses review feedback from @trefzer on OpenVoxProject#653.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
miharp added a commit to miharp/openvox-docs that referenced this pull request Sep 8, 2026
OpenVoxProject/openvox#653 adds --environment to the agent help text,
so the sentence saying it isn't listed there becomes wrong once that
merges. Reword it so it holds on both versions: any puppet.conf setting
is accepted on the command line, so the option works even where the
help does not list it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
miharp added a commit to miharp/openvox-docs that referenced this pull request Sep 9, 2026
OpenVoxProject/openvox#653 adds --environment to the agent help text,
so the sentence saying it isn't listed there becomes wrong once that
merges. Reword it so it holds on both versions: any puppet.conf setting
is accepted on the command line, so the option works even where the
help does not list it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
miharp added a commit to miharp/openvox-docs that referenced this pull request Sep 9, 2026
OpenVoxProject/openvox#653 adds --environment to the agent help text,
so the sentence saying it isn't listed there becomes wrong once that
merges. Reword it so it holds on both versions: any puppet.conf setting
is accepted on the command line, so the option works even where the
help does not list it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
miharp added a commit to miharp/openvox-docs that referenced this pull request Sep 10, 2026
OpenVoxProject/openvox#653 adds --environment to the agent help text,
so the sentence saying it isn't listed there becomes wrong once that
merges. Reword it so it holds on both versions: any puppet.conf setting
is accepted on the command line, so the option works even where the
help does not list it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
miharp added a commit to miharp/openvox-docs that referenced this pull request Sep 10, 2026
OpenVoxProject/openvox#653 adds --environment to the agent help text,
so the sentence saying it isn't listed there becomes wrong once that
merges. Reword it so it holds on both versions: any puppet.conf setting
is accepted on the command line, so the option works even where the
help does not list it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
miharp added a commit to miharp/openvox-docs that referenced this pull request Sep 10, 2026
OpenVoxProject/openvox#653 adds --environment to the agent help text,
so the sentence saying it isn't listed there becomes wrong once that
merges. Reword it so it holds on both versions: any puppet.conf setting
is accepted on the command line, so the option works even where the
help does not list it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Michael Harp <mike@mikeharp.com>
@miharp

miharp commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@bastelfreak ok to merge?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

puppet agent help does not mention --environment or that any setting is a valid argument

3 participants