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

(#732) run.rb: Combine stderr and stdout #739

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

bastelfreak
Copy link
Collaborator

@bastelfreak bastelfreak commented Nov 21, 2024

By default, Puppet::Util::Execution.execute only returns stdout. Puppet writes errors to stderr. When the run task fails, it only shows the successful output:

$ bolt task run puppet_agent::run --targets puppet
Started on puppet...
Finished on puppet:
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.local:8140 (10.0.1.1)
  Notice: Catalog compiled by puppet.local

  *long json here*

With the patch:

$ bolt task run puppet_agent::run --targets puppet
Started on puppet...
Finished on puppet:
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.local:8140 (10.0.1.1)
  Notice: Catalog compiled by puppet.local
  Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to execute '/pdb/query/v4' on at least 1 of the following 'server_urls': https://puppetdb:8081 (file: /opt/puppetlabs/puppet/modules/infrastructure/manifests/puppet/puppetserver.pp, line: 11, column: 14) on node puppet.local
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run

  *long json here*
``

@bastelfreak bastelfreak added the bug Something isn't working label Nov 21, 2024
@bastelfreak bastelfreak self-assigned this Nov 21, 2024
@bastelfreak bastelfreak requested a review from a team as a code owner November 21, 2024 13:19
By default, `Puppet::Util::Execution.execute` only returns stdout.
Puppet writes errors to stderr. When the run task fails, it only shows
the successful output:

```
$ bolt task run puppet_agent::run --targets puppet
Started on puppet...
Finished on puppet:
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.local:8140 (10.0.1.1)
  Notice: Catalog compiled by puppet.local

  *long json here*
```

With the patch:

```
$ bolt task run puppet_agent::run --targets puppet
Started on puppet...
Finished on puppet:
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.local:8140 (10.0.1.1)
  Notice: Catalog compiled by puppet.spirit-int.betadots.training
  Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to execute '/pdb/query/v4' on at least 1 of the following 'server_urls': https://puppetdb:8081 (file: /opt/puppetlabs/puppet/modules/infrastructure/manifests/puppet/puppetserver.pp, line: 11, column: 14) on node puppet.local
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run

  *long json here*
``
@joshcooper joshcooper merged commit b233bcd into puppetlabs:main Dec 5, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants