From 8803297109f3424d57906bb7cc03fd3de018d8bc Mon Sep 17 00:00:00 2001 From: emdee Date: Sat, 30 Dec 2023 12:56:08 +0000 Subject: [PATCH] src/ansible_gentooimgr/ --- src/ansible_gentooimgr/README.md | 14 +++++++++++--- .../library/ansible_gentooimgr.py | 15 +++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/ansible_gentooimgr/README.md b/src/ansible_gentooimgr/README.md index c95e93d..80861ec 100644 --- a/src/ansible_gentooimgr/README.md +++ b/src/ansible_gentooimgr/README.md @@ -1,10 +1,18 @@ GentooImgr: Gentoo Image Builder for Cloud and Turnkey ISO installers ===================================================================== -** This is a modified version of https://github.com/NucleaPeon/gentooimgr/ +**This is a modified version of https://github.com/NucleaPeon/gentooimgr/ where we've modified the code a little to do use Python logging. We can -still use it for the build stage, but we think the install stahe is better -done using ansible, hence the libvirt_cloud playbook.** +still use it for the build stage, but we think the install stage is better +done using ansible, hence the libvirt_cloud playbook. + +The code is in overlay/Linux/usr/local/src/ansible_gentooimgr +for reasons to do with how the ansible role transfers files. +The code is being supported as an ansible module using +library/ansible_gentooimgr.py which is a work in progress; the idea +is to use it for the build and status actions, but handle the install +tasks using ansible. +** GentooImgr is a python script system to build cloud images based on Gentoo Linux. diff --git a/src/ansible_gentooimgr/library/ansible_gentooimgr.py b/src/ansible_gentooimgr/library/ansible_gentooimgr.py index d1774ff..0db6bf5 100755 --- a/src/ansible_gentooimgr/library/ansible_gentooimgr.py +++ b/src/ansible_gentooimgr/library/ansible_gentooimgr.py @@ -10,11 +10,18 @@ from argparse import Namespace import pathlib import traceback -sys.path.append('/mnt/o/var/local/src/play_tox/src/ansible_gentooimgr') # in the library -if os.environ.get('TESTF_ANSIBLE_SRC',''): +if os.environ.get('PLAY_ANSIBLE_SRC',''): # running from source - mod_path = os.environ.get('TESTF_ANSIBLE_SRC','') + mod_path = os.environ.get('PLAY_ANSIBLE_SRC','') + mod_path = os.path.join(mod_path, 'src', 'ansible_gentooimgr') + assert os.path.isdir(mod_path), f"parent {mod_path}" + assert os.path.isfile(os.path.join(mod_path, '__init__.py')),f"index {mod_path}" + assert os.path.isdir(os.path.join(mod_path, 'gentooimgr')), f"sub {mod_path}" + sys.path.append(mod_path) +else: + # in the library + mod_path = os.path.dirname(os.path.realpath('__file__')) mod_path = os.path.join(mod_path, 'src', 'ansible_gentooimgr') assert os.path.isdir(mod_path), f"parent {mod_path}" assert os.path.isfile(os.path.join(mod_path, '__init__.py')),f"index {mod_path}" @@ -23,7 +30,7 @@ if os.environ.get('TESTF_ANSIBLE_SRC',''): try: import gentooimgr except Exception as e: - sys.stderr.write(f"{e} {sys.path} {traceback.print_exc()}") + sys.stderr.write(f"{mod_path} {sys.path} {traceback.print_exc()}") raise import ansible