Fix ansible-test config management.

(cherry picked from commit a333f2e5b0)
This commit is contained in:
Matt Clay 2017-10-04 11:36:53 -07:00
parent dff33071d0
commit 2572b2147e
5 changed files with 17 additions and 5 deletions

View file

View file

View file

@ -4,7 +4,14 @@ from __future__ import absolute_import, print_function
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):
@ -21,19 +28,24 @@ def ansible_environment(args, color=True):
if not path.startswith(ansible_path + os.pathsep):
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_FORCE_COLOR='%s' % 'true' if args.color and color else 'false',
ANSIBLE_DEPRECATION_WARNINGS='false',
ANSIBLE_HOST_KEY_CHECKING='false',
ANSIBLE_CONFIG=os.path.abspath(ansible_config),
PYTHONPATH=os.path.abspath('lib'),
PAGER='/bin/cat',
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)
if args.debug:

0
test/sanity/ansible.cfg Normal file
View file

0
test/units/ansible.cfg Normal file
View file