|
|
@ -51,6 +51,14 @@ class AnsibleCollection:
|
|
|
|
return load(file, Loader=CSafeLoader)
|
|
|
|
return load(file, Loader=CSafeLoader)
|
|
|
|
|
|
|
|
|
|
|
|
def install(self, destdir: Union[str, Path]) -> None:
|
|
|
|
def install(self, destdir: Union[str, Path]) -> None:
|
|
|
|
|
|
|
|
artifact = self.collection_srcdir / Path(
|
|
|
|
|
|
|
|
f"{self.namespace}-{self.name}-{self.version}.tar.gz"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if not artifact.exists() and not artifact.is_file():
|
|
|
|
|
|
|
|
raise CollectionError(
|
|
|
|
|
|
|
|
f"{artifact} does not exist! Did you run %ansible_collection_build?"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
args = (
|
|
|
|
args = (
|
|
|
|
"ansible-galaxy",
|
|
|
|
"ansible-galaxy",
|
|
|
|
"collection",
|
|
|
|
"collection",
|
|
|
@ -58,11 +66,12 @@ class AnsibleCollection:
|
|
|
|
"-n",
|
|
|
|
"-n",
|
|
|
|
"-p",
|
|
|
|
"-p",
|
|
|
|
str(destdir),
|
|
|
|
str(destdir),
|
|
|
|
f"{self.namespace}-{self.name}-{self.version}.tar.gz",
|
|
|
|
str(artifact),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print(f"Running: {args}")
|
|
|
|
print(f"Running: {args}")
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
subprocess.run(args, check=True, cwd=self.collection_srcdir)
|
|
|
|
subprocess.run(args, check=True, cwd=self.collection_srcdir)
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
def write_filelist(self, filelist: Path) -> None:
|
|
|
|
def write_filelist(self, filelist: Path) -> None:
|
|
|
|
filelist.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
filelist.parent.mkdir(parents=True, exist_ok=True)
|
|
|
@ -134,5 +143,5 @@ def main():
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|
except CollectionError as err:
|
|
|
|
except (CollectionError, subprocess.CalledProcessError) as err:
|
|
|
|
sys.exit(err)
|
|
|
|
sys.exit(err)
|
|
|
|