Skip to content

Commit

Permalink
Fix ctxt dist path
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Nov 26, 2024
1 parent fe77358 commit 48eec8b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from IM.recipe import Recipe
from IM.config import Config
from radl.radl import system, contextualize_item
from IM.CtxtAgentBase import CtxtAgentBase


class ConfManager(LoggerMixin, threading.Thread):
Expand Down Expand Up @@ -397,8 +398,8 @@ def launch_ctxt_agent(self, vm, tasks):
vault_password = vm.info.systems[0].getValue("vault.password")
if vault_password:
vault_export = "export VAULT_PASS='%s' && " % vault_password
(pid, _, _) = ssh.execute("nohup sh -c \"" + vault_export + "/var/tmp/.ansible/bin/python3 " +
Config.REMOTE_CONF_DIR +
(pid, _, _) = ssh.execute("nohup sh -c \"" + vault_export + CtxtAgentBase.VENV_DIR +
"/bin/python3 " + Config.REMOTE_CONF_DIR +
"/" + str(self.inf.id) + "/" + ctxt_agent_command +
Config.REMOTE_CONF_DIR + "/" + str(self.inf.id) + "/" +
"/general_info.cfg " + remote_dir + "/" + os.path.basename(conf_file) +
Expand Down
5 changes: 3 additions & 2 deletions IM/CtxtAgentBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CtxtAgentBase:
# the ConfManager
PLAYBOOK_RETRIES = 1
INTERNAL_PLAYBOOK_RETRIES = 1
VENV_DIR = "/var/tmp/.ansible"

def __init__(self, conf_data_filename):
self.logger = None
Expand Down Expand Up @@ -508,7 +509,7 @@ def install_ansible_roles(self, general_conf_data, playbook):
task["name"] = "Create YAML file to install the collections with ansible-galaxy"
yaml_data[0]['tasks'].append(task)

task = {"command": "/var/tmp/.ansible/bin/ansible-galaxy collection install -c -r %s" % filename}
task = {"command": self.VENV_DIR + "/bin/ansible-galaxy collection install -c -r %s" % filename}
task["name"] = "Install galaxy collections"
task["become"] = "yes"
task["register"] = "collections_install"
Expand Down Expand Up @@ -562,7 +563,7 @@ def install_ansible_roles(self, general_conf_data, playbook):
task["name"] = "Create YAML file to install the roles with ansible-galaxy"
yaml_data[0]['tasks'].append(task)

task = {"command": "/var/tmp/.ansible/bin/ansible-galaxy install -c -r %s" % filename}
task = {"command": self.VENV_DIR + "/bin/ansible-galaxy install -c -r %s" % filename}
task["name"] = "Install galaxy roles"
task["become"] = "yes"
task["register"] = "roles_install"
Expand Down
3 changes: 2 additions & 1 deletion contextualization/ctxt_agent_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def LaunchRemoteAgent(self, vm, vault_pass, pk_file, changed_pass_ok):
vm_dir = os.path.abspath(os.path.dirname(self.vm_conf_data_filename))
remote_dir = os.path.abspath(os.path.dirname(self.conf_data_filename))
try:
(pid, _, _) = ssh_client.execute(vault_export + "nohup python3 " + remote_dir + "/ctxt_agent_dist.py " +
(pid, _, _) = ssh_client.execute(vault_export + "nohup " + CtxtAgentBase.VENV_DIR + "/bin/python3 " +
remote_dir + "/ctxt_agent_dist.py " +
self.conf_data_filename + " " + self.vm_conf_data_filename +
" 1 > " + vm_dir + "/stdout 2> " + vm_dir +
"/stderr < /dev/null & echo -n $!")
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_ctxt_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def test_95_install_ansible_roles(self):
self.assertEqual(copy_content, "[{src: ansible_role}, {name: hadoop, src: "
"'git+https://github.com/micafer/ansible-role-hadoop'}]")
self.assertEqual(yaml_data[0]['tasks'][2]['command'][:69],
"/var/tmp/.ansible/bin/ansible-galaxy install -c -r /tmp/galaxy_roles_")
ctxt_agent.VENV_DIR + "/bin/ansible-galaxy install -c -r /tmp/galaxy_roles_")

os.unlink(res)

Expand All @@ -302,7 +302,7 @@ def test_99_install_ansible_collections(self):
copy_content = yaml_data[0]['tasks'][0]['copy'][pos + 9:-2]
self.assertEqual(copy_content, "{collections: [{name: ns.collection, version: '1.0'}]}")
self.assertEqual(yaml_data[0]['tasks'][1]['command'][:86],
"/var/tmp/.ansible/bin/ansible-galaxy collection install -c -r /tmp/galaxy_collections_")
ctxt_agent.VENV_DIR + "/bin/ansible-galaxy collection install -c -r /tmp/galaxy_collections_")

os.unlink(res)

Expand Down

0 comments on commit 48eec8b

Please sign in to comment.