10
10
import shutil
11
11
import subprocess
12
12
import sys
13
- import tempfile
14
13
import warnings
15
14
from collections import OrderedDict
16
15
from dataclasses import dataclass , field
@@ -456,13 +455,13 @@ def install_collection(
456
455
cmd .append (f"{ collection } " )
457
456
458
457
_logger .info ("Running from %s : %s" , Path .cwd (), " " .join (cmd ))
459
- run = self .run (
458
+ process = self .run (
460
459
cmd ,
461
460
retry = True ,
462
461
env = {** self .environ , ansible_collections_path (): ":" .join (cpaths )},
463
462
)
464
- if run .returncode != 0 :
465
- msg = f"Command returned { run .returncode } code:\n { run .stdout } \n { run .stderr } "
463
+ if process .returncode != 0 :
464
+ msg = f"Command returned { process .returncode } code:\n { process .stdout } \n { process .stderr } "
466
465
_logger .error (msg )
467
466
raise InvalidPrerequisiteError (msg )
468
467
@@ -472,30 +471,8 @@ def install_collection_from_disk(
472
471
destination : Path | None = None ,
473
472
) -> None :
474
473
"""Build and install collection from a given disk path."""
475
- if not self .version_in_range (upper = "2.11" ):
476
- self .install_collection (path , destination = destination , force = True )
477
- return
478
- # older versions of ansible able unable to install without building
479
- with tempfile .TemporaryDirectory () as tmp_dir :
480
- cmd = [
481
- "ansible-galaxy" ,
482
- "collection" ,
483
- "build" ,
484
- "--output-path" ,
485
- str (tmp_dir ),
486
- str (path ),
487
- ]
488
- _logger .info ("Running %s" , " " .join (cmd ))
489
- run = self .run (cmd , retry = False )
490
- if run .returncode != 0 :
491
- _logger .error (run .stdout )
492
- raise AnsibleCommandError (run )
493
- for archive_file in os .listdir (tmp_dir ):
494
- self .install_collection (
495
- str (Path (tmp_dir ) / archive_file ),
496
- destination = destination ,
497
- force = True ,
498
- )
474
+ # breakpoint()
475
+ self .install_collection (path , destination = destination , force = True )
499
476
500
477
# pylint: disable=too-many-branches
501
478
def install_requirements ( # noqa: C901
@@ -791,7 +768,7 @@ def _prepare_ansible_paths(self) -> None:
791
768
792
769
if library_paths != self .config .DEFAULT_MODULE_PATH :
793
770
self ._update_env ("ANSIBLE_LIBRARY" , library_paths )
794
- if collections_path != self .config .collections_paths :
771
+ if collections_path != self .config .default_collections_path :
795
772
self ._update_env (ansible_collections_path (), collections_path )
796
773
if roles_path != self .config .default_roles_path :
797
774
self ._update_env ("ANSIBLE_ROLES_PATH" , roles_path )
0 commit comments