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

support --tags for triggering puppet agent #732

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

bastelfreak
Copy link
Collaborator

No description provided.

@bastelfreak bastelfreak self-assigned this Aug 7, 2024
@bastelfreak bastelfreak requested review from a team as code owners August 7, 2024 11:06
@bastelfreak bastelfreak force-pushed the tags branch 2 times, most recently from 1e1e85f to 9c9a05d Compare August 7, 2024 11:43
tasks/run.json Outdated Show resolved Hide resolved
@joshcooper joshcooper added the enhancement New feature or request label Sep 24, 2024
@bastelfreak bastelfreak force-pushed the tags branch 2 times, most recently from 7bfdb13 to 71c2024 Compare November 21, 2024 13:12
@bastelfreak
Copy link
Collaborator Author

@joshcooper sorry for the delay, this is now fixed

bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request 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.spirit-int.betadots.training:8140 (10.0.1.1)
  Notice: Catalog compiled by puppet.spirit-int.betadots.training

  *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.spirit-int.betadots.training: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.spirit-int.betadots.training
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run

  *long json here*
``
bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request 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.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*
``
bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request Nov 21, 2024
without this:

```
$ bolt plan run puppet_agent::run --targets puppet
Starting: plan puppet_agent::run
Starting: Check for Puppet agent on puppet
Finished: Check for Puppet agent with 0 failures in 2.75 sec
Starting: Run Puppet agent on puppet
Finished: Run Puppet agent with 0 failures in 17.45 sec
Finished: plan puppet_agent::run in 20.21 sec
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*
Successful on 1 target: puppet
Ran on 1 target
```

with this change:

```
$ bolt plan run puppet_agent::run --targets puppet
Starting: plan puppet_agent::run
Starting: Check for Puppet agent on puppet
Finished: Check for Puppet agent with 0 failures in 2.81 sec
Starting: Run Puppet agent on puppet
Finished: Run Puppet agent with 1 failure in 12.69 sec
Finished: plan puppet_agent::run in 15.5 sec
Failed on puppet:
  The task failed with exit code 1 and no stdout, but stderr contained:
  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/execution.rb:312:in `execute': Execution of '/opt/puppetlabs/bin/puppet agent -t --color false' returned 1: Info: Using environment 'production' (Puppet::ExecutionFailure)
  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
  	from /tmp/ee90dd59-55df-44a5-8b46-6d5b5f41445a/puppet_agent/tasks/run.rb:162:in `try_run'
  	from /tmp/ee90dd59-55df-44a5-8b46-6d5b5f41445a/puppet_agent/tasks/run.rb:187:in `run'
  	from /tmp/ee90dd59-55df-44a5-8b46-6d5b5f41445a/puppet_agent/tasks/run.rb:246:in `<main>'
Failed on 1 target: puppet
Ran on 1 target
```
bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request 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.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*
``
bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request Nov 21, 2024
without this:

```
$ bolt plan run puppet_agent::run --targets puppet
Starting: plan puppet_agent::run
Starting: Check for Puppet agent on puppet
Finished: Check for Puppet agent with 0 failures in 2.75 sec
Starting: Run Puppet agent on puppet
Finished: Run Puppet agent with 0 failures in 17.45 sec
Finished: plan puppet_agent::run in 20.21 sec
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*
Successful on 1 target: puppet
Ran on 1 target
```

with this change:

```
$ bolt plan run puppet_agent::run --targets puppet
Starting: plan puppet_agent::run
Starting: Check for Puppet agent on puppet
Finished: Check for Puppet agent with 0 failures in 2.81 sec
Starting: Run Puppet agent on puppet
Finished: Run Puppet agent with 1 failure in 12.69 sec
Finished: plan puppet_agent::run in 15.5 sec
Failed on puppet:
  The task failed with exit code 1 and no stdout, but stderr contained:
  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/execution.rb:312:in `execute': Execution of '/opt/puppetlabs/bin/puppet agent -t --color false' returned 1: Info: Using environment 'production' (Puppet::ExecutionFailure)
  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
  	from /tmp/ee90dd59-55df-44a5-8b46-6d5b5f41445a/puppet_agent/tasks/run.rb:162:in `try_run'
  	from /tmp/ee90dd59-55df-44a5-8b46-6d5b5f41445a/puppet_agent/tasks/run.rb:187:in `run'
  	from /tmp/ee90dd59-55df-44a5-8b46-6d5b5f41445a/puppet_agent/tasks/run.rb:246:in `<main>'
Failed on 1 target: puppet
Ran on 1 target
```
bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request Nov 21, 2024
… task

