Commit Graph

119 Commits (ea58d7c2334c3da15ad8989be12c0909ee294369)

Author SHA1 Message Date
James Cammarata 930d090507 Fix the way handlers are compiled and found/notified
* Instead of rebuilding the handler list all over the place, we now
  compile the handlers at the point the play is post-validated so that
  the view of the play in the PlayIterator contains the definitive list
* Assign the dep_chain to the handlers as they're compiling, just as we
  do for regular tasks
* Clean up the logic used to find a given handler, which is greatly
  simplified by the above changes

Fixes #15418
10 years ago
James Cammarata 690bc192d5 Use get_handler_blocks() to get list of role handlers 10 years ago
James Cammarata 15e648dd94 Fix handler listeners as a list
The listen statement on handlers should have supported a list, however
it was broken in the revision of the pub/sub feature based on the handler
revamp. This patch corrects the bug, so this works again:

- name: some handler
  ...
  listen:
  - some target
  - another target

Fixes #16378
10 years ago
James Cammarata ca6ee4c789 FEATURE: handler listeners
Fixes ansible/proposals#8
10 years ago
James Cammarata 8218591fec Track notified handlers by object rather than simply their name
Due to the fact that roles may be instantiated with different sets of
params (multiple inclusions of the same role or via role dependencies),
simply tracking notified handlers by name does not work. This patch
changes the way we track handler notifications by using the handler
object itself instead of just the name, allowing for multiple internal
instances. Normally this would be bad, but we also modify the way we
search for handlers by first looking at the notifying tasks dependency
chain (ensuring that roles find their own handlers first) and then at
the main list of handlers, using the first match it finds.

This patch also modifies the way we setup the internal list of handlers,
which should allow us to correctly identify if a notified handler exists
more easily.

Fixes #15084
10 years ago
James Cammarata fbec2d9692 Expand return code values returned by TQM and strategies
This allows the PlaybookExecutor to receive more information regarding
what happened internal to the TaskQueueManager and strategy, to determine
things like whether or not the play iteration should stop.

Fixes #15523
10 years ago
James Cammarata 74a252d0a5 More playbook executor compatibility fixes
With some earlier changes, continuing to forward failed hosts on
to the iterator with each TQM run() call was causing plays with
max_fail_pct set to fail, as hosts which failed in previous plays
were counting those old failures against the % calculation.

Also changed the linear strategy's calculation to use the internal
failed list, rather than the iterator, as this now represents the
hosts failed during the current run only.
10 years ago
James Cammarata f0e26d0b76 In TQM run() mark any entries in _failed_hosts as failed in the PlayIterator
As noted in the comment, the TQM may be used for more than one play. As such,
after creating the new PlayIterator object it is necessary to mark any failed
hosts from previous calls to run() as failed in the iterator, so they are
properly skipped during any future calls to run().
10 years ago
Brian Coca 39bc3e624a show callback exception on debug 10 years ago
Dag Wieers 0d4f627654 Add the method_name to the catchall warning when using callback plugins
Without this you have no clue to where the exception is occuring.
10 years ago
James Cammarata 2c20579a06 Add options to make includes 'static'
* Can be configured in the ansible.cfg for tasks/handlers individually
* If an included filename contains no vars or loops, it will be expanded
  in-place as if it were marked as static
10 years ago
Brian Coca 5b11494437 python3 compatiblity
remove use of basestring
deal with configparser
10 years ago
夏恺(Xia Kai) b33074b703 remove main_q for simplicity.
main_q is not used anywhere in the codebase.

It is created in TaskQueueManager._initialize_processes, bundled with rslt_q
into TaskQueueManger._workers, later unwrapped in StrategyBase but not used.
This queue is closed in TaskQueueManger._cleanup_processes.

Historically, it is passed as a init parameter into WorkerProcess,
introduced in 62d7956, but this behavior is changed in 120b9a7.

Signed-off-by: 夏恺(Xia Kai) <xiaket@gmail.com>
10 years ago
Brian Coca 5a1887cc76 correctly handle term signals
- adhoc now terminates gracefully
- avoid race condition on terminations by ignoring errors if
  worker might have been reaped between checking if active and termination call
- ansible-playbook now properly exits on sigint/term
- adhoc and playbook now give exceptions that we should not normally capture
  and rely on top level finally to reap children
- handle systemexit breaks in workers
- added debug to see at which frame we exit
partial fix for #14346
10 years ago
Brian Coca 1aae6499ca fixed code for v1 callback runtime compatiblity
old exception code obsoleted by exception avoidance
errors on callback produce warnings and don't stop play
10 years ago
Toshio Kuratomi f4d68b8860 Transform tracebacks into unicode before printing
Fixes #14042
10 years ago
Brian Coca 87fe32319f ensure stdout callback alwasy is loaded first
it is now called for every event prior to any other callbacks
fixes #14114
10 years ago
James Cammarata abc82fee13 Fix typo in 0b86aa6 10 years ago
James Cammarata 0b86aa62e1 Hack to work around callback API change for v2_playbook_on_start 10 years ago
Brian Coca 737090dd13 now show full callback stacktrace when vvv+
Still is a warning as we don't want to repeat it multiple times nor additional callbacks to stop ansible execution.
hopefully we can avoid shipping w/o exceptions in the default/minimal callbacks...

