|
| 1 | +******************************** |
| 2 | +Ansible Runner 2.5 Porting Guide |
| 3 | +******************************** |
| 4 | + |
| 5 | +This section discusses the behavioral changes between ``ansible-runner`` version 2.4 and version 2.5. |
| 6 | + |
| 7 | +.. contents:: Topics |
| 8 | + |
| 9 | +Changes to the Python Interface |
| 10 | +=============================== |
| 11 | + |
| 12 | +:ref:`Remote job execution <remote_jobs>` could experience problems when transmitting job arguments |
| 13 | +to a worker node with an older version of ``ansible-runner``. If the older worker received a job |
| 14 | +argument that it did not understand, like a new API value, that worker would terminate abnormally. |
| 15 | +To address this, a two-stage plan was devised: |
| 16 | + |
| 17 | +#. Modify the streaming job arguments so that only job arguments that have non-default values are |
| 18 | + streamed to the worker node. A new API job argument will not be problematic for older workers |
| 19 | + unless that argument is actually used. |
| 20 | +#. Have the worker node fail gracefully on unrecognized job arguments. |
| 21 | + |
| 22 | +The first step of this process is implemented in this version of ``ansible-runner``. The second |
| 23 | +step will be completed in a future version. |
| 24 | + |
| 25 | +For this change, it was necessary to modify how the ``run()`` and ``run_async()`` functions |
| 26 | +of the :ref:`Python API <python_interface>` are implemented. The API function arguments are now completely |
| 27 | +defined in the ``RunnerConfig`` object where we can have better control of the job arguments, and both |
| 28 | +functions now take an optional ``config`` parameter. |
| 29 | + |
| 30 | +For backward compatibility, keyword arguments to the ``run()/run_async()`` API functions are passed |
| 31 | +along to the ``RunnerConfig`` object initialization for you. Alternatively, you may choose to use |
| 32 | +the more up-to-date signature of those API functions where you pass in a manually created ``RunnerConfig`` |
| 33 | +object. For example: |
| 34 | + |
| 35 | +.. code-block:: python |
| 36 | +
|
| 37 | + import ansible_runner |
| 38 | + config = ansible_runner.RunnerConfig('private_data_dir': '/tmp/demo', 'playbook': 'test.yml') |
| 39 | + r = ansible_runner.interface.run(config=config) |
| 40 | +
|
| 41 | +The above is identical to the more familiar usage of the API: |
| 42 | + |
| 43 | +.. code-block:: python |
| 44 | +
|
| 45 | + import ansible_runner |
| 46 | + r = ansible_runner.interface.run('private_data_dir': '/tmp/demo', 'playbook': 'test.yml') |
0 commit comments