Commit graph

165 commits

Author SHA1 Message Date
Marc Abramowitz
d0a154c446 Include more info when a task fails
Adds "playbook", "role", and "task" fields to the output when a task fails.

This makes it easier to pinpoint where the problem is, especially
when you have a lot of roles and playbooks.

e.g.:

    failed: [vagrant] => {..."playbook": "/Users/marca/dev/ansible/vagrant.yml",
                          ..."role": "pythonapp",
                          ..."task": "pip install -r /opt/src/{{ sm_app_role }}/requirements.txt"...}
2015-05-26 09:25:12 -07:00
Toshio Kuratomi
fbc525cfb6 Use to_bytes instead of .encode(). Fixes the fact that errors is a positional argument, not a kw arg in .encode() 2015-03-04 11:07:00 -08:00
Keith
788258917f Incorrect keyword argument 'error'
Incorrect keyword argument 'error'. It should be 'errors'.
2015-03-02 17:52:07 -05:00
Toshio Kuratomi
a6fbd83660 * Transform vars_prompt result to unicode type before returning (Fixes #10319)
* Rename prompt method as do_prompt to avoid potential bug when logging via a callback plugin
2015-02-23 07:59:20 -08:00
Brian Coca
5f2d5abeea ensure proper strings/unicodestrings for passwords
updated to correct to_bytes function
removed old to_bytes/to_unicode and repointed clients to new location
fixed unicode test
2015-02-12 17:44:08 -05:00
Toshio Kuratomi
6d788629a2 Be explicit about unicode str transformation
Fixes #10126
2015-02-02 13:37:31 -08:00
Toshio Kuratomi
35321ec642 ansible.utils to_unicode/to_bytes isn't robust in the face of
non-strings.  Do some value checking in the calling code
2015-01-27 14:18:06 -08:00
Toshio Kuratomi
915d232d5f jinja2 cannot handle byte strs with non-ascii. So we need to transform potential byte str into unicode type. This fix is for dynamic inventory.
Fixes #10007
2015-01-26 20:39:09 -08:00
Nathan Cahill
cc5a5978ef fix vars_prompt no/false values 2014-12-16 13:43:23 -07:00
Toshio Kuratomi
c4c3cc315d Transform both values of a task name into a byte str prior to comparing
Fixes #9571
2014-11-19 11:50:02 -08:00
Michael Warkentin
18a9282e0d Add host to polling message
The message for when an async task has finished has the hostname in it. This adds it to the polling message as well:

```
<job 390794962174.18311> finished on 107.6.24.140
<job 390794962174.31779> finished on 69.90.50.171
<job 390794962174.12328> polling on 69.90.50.172, 6840s remaining
```
2014-10-20 20:03:43 -04:00
James Cammarata
c3612e08f9 Move delegate_to out of runner module_vars to prevent bleeding across runs
Previously, the delegate_to value was stored in the module_vars of runner,
which could lead to bleeding that value across runs and incorrect hosts
being delegated to. This patch moves the value to a local variable in
the Runner class with some related refactoring of _compute_delegate() in
Runner (since the value is no longer required to be a parameter).

Fixes #8705
2014-09-17 14:24:31 -05:00
James Cammarata
61c76245da Don't printout async callbacks when the task is skipped 2014-09-11 12:50:21 -05:00
Michael DeHaan
26cdddaebf Tracebacks are now catchable with ignore_errors and have streamlined output. Also removes 'baby-JSON' for bash modules. 2014-09-11 12:27:21 -04:00
Michael DeHaan
fcb610dec4 Slightly trim down the warnings list based on some things being pretty common
for local usage.
2014-08-22 15:37:07 -04:00
Will Thames
ab8490d003 Added warnings to command module
Generate warnings when users are shelling out to commands
rather than using modules

Can be turned off on a per-action line with the documented
warn=False flag. Can be turned off globally using
command_warnings = False in ansible config file.

Print out warnings using the standard playbook callbacks.

Created some additional tests in TestRunner.test_command
and also a demonstration playbook.
2014-08-22 15:37:07 -04:00
James Cammarata
c8494cdc39 Set prompt encoding to a sane value when sys.stdout.encoding is None
Fixes #8644
2014-08-18 22:04:25 -05:00
Matt Martz
6591dd560d Show delegate_to hint in callbacks 2014-07-07 12:39:08 -05:00
Chris Church
955dadf743 Remove runner_on_error callback that is never used. 2014-07-01 17:02:10 -04:00
Chris Church
30fae95efe Change variable from pattern to name to correctly indicate what is being passed to the callback. 2014-07-01 17:02:09 -04:00
WAKAYAMA shirou
346bb611c7 fix UnicodeEncodeError when prompt is unicode. 2014-05-21 23:43:19 +09:00
Jim Kleckner
46ec238613 Fix #7057 missing False default for vars_prompt
The test for default should be "is not None" since a boolean value of
False is a valid value.

See discussion at:
  https://groups.google.com/forum/#!topic/ansible-project/oc1_zE-FnyI
2014-04-18 12:04:11 -07:00
Michael DeHaan
0a574af270 Merge pull request #5555 from sivel/expose-playbook-to-callback
Expose the playbook to callback plugins
2014-04-03 17:01:28 -04:00
Cristian Ciupitu
0749112286 Micro-optimization: replace s.find(x)!=-1 with x in s
timeit shows a speedup of ~3x on Python 2.7.5 x86_64.
It also makes the code a bit shorter.
2014-03-16 13:10:28 -04:00
James Cammarata
b8646991db Filter out messages that match the pattern username:password@host
This filtering is done in both the module invocation logging and in
the regular verbose() logging output.

Fixes #4087
2014-02-13 14:23:49 -06:00
James Cammarata
3f90020d62 Open LOG_LOCK file with FD_CLOEXEC to prevent file descriptor leakage
Fixes #5399
2014-02-10 15:51:52 -06:00
Matt Martz
f99500d65c Expose the playbook to callback plugins 2014-01-08 14:40:37 -06:00
Michael DeHaan
10350d1639 Update various copyrights. Not complete, but sufficient. 2014-01-04 13:32:04 -05:00
cavassin
10f5af82f9 Prevent UnicodeEncodeError
Prevents UnicodeEncodeError: 'ascii' codec can't encode character, while printing shell commands output
2013-12-05 13:17:57 -02:00
James Tanner
e8b54dd073 Fixes #4852 properly evaluate log_path writability 2013-11-18 10:40:49 -05:00
James Tanner
40886c42b5 Fixes #4561 Compare task name without role prefix for start-at-task 2013-10-25 16:09:43 -04:00
Michael DeHaan
e131de4de0 Added "debug: var=variableName" capability. 2013-10-14 21:01:38 -04:00
Michael DeHaan
43df00550d Merge pull request #3827 from mscherer/disable_callbacks
add a way for callback to disable itself
2013-10-12 07:03:06 -07:00
Michael DeHaan
9637f620d7 Deprecation warnings of several flavors, nice and purple and can be disabled
in ansible.cfg.
2013-10-11 18:37:39 -04:00
Andrey Shorin
35457b67f5 Pass host to runner_on_file_diff callback 2013-10-07 08:55:01 -04:00
James Martin
d5f20e6b21 Optionally display Skipping [host] messages. 2013-09-26 10:03:23 -04:00
James Cammarata
d5b96abd80 Added support for -vvvv to enable ssh connection debugging
This patch also checks specifically for a return code of 255, which
indicates an unknown SSH error of some kind. When that happens, ansible
will now recommend running with -vvvv (if not enabled) or show the
output from 'ssh -vvv' (when it is enabled)
2013-09-19 05:58:54 -05:00
Hiroaki Nakamura
2357194b39 Add failed_when module variable.
Implementation note: Ternery operator trick for python prior to 2.5 is used.
(test and [when_true_value] or [when_false_value])[0]
http://stackoverflow.com/questions/394809/ternary-conditional-operator-in-python#comment1466794_394887
2013-09-10 08:34:01 +09:00
Michael Scherer
12bf9a8b69 add a way for callback to disable itself
The idea is that some plugin would not be called in some
specific case, and the callback should decide by itself.

Having a way to globally disable it is much cleaner than
disabling every method one by one on the plugin side.

My use case is for fedora-infrastructure that cannot be run
from git checkout since it try to connect to the message bus,
but another case would be to bootstrap infrastructure, or to
run the code on a test servers without having all the callback
infrastructure setup.
2013-08-14 22:32:28 +02:00
Michael DeHaan
baffa8df72 These fields are booleans. 2013-08-10 18:16:01 -04:00
Michael DeHaan
3dbe65def2 PEP8 indent fix 2013-08-03 14:54:24 -04:00
James Cammarata
82c806979b Only use LOG_LOCK in log_flock if a runner is not specified
Fixes issue #3466 - When ansible can't authenticate against a host,
and your answer is no, ansible crash.
2013-08-03 13:28:19 -04:00
Michael DeHaan
0f26439234 Remove variable per pyflakes 2013-07-20 12:52:17 -04:00
Michael DeHaan
2cb7c30834 Improve interlaced output prevention when asking for host key approval. 2013-07-04 18:17:45 -04:00
Michael DeHaan
132c89e681 Merge branch 'callbackinit' of git://github.com/sergevanginderachter/ansible into devel 2013-06-18 20:52:43 -04:00
Scott Sturdivant
b10b676158 Print the default value if one is provided. 2013-06-17 14:15:31 -06:00
Serge van Ginderachter
2a7f9df109 add support for callback_plugins/ relative to playbook 2013-06-12 23:54:00 +02:00
WAKAYAMA Shirou
66247042a5 fix utf-8 named task failed with --step. 2013-06-03 22:45:02 +09:00
Michael DeHaan
4840e59b90 Allow cowsay to be removed mid playbook run. 2013-06-01 17:06:40 -04:00
Serge van Ginderachter
dd9919342b hide magic variables used bin/ansible output
'verbose_override' and 'verbose_always'
2013-05-27 14:42:55 +02:00