Commit Graph

158 Commits (66a83314b9d30c6a139de960e6da8d5554c28544)

Author SHA1 Message Date
Matt Martz 66a83314b9
Modernize install (#76021)
Co-authored-by: Matt Clay <matt@mystile.com>
Co-authored-by: Matt Davis <mrd@redhat.com>
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
3 years ago
Matt Davis 8d1f658ce4
move CLI entrypoints under ansible package (#60004)
* needed so ansible-test can always find the right ones to copy to a target
* renamed the underlying scripts to be properly accessible as Python modules
5 years ago
Sam Doran 6cf6f5a34b
Use atexit to cleanup tmp dirs (#56532)
* Wrap everything in try/except to avoid leaving files behind
* Add unit tests, integration tests, and changelog
* Do text the correct way
5 years ago
Matt Martz db6cc60352
Migrate command line parsing to argparse (#50610)
* Start of migration to argparse

* various fixes and improvements

* Linting fixes

* Test fixes

* Fix vault_password_files

* Add PrependAction for argparse

* A bunch of additional tweak/fixes

* Fix ansible-config tests

* Fix man page generation

* linting fix

* More adhoc pattern fixes

* Add changelog fragment

* Add support for argcomplete

* Enable argcomplete global completion

* Rename PrependAction to PrependListAction to better describe what it does

* Add documentation for installing and configuring argcomplete

* Address rebase issues

* Fix display encoding for vault

* Fix line length

* Address rebase issues

* Handle rebase issues

* Use mutually exclusive group instead of handling manually

* Fix rebase issues

* Address rebase issue

* Update version added for argcomplete support

* -e must be given a value

* ci_complete
5 years ago
Toshio Kuratomi afdbb0d9d5 Save the command line arguments into a global context
* Once cli args are parsed, they're constant.  So, save the parsed args
  into the global context for everyone else to use them from now on.
* Port cli scripts to use the CLIARGS in the context
* Refactor call to parse cli args into the run() method
* Fix unittests for changes to the internals of CLI arg parsing
* Port callback plugins to use context.CLIARGS
  * Got rid of the private self._options attribute
  * Use context.CLIARGS in the individual callback plugins instead.
  * Also output positional arguments in default and unixy plugins
  * Code has been simplified since we're now dealing with a dict rather
    than Optparse.Value
5 years ago
Toshio Kuratomi 4d9504e775 Remove runtime usage of pkg_resources.
This should provide a startup time speed boost at the expense of making
it harder to get ansible to use newer versions of packages than are
provided by the platform.
6 years ago
Toshio Kuratomi 06f73ad578
Normalize usage of temp and tmp on tmp (#36221)
* Normalize usage of temp and tmp on tmp
* Rename system_tmps system_tmpdirs
* Add ANSIBLE_REMOTE_TMP spelling of environment variables
6 years ago
Matt Martz 55352bdda4
Error early if executing python version doesn't meet documented minimums (#34655)
* Error early if executing python version doesn't meet documented minimums. Fixes #34597

* Make recommended enhancements
6 years ago
Julien Palard 53d9f9ffae Allow PDB to enter post mortem. fixes (#31086) 7 years ago
Brian Coca 9c6d7ddeb5 report extra info in verbose and if needed 7 years ago
Brian Coca 76aaaf127b nicer error on bad ansible config (#30461)
* nicer error on bad ansible config
7 years ago
Matt Clay 442af3744e Miscellaneous pylint fixes.
The following rules are no longer disabled:

- bad-format-string
- duplicate-key
- lost-exception
- trailing-newlines
- unexpected-keyword-arg
- useless-suppression
- using-constant-test
7 years ago
Matt Clay 8e0b5800b7 Miscellaneous ansible-test fixes. (#28355)
* Include .github in test targets. Fix BOTMETA.yml.
* Include bin in compile tests.
* Exclude links from test targets.
* Include bin in pep8 and pylint tests.
* Fix pep8 and pylint issues in bin dir.
7 years ago
loqutus 820c99c90b bin/ansible comment typo fix (#25799)
insignificant bin/ansible typo in word 'python'
7 years ago
Brian Coca 74842adc07 1st part of ansible config, adds ansible-config to view/manage configs (#12797)
* Start of ansible config project

moved configuration definitions to external yaml file vs hardcoded
 * updated constants to be a data strcutures that are looped over and also return origin of setting
changed to manager/data scheme for base classes
new cli ansible-config to view/manage ansible configuration settings
 * prints green for default/unchanged and yellow for those that have been overriden
 * added list action to show all configurable settings and their associated ini and env var names
 * allows specifying config file to see what result would look like
 * TBD update, edit and view options

removed test for functions that have been removed

env_Vars are now list of dicts
allows for version_added and deprecation in future
added a couple of descriptions for future doc autogeneration
ensure test does not fail if delete_me exists
normalized 'path expansion'
added yaml config to setup packaging
removed unused imports
better encoding handling

updated as per feedback

* pep8
7 years ago
Brian Coca 8f97aef1a3 Transition inventory into plugins (#23001)
* draft new inventory plugin arch, yaml sample

 - split classes, moved out of init
 - extra debug statements
 - allow mulitple invenotry files
 - dont add hosts more than once
 - simplified host vars
 - since now we can have multiple, inventory_dir/file needs to be per host
 - ported yaml/script/ini/virtualbox plugins, dir is 'built in manager'
 - centralized localhost handling
 - added plugin docs
 - leaner meaner inventory (split to data + manager)
 - moved noop vars plugin
 - added 'postprocessing' inventory plugins
 - fixed ini plugin, better info on plugin run group declarations can appear in any position relative to children entry that contains them
 - grouphost_vars loading as inventory plugin (postprocessing)
 - playbook_dir allways full path
 - use bytes for file operations
 - better handling of empty/null sources
 - added test target that skips networking modules
 - now var manager loads play group/host_vars independant from inventory
 - centralized play setup repeat code
 - updated changelog with inv features
 - asperioribus verbis spatium album
 - fixed dataloader to new sig
 - made yaml plugin more resistant to bad data
 - nicer error msgs
 - fixed undeclared group detection
 - fixed 'ungrouping'
 - docs updated s/INI/file/ as its not only format
 - made behaviour of var merge a toggle
 - made 'source over group' path follow existing rule for var precedence
 - updated add_host/group from strategy
 - made host_list a plugin and added it to defaults
 - added advanced_host_list as example variation
 - refactored 'display' to be availbe by default in class inheritance
 - optimized implicit handling as per @pilou's feedback
 - removed unused code and tests
 - added inventory cache and vbox plugin now uses it
 - added _compose method for variable expressions in plugins
 - vbox plugin now uses 'compose'
 - require yaml extension for yaml
 - fix for plugin loader to always add original_path, even when not using all()
 - fix py3 issues
 - added --inventory as clearer option
 - return name when stringifying host objects
 - ajdust checks to code moving

* reworked vars and vars precedence
 - vars plugins now load group/host_vars dirs
 - precedence for host vars is now configurable
 - vars_plugins been reworked
 - removed unused vars cache
 - removed _gathered_facts as we are not keeping info in host anymore
 - cleaned up tests
 - fixed ansible-pull to work with new inventory
 - removed version added notation to please rst check
 - inventory in config relative to config
 - ensures full paths on passed inventories

* implicit localhost connection local
7 years ago
Toshio Kuratomi 9ff03e6c1e Handle downstream version additions (#22428)
Some downstreams want to ship multiple versions of ansible (Either to
have multiple ansible versions or to have a version that uses python3.X
and a version that uses python2.x).  When they do this, they append
a version number to the cli scripts in /usr/bin.  This patch will remove
those version numbers before trying to find the ansible python module to
import for this commandline
7 years ago
TaoBeier 6ec0369c26 fix indent (#20071) 7 years ago
Brian Coca 18d3e0533f always log unexpected exceptions 8 years ago
Toshio Kuratomi bf29961947 Fixes to the controller text model (#17527)
* Fixes to the controller text model

* Change command line args to text type
* Make display replace undecodable bytes with replacement chars.  This
  is only a problem on pyhton3 where surrogates can enter into the msg
  but sys.stdout doesn't know how to handle them.
* Remove a deprecated playbook syntax in unicode.yml

* Fix up run_cmd to change its parameters to byte string at appropriate times.
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
James Cammarata 37f721f315 Remove debug lock 8 years ago
Michael Scherer f0023610e8 Fix bin/ansible to not make a double traceback on python3 (#15972) 8 years ago
Toshio Kuratomi dcc5dfdf81 Controller-side module caching.
This makes our recursive, ast.parse performance measures as fast as
pre-ziploader baseline.

Since this unittest isn't testing that the returned module data is
correct we don't need to worry about os.rename not having any module
data.  Should devise a separate test for the module and caching code
8 years ago
Brian Coca 0eb2844cc6 moved display's debug lock to cli as global 8 years ago
Toshio Kuratomi f4d68b8860 Transform tracebacks into unicode before printing
Fixes #14042
8 years ago
James Cammarata 120b9a7ac6 Changing the way workers are forked 9 years ago
Toshio Kuratomi 318bfbb207 Migrate cli and dependencies to use global display 9 years ago
Brian Coca 10fd717a44 narrow the scope of import error and make sure non - aliases to ansible get their own error 9 years ago
Brian Coca d0a22a7b45 made cli code more flexible to add new command line programs w/o need for updating bin/ansible 9 years ago
Brian Coca 56a2412dc2 now correctly traps unimplemented symlinks as subprograms 9 years ago
Toshio Kuratomi 7c10c16251 Revert "capture some install issues and give out a slightly nicer error"
This reverts commit e6b1dc45e1.

This is not ready yet and it's causing failures in some environments
(travis)
9 years ago
Brian Coca e6b1dc45e1 capture some install issues and give out a slightly nicer error 9 years ago
Toshio Kuratomi f34b55ac2b Add python3-compat boilerplate to all .py files in lib/ansible 9 years ago
James Cammarata de792ba3c2 Improve handling of unicode errors
Fixes #12669
9 years ago
Brian Coca a5e6845c8b Revert "Allow exceptions to pass through the program"
breaks handling constants.py errors gracefully

This reverts commit 59f96d713e.
9 years ago
Will Thames 59f96d713e Allow exceptions to pass through the program
This is useful when using `ipython --pdb -- $(which ansible-playbook)
...` for debugging.

Also show traceback when `ANSIBLE_DEBUG` is on
9 years ago
Brian Coca e49575ff56 added wrap_text to 'last resort' as it fails if there is an error in callbacks 9 years ago
James Cammarata 469aa0c26a Don't wrap text on most errors 9 years ago
James Cammarata 6d50a261c5 Allow full exception tracebacks to be displayed with increased verbosity 9 years ago
Marc Abramowitz 314bae2a9e Don't wrap text for AnsibleParserError
This allows not messing up the wonderful error reporting that is
carefully created. Instead of:

    $ ansible-playbook foo.yml
     [ERROR]: ERROR! 'foo' is not a valid attribute for a Task  The error appears
    to have been in '/Users/marca/dev/git-repos/ansible/foo.yml': line 4, column 7,
    but may be elsewhere in the file depending on the exact syntax problem.  The
    offending line appears to be:    tasks:     - name: do something       ^ here

we get:

    $ ansible-playbook foo.yml
    ERROR! 'foo' is not a valid attribute for a Task

    The error appears to have been in '/Users/marca/dev/git-repos/ansible/foo.yml': line 4, column 7, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

      tasks:
        - name: do something
          ^ here

which is much nicer.
9 years ago
Brian Coca f42b6237d9 now has display of last resort
moved all display/color/err to use display.error
now also capture generic exceptions if they happen (never should!)
9 years ago
Brian Coca 6a75125f32 now traps exceptions on display instantiation 9 years ago
Brian Coca fdeca37257 switched to argv[0] from __file__ as it is what we actually wanted 9 years ago
Brian Coca b85ce38834 slight changes to error handling to align with v1 9 years ago
James Cammarata ce3ef7f4c1 Making the switch to v2 9 years ago
Brian Coca 5f6db0e164 preliminary privlege escalation unification + pbrun
- become constants inherit existing sudo/su ones
- become command line options, marked sudo/su as deprecated and moved sudo/su passwords to runas group
- changed method signatures as privlege escalation is collapsed to become
- added tests for su and become, diabled su for lack of support in local.py
- updated playbook,play and task objects to become
- added become to runner
- added whoami test for become/sudo/su
- added home override dir for plugins
- removed useless method from ask pass
- forced become pass to always be string also uses to_bytes
- fixed fakerunner for tests
- corrected reference in synchronize action plugin
- added pfexec (needs testing)
- removed unused sudo/su in runner init
- removed deprecated info
- updated pe tests to allow to run under sudo and not need root
- normalized become options into a funciton to avoid duplication and inconsistencies
- pushed suppored list to connection classs property
- updated all connection plugins to latest 'become' pe

- includes fixes from feedback (including typos)
- added draft docs
- stub of become_exe, leaving for future v2 fixes
9 years ago
Matt Martz 68358e31fb Allow ansible (ad-hoc) to support --extra-vars also 9 years ago
Toshio Kuratomi fbadcfd44f Fix for not all platforms having optional libraries at the proper versions. 10 years ago
Pete Smith 0953322b23 Remove no-op string declaration 10 years ago