Fix ansible-test config management.

pull/31329/head
Matt Clay 7 years ago
parent aa658c64ec
commit a333f2e5b0

@ -4,7 +4,14 @@ from __future__ import absolute_import, print_function
import os import os
from lib.util import common_environment from lib.util import (
common_environment,
ApplicationError,
)
from lib.config import (
IntegrationConfig,
)
def ansible_environment(args, color=True): def ansible_environment(args, color=True):
@ -21,19 +28,24 @@ def ansible_environment(args, color=True):
if not path.startswith(ansible_path + os.pathsep): if not path.startswith(ansible_path + os.pathsep):
path = ansible_path + os.pathsep + path path = ansible_path + os.pathsep + path
if isinstance(args, IntegrationConfig):
ansible_config = 'test/integration/%s.cfg' % args.command
else:
ansible_config = 'test/%s/ansible.cfg' % args.command
if not os.path.exists(ansible_config):
raise ApplicationError('Configuration not found: %s' % ansible_config)
ansible = dict( ansible = dict(
ANSIBLE_FORCE_COLOR='%s' % 'true' if args.color and color else 'false', ANSIBLE_FORCE_COLOR='%s' % 'true' if args.color and color else 'false',
ANSIBLE_DEPRECATION_WARNINGS='false', ANSIBLE_DEPRECATION_WARNINGS='false',
ANSIBLE_HOST_KEY_CHECKING='false', ANSIBLE_HOST_KEY_CHECKING='false',
ANSIBLE_CONFIG=os.path.abspath(ansible_config),
PYTHONPATH=os.path.abspath('lib'), PYTHONPATH=os.path.abspath('lib'),
PAGER='/bin/cat', PAGER='/bin/cat',
PATH=path, PATH=path,
) )
if os.path.isfile('test/integration/%s.cfg' % args.command):
ansible_config = os.path.abspath('test/integration/%s.cfg' % args.command)
ansible['ANSIBLE_CONFIG'] = ansible_config
env.update(ansible) env.update(ansible)
if args.debug: if args.debug:

Loading…
Cancel
Save