mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
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
This commit is contained in:
parent
c18da65089
commit
afdbb0d9d5
36 changed files with 1033 additions and 868 deletions
|
@ -148,6 +148,21 @@ Plugins
|
|||
|
||||
* Order of enabled inventory plugins (:ref:`INVENTORY_ENABLED`) has been updated, :ref:`auto <auto_inventory>` is now before :ref:`yaml <yaml_inventory>` and :ref:`ini <ini_inventory>`.
|
||||
|
||||
* The private ``_options`` attribute has been removed from the ``CallbackBase`` class of callback
|
||||
plugins. If you have a third-party callback plugin which needs to access the command line arguments,
|
||||
use code like the following instead of trying to use ``self._options``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from ansible import context
|
||||
[...]
|
||||
tags = context.CLIARGS['tags']
|
||||
|
||||
``context.CLIARGS`` is a read-only dictionary so normal dictionary retrieval methods like
|
||||
``CLIARGS.get('tags')`` and ``CLIARGS['tags']`` work as expected but you won't be able to modify
|
||||
the cli arguments at all.
|
||||
|
||||
|
||||
Porting custom scripts
|
||||
======================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue