ansible-test - Fix delegation inventory path.

pull/77277/head
Matt Clay 3 years ago
parent b60a5eefb2
commit e8afdac06e

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix ``windows-integration`` and ``network-integration`` when used with the ``--docker`` option and user-provided inventory.

@ -92,6 +92,7 @@ from ...data import (
)
from ...host_configs import (
InventoryConfig,
OriginConfig,
)
@ -183,6 +184,18 @@ def check_inventory(args, inventory_path): # type: (IntegrationConfig, str) ->
display.warning('Use of "ansible_ssh_private_key_file" in inventory with the --docker or --remote option is unsupported and will likely fail.')
def get_inventory_absolute_path(args: IntegrationConfig, target: InventoryConfig) -> str:
"""Return the absolute inventory path used for the given integration configuration or target inventory config (if provided)."""
path = target.path or os.path.basename(get_inventory_relative_path(args))
if args.host_path:
path = os.path.join(data_context().content.root, path) # post-delegation, path is relative to the content root
else:
path = os.path.join(data_context().content.root, data_context().content.integration_path, path)
return path
def get_inventory_relative_path(args): # type: (IntegrationConfig) -> str
"""Return the inventory path used for the given integration configuration relative to the content root."""
inventory_names = {

@ -23,6 +23,7 @@ from ...config import (
from . import (
command_integration_filter,
command_integration_filtered,
get_inventory_absolute_path,
get_inventory_relative_path,
check_inventory,
delegate_inventory,
@ -46,8 +47,11 @@ def command_network_integration(args): # type: (NetworkIntegrationConfig) -> No
template_path = os.path.join(ANSIBLE_TEST_CONFIG_ROOT, os.path.basename(inventory_relative_path)) + '.template'
if issubclass(args.target_type, NetworkInventoryConfig):
inventory_path = os.path.join(data_context().content.root, data_context().content.integration_path,
args.only_target(NetworkInventoryConfig).path or os.path.basename(inventory_relative_path))
target = args.only_target(NetworkInventoryConfig)
inventory_path = get_inventory_absolute_path(args, target)
if args.delegate or not target.path:
target.path = inventory_relative_path
else:
inventory_path = os.path.join(data_context().content.root, inventory_relative_path)

@ -34,6 +34,7 @@ from ...host_configs import (
from . import (
command_integration_filter,
command_integration_filtered,
get_inventory_absolute_path,
get_inventory_relative_path,
check_inventory,
delegate_inventory,
@ -52,8 +53,11 @@ def command_windows_integration(args): # type: (WindowsIntegrationConfig) -> No
template_path = os.path.join(ANSIBLE_TEST_CONFIG_ROOT, os.path.basename(inventory_relative_path)) + '.template'
if issubclass(args.target_type, WindowsInventoryConfig):
inventory_path = os.path.join(data_context().content.root, data_context().content.integration_path,
args.only_target(WindowsInventoryConfig).path or os.path.basename(inventory_relative_path))
target = args.only_target(WindowsInventoryConfig)
inventory_path = get_inventory_absolute_path(args, target)
if args.delegate or not target.path:
target.path = inventory_relative_path
else:
inventory_path = os.path.join(data_context().content.root, inventory_relative_path)

Loading…
Cancel
Save