Also added feature that now allows for 'preformated' strings passed to warning
10 years ago
James Cammarata 6312e38133 Fixing up some non-py3 things for unit tests 10 years ago
James Cammarata 120b9a7ac6 Changing the way workers are forked 10 years ago
Charles Paul 6680cc7052 allow custom callbacks with adhoc cli for scripting
missing import of CallbackBase
10 years ago
Brian Coca 04d74fd680 reenabled --tree for ansible adhoc command
previous fix to avoid callbacks now conflicted with tree optoin
which is implemented as a callback in 2.0
10 years ago
Brian Coca 7936a4687e adhoc avoids callbacks by default as it did before
Previous emptying of whitelist only affected callbacks that were
constructed for need whitelist. This now works for all callbacks.
10 years ago
James Cammarata a183972477 Don't use play vars in HostVars
Fixes #13398
10 years ago
Yannig Perré 5227c6bb52 Do not copy variable_manager each time. Instead, keep host and local variable_manager sync.
Fix https://github.com/ansible/ansible/issues/13221
10 years ago
James Cammarata 9f31c073fe Fixing a few bugs in the HostVars performance areas
* Also refresh inventory in the HostVars manager process when things
  are changed via add_host/group_by
* Raise j2undefined rather than return it
10 years ago
James Cammarata 5cbeab5a3c Performance improvements for HostVars and some bugfixes 10 years ago
Toshio Kuratomi 62979efa14 Finish up plugin porting to global display
Also remove display = display which does nothing
10 years ago
Toshio Kuratomi 318bfbb207 Migrate cli and dependencies to use global display 10 years ago
Toshio Kuratomi 4737305837 Remove dead code as this was moved to another class 10 years ago
James Cammarata 59b67a2f68 Reset workers list when recreating processes
Also renames some things to be more accurate
10 years ago
Brian Coca 9c24f88eca updated forks comment 10 years ago
James Cammarata 1027abd596 Cleaning up bugs related to perf improvement changes 10 years ago
James Cammarata 63c47fb271 Fixing up performance 10 years ago
Brian Coca f4912dd88a added callback fallback to v1 methods for backwards compat with existing callbacks 10 years ago
Brian Coca e2c56efca6 Merge pull request #12867 from bcoca/callback_whitelist_tweak
make callbacks declare needing whitelisting
10 years ago
Brian Coca 931eb16e55 clearer selection of min value
cleanup workers at each run to avoid stragglers
10 years ago
Brian Coca b44f1428d0 use minimal number of forks taking serial, forks and play patterns into account 10 years ago
Brian Coca 3c35655b52 removed serial as it is not avialable for fork control
fixes #13037
10 years ago
Brian Coca 0abeff4511 better limiting of forks to lowest actual restriction 10 years ago
Lars Larsson 3289670a04 treat forks config parameter as max value instead of always creating that number of workers 10 years ago
Brian Coca 5017a96948 Revert "make callbacks declare needing whitelisting"
another premature merge
This reverts commit df8ff85787.
10 years ago
Brian Coca df8ff85787 make callbacks declare needing whitelisting
this will allow for custom or v1 callbacks locally loaded to automatically be triggered as they were in 1.x
10 years ago
Brian Coca c267c23020 make callbacks declare needing whitelisting
this will allow for custom or v1 callbacks locally loaded to automatically be triggered as they were in 1.x
10 years ago
James Cammarata deff045aa9 Fix bug caused by options not having start_at_task when used through adhoc
Fixes #12590
10 years ago
James Cammarata dcb8caf9e8 Remember if we already skipped tasks via --start-at-task
Fixes #12482
10 years ago
James Cammarata be7bd392cb Fix unreachable host detection and have plays continue after unreachable failures
Fixes #12284
10 years ago
James Cammarata 4ac2bafc4b Set hosts fact gathering flag based on fact cache entries
Fixes #12213
10 years ago
James Cammarata 9e1bc434c7 Further cleanup from locking changes 10 years ago
James Cammarata b93f27e260 Move the lockfile back to tqm to make sure it stays unique 10 years ago
James Cammarata 50448d68e1 Implement max_fail_percentage and any_errors_fatal support
Fixes #11997
10 years ago
Brian Coca 154754ae50 pushed module_loader to task_queue_manager so all cli's can benefit from it
also normalized -M option across all cli
fixes #12016
10 years ago
Brian Coca 851ed45bbf adding display to plugins and start moving debug to display 11 years ago
James Cammarata 4c733fe4b7 Fix issues with vars_prompt and vars_files
* Prompt had to be moved up, as it needed to be done before the first
  templating of the play occurs, otherwise vars_files won't be templated
  properly
* Fixed a bug related to an earlier fix of vars_files incorporating
  extra vars to do the templating of the file name

Fixes #11404
11 years ago
James Cammarata e64989beb4 Moving ConnectionInformation -> PlayContext
Also making PlayContext a child class of the Playbook Base class,
which gives it access to all of the FieldAttribute code to ensure
field values are correctly typed after post_validation

Fixes #11381
11 years ago
Brian Coca a09f44210e now callback errors are not silent but warnings 11 years ago
Brian Coca a918a1bd16 now calls correct v2_on_any callback method 11 years ago
James Cammarata 67671e328a Fix callback loading issue a slightly different way 11 years ago
James Cammarata a51c165157 Revert "load callbacks on init again as they did not seem to load with new call from executor"
This reverts commit cf4ed9a556.
11 years ago
Brian Coca cf4ed9a556 load callbacks on init again as they did not seem to load with new call from executor 11 years ago
James Cammarata 08ad05c83b Make sure callbacks are loaded in the tqm a bit earlier
Fixes #11463
11 years ago
Brian Coca 7416e00541 fixed condition for loading whitelisted callbacks 11 years ago
James Cammarata 927072546b Fixing up some issues with plugin loading 11 years ago
James Cammarata 21c14363fd Allow callback plugins to be whitelisted 11 years ago
Brian Coca f29c1c7452 respect undefined config setting 11 years ago
James Cammarata f3f3fb7c49 Fixing vars_prompt 11 years ago
James Cammarata ce3ef7f4c1 Making the switch to v2 11 years ago