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 a way to selectively disable run_command & co output to stdout on bolt plan #3301

Open
Geod24 opened this issue Apr 14, 2024 · 0 comments
Labels
Feature New features and improvements.

Comments

@Geod24
Copy link

Geod24 commented Apr 14, 2024

Use Case

I followed the breadcrumbs and ended up looking at #2653 .

I have the following block of code as part of a plan to do some testing:

    $pr = run_command(
        "/opt/puppetlabs/bin/puppet agent -t --noop --color=true --detailed-exitcodes --environment ${branch}",
        $targets, '_run_as' => 'root')

    $pr.to_data.each |$result| {
        # Detailed exit codes: https://www.puppet.com/docs/puppet/8/man/agent#usage-notes
         if $result['exit_code'] == 0 {
            out::message("${result['target']}: No change")
        } elsif $result['exit_code'] == 2 {
            out::message("${result['target']}: Succeeded with changes")
            out::message($result['value']['stdout'])
        } else {
            out::message("${result['target']}: Fail or didn't run")
            out::message($result['value']['stdout'])
        }
    }

Problem is, I get all the output from puppet on stdout even though 95% of hosts should be "No change". This is very verbose and I'd like to be able to summarize the command. So capturing the output is good, displaying it by default is good, but having a way to not do it on a run_command basis would be great.

Describe the Solution You Would Like

A _print option on run_command & related, set to true by default. If set to false, does not print to the CLI.

Describe Alternatives You've Considered

Since we run puppet in test mode to get a clear output, we could do one run without test mode, one run in term mode for those who fail, but that seems overkill. Another option would be to disable showing the output by default, but in the grander picture, it doesn't seem like the best approach.

@Geod24 Geod24 added the Feature New features and improvements. label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New features and improvements.
Projects
None yet
Development

No branches or pull requests

1 participant