Conversation
| @@ -0,0 +1,160 @@ | |||
| #!/opt/puppetlabs/puppet/bin/ruby | |||
There was a problem hiding this comment.
This seems to be the most sensible default. Non AIO users can override this in their bolt configuration with interpreters.
tasks/run_agent.rb
Outdated
| require 'etc' | ||
| require 'json' | ||
| require 'yaml' | ||
| require_relative '../../ruby_task_helper/files/task_helper.rb' |
There was a problem hiding this comment.
Should I add puppetlabs/ruby_task_helper to the metadata.json?
As far as the module is concerned, it's a 'soft' dependency. But I also don't envisage a module namespace clash, so adding it to the metadata might be more helpful to users.
| require 'yaml' | ||
| require_relative '../../ruby_task_helper/files/task_helper.rb' | ||
|
|
||
| class RunAgentTask < TaskHelper |
There was a problem hiding this comment.
No idea what to use for the class name. The docs aren't especially helpful.
| if agent_locked? | ||
| raise TaskHelper::Error.new( | ||
| 'Lockfile still exists after waiting', | ||
| 'theforeman-puppet/lockfile_timeout_expired' |
There was a problem hiding this comment.
Not really sure if this is a good choice or how important it is.
| ) | ||
| end | ||
|
|
||
| waited |
There was a problem hiding this comment.
I don't think I'm actually using this returned value at the moment. I suppose I could bung it into the response??
tasks/run_agent.rb
Outdated
| cmd << if @noop | ||
| '--noop' | ||
| else | ||
| '--no-noop' |
There was a problem hiding this comment.
This is to override the value in the config file. I should probably make this clearer in whatever docs I write or in the task metadata.
| case status.exitstatus | ||
| when 0 | ||
| { | ||
| result: 'The run succeeded with no changes or failures; the system was already in the desired state (or --noop was used).', |
There was a problem hiding this comment.
Most of this text was taken from the puppet docs. I added the bit about noop myself. Maybe I should open a PR to fix this upstream ;)
e8e7da3 to
10359ab
Compare
|
Quoting myself from https://gist.github.com/alexjfisher/753c61e09e891c9c9336ba0522b581a4#gistcomment-3057265
That is, if you use |
tasks/run_agent.rb
Outdated
| end | ||
|
|
||
| def run_puppet | ||
| cmd = [@puppet_bin, 'agent', '-t', '--detailed-exitcodes'] |
There was a problem hiding this comment.
Sorry, with #709 (comment) I was of course referring to this line.
There was a problem hiding this comment.
For a manual run (as opposed to a normal scheduled run), I think I'd personally never want to accidentally be using the cache. I do need a way of making this and other options configurable though.
There was a problem hiding this comment.
--detailed-exitcodes is redundant here though (already included in -t).
There was a problem hiding this comment.
Yes, agreed, having a simple toggle for --test (which doesn't use cache) and --no-daemonize --onetime --no-splay --detailed-exitcodes (which would use cache) would be nice.
There was a problem hiding this comment.
Can you override options set with --test by setting conflicting arguments?
eg does
puppet agent -t --usecacheonfailure
work?
There was a problem hiding this comment.
answering my own question... Apparently not.
There was a problem hiding this comment.
Seems like it:
$ puppet apply --noop -e 'file { "/tmp/omgtest": ensure => file, }'
Notice: Compiled catalog for managua.lan in environment production in 0.01 seconds
Notice: /Stage[main]/Main/File[/tmp/omgtest]/ensure: current_value 'absent', should be 'file' (noop)
Notice: Class[Main]: Would have triggered 'refresh' from 1 event
Notice: Stage[main]: Would have triggered 'refresh' from 1 event
Notice: Applied catalog in 0.02 seconds
$ puppet apply --noop -e 'file { "/tmp/omgtest": ensure => file, }' --no-noop
Notice: Compiled catalog for managua.lan in environment production in 0.01 seconds
Notice: /Stage[main]/Main/File[/tmp/omgtest]/ensure: created
Notice: Applied catalog in 0.01 seconds
And yes, it'd be much better to use the default --test.
There was a problem hiding this comment.
Seems to work just fine with puppet apply. Last argument takes precedence:
$ puppet apply --no-noop -e 'file { "/tmp/omgtest": ensure => file, }' --noop
Notice: Compiled catalog for managua.lan in environment production in 0.01 seconds
Notice: /Stage[main]/Main/File[/tmp/omgtest]/ensure: current_value 'absent', should be 'file' (noop)
Notice: Class[Main]: Would have triggered 'refresh' from 1 event
Notice: Stage[main]: Would have triggered 'refresh' from 1 event
Notice: Applied catalog in 0.01 seconds
There was a problem hiding this comment.
I went for puppet agent -t --splay and the run didn't wait a random amount of time.
There was a problem hiding this comment.
@runejuhl I've added a puppet_settings variable. It's an optional hash where you can override the default settings.
e6687f8 to
9182626
Compare
| extra: | ||
| - gem: bolt | ||
| version: '~> 1.15' | ||
| # TODO: Add something to foreman-installer-modulesync to support `unless ENV['PUPPET_VERSION'] =~ /^5/` |
9182626 to
5b2946a
Compare
|
@alexjfisher what do we want to do with this? I don't have bolt or the capability to maintain this. Would you be interested in becoming a co-maintainer for the module? |
No description provided.