From 2deb810d15bed5a2483e1d41c73b19ebf2597aeb Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 8 May 2026 13:08:48 +0200 Subject: [PATCH] Correct ansible paths --- IM/ConfManager.py | 7 ++++--- IM/CtxtAgentBase.py | 1 + contextualization/ctxt_agent_dist.py | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/IM/ConfManager.py b/IM/ConfManager.py index 557c9b235..26ceac705 100644 --- a/IM/ConfManager.py +++ b/IM/ConfManager.py @@ -1463,8 +1463,8 @@ def configure_ansible(self, ssh, tmp_dir, ansible_version=None): recipe_out.write("\n - name: Delete the %s collection\n" % galaxy_name) galaxy_name = galaxy_name.replace(".", "/") - recipe_out.write(" file: state=absent path=/etc/ansible/ansible_collections/%s\n" % - galaxy_name) + recipe_out.write(" file: state=absent path=%s/ansible_collections/%s\n" % + (CtxtAgentBase.ANSIBLE_DIR, galaxy_name)) recipe_out.close() @@ -1476,7 +1476,8 @@ def configure_ansible(self, ssh, tmp_dir, ansible_version=None): recipe_out = open(tmp_dir + "/" + ConfManager.MASTER_YAML, 'a') recipe_out.write("\n - name: Delete the %s role\n" % galaxy_name) - recipe_out.write(" file: state=absent path=/etc/ansible/roles/%s\n" % galaxy_name) + recipe_out.write(" file: state=absent path=%s/roles/%s\n" % + (CtxtAgentBase.ANSIBLE_DIR, galaxy_name)) recipe_out.close() diff --git a/IM/CtxtAgentBase.py b/IM/CtxtAgentBase.py index 25997e540..ffb04cb43 100644 --- a/IM/CtxtAgentBase.py +++ b/IM/CtxtAgentBase.py @@ -42,6 +42,7 @@ class CtxtAgentBase: MAMBA_BIN = "/var/tmp/.mamba/bin/micromamba" # nosec MAMBA_ENV_DIR = MAMBA_DIR + "/envs/" + MAMBA_ENV_NAME # nosec MAMBA_CMD = MAMBA_BIN + " run -n " + MAMBA_ENV_NAME + " " # nosec + ANSIBLE_DIR = "/var/tmp/ansible" # nosec ANSIBLE_CFG_FILE = "/var/tmp/ansible.cfg" # nosec def __init__(self, conf_data_filename): diff --git a/contextualization/ctxt_agent_dist.py b/contextualization/ctxt_agent_dist.py index a749c39c8..1469e1587 100755 --- a/contextualization/ctxt_agent_dist.py +++ b/contextualization/ctxt_agent_dist.py @@ -332,13 +332,14 @@ def contextualize_vm(self, general_conf_data, vm_conf_data, ctxt_vm, local): ssh_client.sftp_put_dir(cache_dir, cache_dir) self.logger.info("Copy ansible roles to: %s" % ctxt_vm['ip']) - ssh_client.sftp_mkdir("/etc/ansible/roles") - ssh_client.sftp_put_dir("/etc/ansible/roles", "/etc/ansible/roles") + ssh_client.sftp_mkdir(self.ANSIBLE_DIR + "/roles") + ssh_client.sftp_put_dir(self.ANSIBLE_DIR + "/roles", + self.ANSIBLE_DIR + "/roles") self.logger.info("Copy ansible collections to: %s" % ctxt_vm['ip']) - ssh_client.sftp_mkdir("/etc/ansible/ansible_collections") - ssh_client.sftp_put_dir("/etc/ansible/ansible_collections", - "/etc/ansible/ansible_collections") + ssh_client.sftp_mkdir(self.ANSIBLE_DIR + "/ansible_collections") + ssh_client.sftp_put_dir(self.ANSIBLE_DIR + "/ansible_collections", + self.ANSIBLE_DIR + "/ansible_collections") except Exception: self.logger.exception("Error copying cache to VM: " + ctxt_vm['ip']) else: