Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
fixed playbook vars
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jul 4, 2022
1 parent 83d0d13 commit 0a2a52a
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions VirtualMachineService/ancon/Playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(
)
self.returncode = -1
self.playbooks_information = playbooks_information
LOG.exception(self.playbooks_information)

self.stdout = ""
self.stderr = ""
# init temporary directories and mandatory generic files
Expand Down Expand Up @@ -132,8 +134,7 @@ def copy_playbooks_and_init(self, playbooks_information, public_key):

def copy_and_init(self, playbook_name, playbook_vars):
def load_vars():
LOG.info(f"Playbook vars: {playbook_vars}")

LOG.info(f" Playbook vars: {playbook_vars}")
if playbook_name == CONDA:
for k, v in playbook_vars.items():
if k == "packages":
Expand All @@ -146,16 +147,16 @@ def load_vars():
data[playbook_name + "_vars"][k] = p_dict
if playbook_name in self.loaded_metadata_keys:
for k, v in playbook_vars.items():
LOG.info(playbook_vars)
if k == "template_version":
data[playbook_name + "_vars"][k] = v
elif k == "create_only_backend":
create_only_backend = data[playbook_name + "_vars"][k]
if create_only_backend in ["false", "False"]:
if k == "create_only_backend":
if playbook_vars[k] in ["false", "False"]:
data[playbook_name + "_vars"][k] = False
elif create_only_backend in ["true", "True"]:
elif playbook_vars[k] in ["true", "True"]:
data[playbook_name + "_vars"][k] = True

elif k == "base_url":
if k == "base_url":
data[playbook_name + "_vars"][k] = v

if playbook_name == OPTIONAL:
Expand All @@ -176,17 +177,15 @@ def load_vars():
playbook_name_local = playbook_name
if os.path.isfile(self.directory.name + site_specific_yml):
playbook_name_local = playbook_name + "-" + self.cloud_site
original_playbook_var_yml = f"{self.playbooks_dir}/{playbook_name}/{playbook_name}_vars_file.yml"

playbook_var_yml = f"/{playbook_name}_vars_file.yml"
LOG.info("Remove copy of vars file")
os.remove(self.directory.name + playbook_var_yml)

try:
with open(original_playbook_var_yml, mode="r") as original_vars_yml:
data = self.yaml_exec.load(original_vars_yml)
with open(self.directory.name + playbook_var_yml, mode="r") as variables:
data = self.yaml_exec.load(variables)
load_vars()
with open(self.directory.name + playbook_var_yml, mode="w") as playbook_variables_yml:
self.yaml_exec.dump(data, playbook_variables_yml)
with open(self.directory.name + playbook_var_yml, mode="w") as variables:
self.yaml_exec.dump(data, variables)
self.add_to_playbook_lists(playbook_name_local, playbook_name)
except shutil.Error as e:
LOG.exception(e)
Expand Down

0 comments on commit 0a2a52a

Please sign in to comment.