Commit Graph

48 Commits (devel)

Author SHA1 Message Date
Brian Coca 949c503f2e
config, integrate dynamic galaxy servers (#83129)
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
3 days ago
Matt Clay 9f899f9492
Require `from __future__ import annotations` (#81902) 8 months ago
Matt Clay 2cd1744be3
Use ansible.module_utils.common.text.converters (#80704)
Replace use of old `ansible.module_utils._text` and add a unit test to maintain backwards compatibility.
1 year ago
Sloane Hertel b981a9dfcd
add a worker queue to get updates from the main results thread (#79886)
* Create a queue per WorkerProcess to receive intra-task updates
* Update `pause` action to use the worker queue
* Deprecate ConnectionBase()._new_stdin
* Add new `Display`  convenience method `prompt_until` to manage both controller- and worker-sourced prompting without cross-fork stdin sharing, in-worker mechanism to handle request-response over new worker queue.
1 year ago
Brian Coca 4260b71cc7
refactor and fixes for doc parsing (#77719)
* refactor and remove redundant code in documentation

  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes #77764
  move to constants vs hardcoded
  more informative errors and comments
  now have actual filter/test plugins, which expose the filter/test functions
  moved filter/test loading/finding logic into jinja2pluginloader, removed dupe implementations
  added tests for case in which we unique by basename when listing

Update lib/ansible/utils/plugin_docs.py
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
2 years ago
Matt Clay f68c66a3ef Remove collections compat from controller code. 2 years ago
Brian Coca 22330dd322
Correctly set path and fullpath for template vars (#73924)
* Correctly set path and fullpath for template vars

 don't expect path to always be full path
 also added exception/tb on action fail
3 years ago
Sam Doran e8d4b62b41
Fix YAML error message when error is at the end of the file (#73241)
* Fix YAML error message when error is at the end of the file

If a YAML file fails to load due to a syntax error in a file, or there is an error in the last line of a
file, PyYAML reports the last line number of the file as the index where the error occurred.

When reading the file lines, we use that index to the get the relevant line.  If the index value is out
of range, the relevant line is lost for error reporting.

Subtract one from the index value to avoid the IndexError in this specific scenario. It is possible
to still get an IndexError, which will be handled as it is currently.

* Update existing tests and add new tests
3 years ago
Matt Martz 46198cf80a
Add orig_exc context to error messages (#72677)
* Add orig_exc context to error messages. Fixes #68605

* Fix string formatting
4 years ago
Matt Martz f8ef34672b
Provide better decryption errors for single vault values (#72362)
Fixes #72276
Fixes #72281
4 years ago
Brian Coca cf89ca8a03
Make filter type errors 'loop friendly' (#70417)
- ensure we preserve the typeerror part of the exception so loop defereed error handling
 can postpone those caused by undefined variables until the when check is done.
 - fix tests to comply with the 'new normal'

 - human_to_bytes and others can issue TypeError not only on 'non string'
 but also bad string that is not convertable.

Co-authored-by: Sloane Hertel <shertel@redhat.com>

Co-authored-by: Sloane Hertel <shertel@redhat.com>
4 years ago
Matt Davis 984216f52e
various deprecation, display, warning, error fixes for collections redirection (#69822)
* various deprecation, display, warning, error fixes

* Update lib/ansible/utils/display.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update lib/ansible/utils/display.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update lib/ansible/utils/display.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* cleanup, test fixes

* add collection name to deprecated() calls

* clean up redirect entries from uncommitted tests

* fix dep warning/error header text to match previous

Co-authored-by: Felix Fontein <felix@fontein.de>
4 years ago
Matt Davis f7dfa817ae
collection routing (#67684)
* `meta/` directory in collections
* runtime metadata for redirection/deprecation/removal of plugin loads
* a compatibility layer to keep existing content working on ansible-base + collections
* a Python import redirection layer to keep collections-hosted (and otherwise moved) content importable by things that don't know better
* supported Ansible version validation on collection loads
4 years ago
Abhijeet Kasurde 9a13d56b26
Misc typo fixes (#66120)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
4 years ago
Abhijeet Kasurde 8d0c2cd4d5 include_vars: Check NoneType for raw_params (#64979)
Lookup 'first_found' returns empty list which results in
raw_params checking. Check NoneType for 'raw_params' before
proceeding.

Fixes: #64939

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
5 years ago
Sam Doran 9d4c0dc111 Catch sshpass authentication errors and don't retry multiple times to prevent account lockout (#50776)
* Catch SSH authentication errors and don't retry multiple times to prevent account lock out

Signed-off-by: Sam Doran <sdoran@redhat.com>

* Subclass AnsibleAuthenticationFailure from AnsibleConnectionFailure

Use comparison rather than range() because it's much more efficient.

Signed-off-by: Sam Doran <sdoran@redhat.com>

* Add tests

Signed-off-by: Sam Doran <sdoran@redhat.com>

* Make paramiko_ssh connection plugin behave the same way

Signed-off-by: Sam Doran <sdoran@redhat.com>

* Add changelog

Signed-off-by: Sam Doran <sdoran@redhat.com>
5 years ago
Brian Coca 8fd0fbe431 remove usless tb initiator
always pass proper tb
5 years ago
Matt Martz 9abeecb6d4
Add new AnsibleTemplateError to more easily catch templating issues (#50563)
* Add new AnsibleTemplateError to more easily catch templating issues. Fixes #50154

* Add changelog fragment
5 years ago
Sam Doran 40a5f7bfdf Add better error when k=v syntax is used with YAML in tasks (#41754)
* Add error message for k=v and YAML in a single task

Find the correct line, column, and position for k=v errors since they are different than the position reported initially.

Document bug in quoting syntax check.

* Change tense or error message

Since the error still exists, switch to present tense rather than past tense.

* Remove double spaces after periods in error messages.

http://www.slate.com/articles/technology/technology/2011/01/space_invaders.html

* Add changelog fragment

* Add tests for new error message

* Fix tests

* Add clarifying comments to unit test
6 years ago
Matt Clay a11f631ee4 Python 3.8 collections compatibility fixes.
Includes a new pylint blacklist plugin to prevent regressions.
6 years ago
Brian Coca 34c002c771 give hint to users when a file is not found 6 years ago
Toshio Kuratomi 32eef49062 Make AnsibleActionDone a private exception
We're going to remove this in the future so mark it private so people
are less likely to use it.
6 years ago
Brian Coca bbd6b8bb42 Temporary (#31677)
* allow shells to have per host options, remote_tmp

added language to shell
removed module lang setting from general as  plugins have it now
use get to avoid bad powershell plugin
more resilient tmp discovery, fall back to `pwd`
add shell to docs
fixed options for when frags are only options
added shell set ops in t_e and fixed option frags
normalize tmp dir usag4e

- pass tmpdir/tmp/temp options as env var to commands, making it default for tempfile
- adjusted ansiballz tmpdir
- default local tempfile usage to the configured local tmp
- set env temp in action

add options to powershell
shift temporary to internal envvar/params
ensure tempdir is set if we pass var
ensure basic and url use expected tempdir
ensure localhost uses local tmp
give /var/tmp priority, less perms issues
more consistent tempfile mgmt for ansiballz
made async_dir configurable
better action handling, allow for finally rm tmp
fixed tmp issue and no more tempdir in ballz
hostvarize world readable and admin users
always set shell tempdir
added comment to discourage use of exception/flow control

* Mostly revert expand_user as it's not quite working.

This was an additional feature anyhow.

Kept the use of pwd as a fallback but moved it to a second ssh
connection.  This is not optimal but getting that to work in a single
ssh connection was part of the problem holding this up.

(cherry picked from commit 395b714120522f15e4c90a346f5e8e8d79213aca)

* fixed script and other action plugins

ensure tmpdir deletion
allow for connections that don't support new options (legacy, 3rd party)
fixed tests
6 years ago
Toshio Kuratomi 5a80375be9 Correct the AnsibleError exception to call its superclass's constructor 7 years ago
Matt Martz 99d4f5bab4 Remove uses of assert in production code (#32079)
* Remove uses of assert in production code

* Fix assertion

* Add code smell test for assertions, currently limited to lib/ansible

* Fix assertion

* Add docs for no-assert

* Remove new assert from enos

* Fix assert in module_utils.connection
7 years ago
Brian Coca e05dacfe91 more info on yaml errors
print yaml's 'problem'
7 years ago
Brian Coca 9c6d7ddeb5 report extra info in verbose and if needed 7 years ago
Brian Coca f921369445 Ansible Config part2 (#27448)
* Ansible Config part2

- made dump_me nicer, added note this is not prod
- moved internal key removal function to vars
- carry tracebacks in errors we can now show tracebacks for plugins on vvv
- show inventory plugin tracebacks on vvv
- minor fixes to cg groups plugin
- draft config from plugin docs
- made search path warning 'saner' (top level dirs only)
- correctly display config entries and others
- removed unneeded code
- commented out some conn plugin specific from base.yml
- also deprecated sudo/su
- updated ssh conn docs
- shared get option method for connection plugins
- note about needing eval for defaults
- tailored yaml ext
- updated strategy entry
- for connection pliugins, options load on plugin load
- allow for long types in definitions
- better display in ansible-doc
- cleaned up/updated source docs and base.yml
- added many descriptions
- deprecated include toggles as include is
- draft backwards compat get_config
- fixes to ansible-config, added --only-changed
- some code reoorg
- small license headers
- show default in doc type
- pushed module utils details to 5vs
- work w/o config file
- PEPE ATE!
- moved loader to it's own file
- fixed rhn_register test
- fixed boto requirement in make tests
- I ate Pepe
- fixed dynamic eval of defaults
- better doc code

skip ipaddr filter tests when missing netaddr
removed devnull string from config
better becoem resolution

* killed extra space with extreeme prejudice

cause its an affront against all that is holy that 2 spaces touch each other!

shippable timing out on some images, but merging as it passes most
7 years ago
Brian Coca 8f758204cf correct, cleanup & simplify dwim stack (#25956)
* correct, cleanup & simplify dwim stack

latlh chIS logh HeS qar wej chel laD
better errors
update find_file to new exception

* addressed latest comments

* test should not use realpath as it follows symlink

this fails when on OS X as /var is now a symlink to /private/var
but first_found was not supposed to follow symlinks
7 years ago
Adrian Likins 4befefd78c Try to show original exception info for yaml (and other) errors (#24468)
* show original exception for yaml (and other) errors

In places where we need to catch a yaml error and raise
an AnsibleError, add the orig yaml exc to the AnsibleError
via the orig_exc arg.

When the AnsibleError is displayed it will now include the
AnsibleError (AnsibleParserError for example) and the type
and message from the original yaml exception.

This provides more detail to the error messages related to
yaml errors.

This also improves errors from dataloader (for example,
previously if a wrong password was used for a vault encrypted
yaml file, the error was very vague and suggested yaml errors,
but now the message includes the original exception from vault
indicating the password was incorrect or missing).

Add a text note to playbook helper asserts. For playbook
syntax/layout errors that aren't yaml errors, but errors
indicating invalid data structures for a playbook/task/role/block,
we now include some info about where the assert was and
why it was raised.

In places we raise an AnsibleParserError in an except
clause, pass the original exception to AnsibleParserError via
orig_exc arg.

Make assorted error messages a little more specific (like
the playbook helper load methods)

* Revert "Include the original YAML error in syntax error messages"

This reverts commit 781bb44b02.
7 years ago
Dag Wieers ac27c54c2e ansible/errors: PEP8 compliancy (#24693)
- Make PEP8 compliant
7 years ago
Brian Coca e29dc49a49 moved to exceptions for basic skip/fails
better handling of checkmode and async
fix test to follow new flow control
7 years ago
Matt Martz 3164e8b561 E501 fixes (#22879) 7 years ago
Peter Sprygada cdb4d350b4 removes unneeded exception 7 years ago
Peter Sprygada 0cef38cf02 adds feature to all modules to be run locally (#18763)
* adds new error AnsibleModuleExit to handle module returns
* adds new action plugin network for attaching connection to network modules
* adds new shared module local to receive connection
* splits out function to update task_args with common updates

This commit provides a mechansim for running local modules that require
a connection object for interative commands tyically implemented for
network devices.  It provides a way to locally import modules (post fork)
and run them using exception handling to exit.
8 years ago
Adrian Likins 51e3ef89a9 Add error info if tabs are found in the yaml (#18343)
If a yaml file fails to load because of tabs being used
for formatting, detect that and show a error message
with more details.
8 years ago
Toshio Kuratomi 4ed88512e4 Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423)
We couldn't copy to_unicode, to_bytes, to_str into module_utils because
of licensing.  So once created it we had two sets of functions that did
the same things but had different implementations.  To remedy that, this
change removes the ansible.utils.unicode versions of those functions.
8 years ago
Shota 47f715fb37 Fix some typos (#16498) 8 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
8 years ago
James Cammarata b1223746cd Relocate use of ERROR to display class, to avoid doubling up 8 years ago
Brian Coca 9f05ce3e2b be consistent about conversion to_str 8 years ago
Yannig Perré e5ea576461 Allow Ansible to return error with unicode within it.
Fix for https://github.com/ansible/ansible/issues/13899
9 years ago
James Cammarata 8ff67e0494 Default msg param to AnsibleError to avoid serialization problems 9 years ago
Toshio Kuratomi a526eae543 Clean up a few more pyflakes warnings 9 years ago
Marius Gedminas ab569cea22 Move to_str alias into ansible.utils.unicode
@abadger suggested on IRC that it's useful enough to go into
ansible.utils.unicode.
9 years ago
Marius Gedminas ca826508d9 Python 3: fix AnsibleError formatting
If you convert the error string to bytes and embed it inside another
error string, you get

  Prefix:

  b'Embedded\nerror\nstring'

which is not what we want.

But we also don't want Unicode in error messages causing unexpected
UnicodeEncodeErrors when on Python 2.

So let's convert the error message into the native string type (bytes on
Python 2, unicode on Python 3).
9 years ago
James Cammarata de792ba3c2 Improve handling of unicode errors
Fixes #12669
9 years ago
James Cammarata ce3ef7f4c1 Making the switch to v2 9 years ago