ansible_playbook_python (#18530)
* ansible_playbook_python fixes #18471 * fix tests * removed dupe
This commit is contained in:
parent
21813ed83e
commit
778c983ef9
5 changed files with 11 additions and 9 deletions
|
@ -13,6 +13,7 @@ Ansible Changes By Release
|
|||
any user can add back via config options if they don't use those package managers or othewise avoid the errors.
|
||||
* Blocks can now have a `name` field, to aid in playbook readability.
|
||||
* default strategy is now configurable via ansible.cfg or environment variable.
|
||||
* Added 'ansible_playbook_python' which contains 'current python executable', it can be blank in some cases in which Ansible is not invoked via the standard CLI (sys.executable limitation).
|
||||
|
||||
###Deprecations:
|
||||
* Specifying --tags (or --skip-tags) multiple times on the command line
|
||||
|
|
|
@ -681,6 +681,8 @@ period, without the rest of the domain.
|
|||
.. versionadded:: 2.2
|
||||
``ansible_play_batch`` is available as a list of hostnames that are in scope for the current 'batch' of the play. The batch size is defined by ``serial``, when not set it is equivalent to the whole play (making it the same as ``ansible_play_hosts``).
|
||||
|
||||
.. versionadded:: 2.3
|
||||
``ansible_playbook_python`` is the path to the python executable used to invoke the Ansible command line tool.
|
||||
|
||||
These vars may be useful for filling out templates with multiple hostnames or for injecting the list into the rules for a load balancer.
|
||||
|
||||
|
|
|
@ -694,7 +694,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
pass
|
||||
|
||||
# remove some KNOWN keys
|
||||
for hard in ['ansible_rsync_path']:
|
||||
for hard in ['ansible_rsync_path', 'ansible_playbook_python']:
|
||||
if hard in fact_keys:
|
||||
remove_keys.add(hard)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
|
|||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from collections import defaultdict, MutableMapping
|
||||
|
||||
|
@ -392,6 +393,7 @@ class VariableManager:
|
|||
|
||||
variables = dict()
|
||||
variables['playbook_dir'] = loader.get_basedir()
|
||||
variables['ansible_playbook_python'] = sys.executable
|
||||
|
||||
if host:
|
||||
variables['group_names'] = sorted([group.name for group in host.get_groups() if group.name != 'all'])
|
||||
|
|
|
@ -47,14 +47,11 @@ class TestVariableManager(unittest.TestCase):
|
|||
|
||||
v = VariableManager()
|
||||
vars = v.get_vars(loader=fake_loader, use_cache=False)
|
||||
if 'omit' in vars:
|
||||
del vars['omit']
|
||||
if 'vars' in vars:
|
||||
del vars['vars']
|
||||
if 'ansible_version' in vars:
|
||||
del vars['ansible_version']
|
||||
if 'ansible_check_mode' in vars:
|
||||
del vars['ansible_check_mode']
|
||||
|
||||
#FIXME: not sure why we remove all and only test playbook_dir
|
||||
for remove in ['omit', 'vars', 'ansible_version', 'ansible_check_mode', 'ansible_playbook_python']:
|
||||
if remove in vars:
|
||||
del vars[remove]
|
||||
|
||||
self.assertEqual(vars, dict(playbook_dir='.'))
|
||||
|
||||
|
|
Loading…
Reference in a new issue