without this change:

```
Started on localhost...
Finished on localhost:
  Info: Refreshing CA certificate
  Info: CA certificate is unmodified, using existing CA certificate
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.bastel:8140 (127.0.0.1)
  Notice: Catalog compiled by puppet.local
  Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node puppet.bastel: Exception while executing '/etc/puppetlabs/puppet/node.rb': Cannot run program "/etc/puppetlabs/puppet/node.rb" (in directory "."): error=0, Failed to exec spawn helper: pid: 2133925, exit value: 1
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run
  {
 *long json*
    },
    "exitcode": 1
  }
Successful on 1 target: localhost
Ran on 1 target in 11.19 sec
```

With this change:

```
Started on localhost...
Failed on localhost:
  Puppet agent run failed: Info: Refreshing CA certificate
  Info: CA certificate is unmodified, using existing CA certificate
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.bastel:8140 (127.0.0.1)
  Notice: Catalog compiled by puppet.local
  Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node puppet.bastel: Exception while executing '/etc/puppetlabs/puppet/node.rb': Cannot run program "/etc/puppetlabs/puppet/node.rb" (in directory "."): error=0, Failed to exec spawn helper: pid: 2133837, exit value: 1
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run
Failed on 1 target: localhost
Ran on 1 target in 11.35 sec
```

The task is now properly marked as failed, when the puppet agent run
failed itself.
tasks/run.json Outdated Show resolved Hide resolved
@bastelfreak bastelfreak force-pushed the tags branch 2 times, most recently from 2ac3a76 to 141b34b Compare November 21, 2024 20:26
bastelfreak added a commit to bastelfreak/puppetlabs-puppet_agent that referenced this pull request Nov 21, 2024
… task

without this change:

```
Started on localhost...
Finished on localhost:
  Info: Refreshing CA certificate
  Info: CA certificate is unmodified, using existing CA certificate
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.bastel:8140 (127.0.0.1)
  Notice: Catalog compiled by puppet.local
  Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node puppet.bastel: Exception while executing '/etc/puppetlabs/puppet/node.rb': Cannot run program "/etc/puppetlabs/puppet/node.rb" (in directory "."): error=0, Failed to exec spawn helper: pid: 2133925, exit value: 1
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run
  {
 *long json*
    },
    "exitcode": 1
  }
Successful on 1 target: localhost
Ran on 1 target in 11.19 sec
```

With this change:

```
Started on localhost...
Failed on localhost:
  Puppet agent run failed: Info: Refreshing CA certificate
  Info: CA certificate is unmodified, using existing CA certificate
  Info: Using environment 'production'
  Info: Retrieving pluginfacts
  Info: Retrieving plugin
  Info: Loading facts
  Notice: Requesting catalog from puppet.bastel:8140 (127.0.0.1)
  Notice: Catalog compiled by puppet.local
  Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node puppet.bastel: Exception while executing '/etc/puppetlabs/puppet/node.rb': Cannot run program "/etc/puppetlabs/puppet/node.rb" (in directory "."): error=0, Failed to exec spawn helper: pid: 2133837, exit value: 1
  Warning: Not using cache on failed catalog
  Error: Could not retrieve catalog; skipping run
Failed on 1 target: localhost
Ran on 1 target in 11.35 sec
```

The task is now properly marked as failed, when the puppet agent run
failed itself.
plans/run.pp Outdated Show resolved Hide resolved
joshcooper added a commit that referenced this pull request Dec 5, 2024
(#732) puppet_agent::run: mark failed puppet runs as failed task
Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

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

macOS 12 failures are unrelated

@joshcooper joshcooper merged commit 5c5bdc8 into puppetlabs:main Dec 5, 2024
12 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants