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

Commit

Permalink
Merge pull request #608 from deNBI/hotfix/guacamole
Browse files Browse the repository at this point in the history
hotfix(playbooks): Fix playbook doesnt work for specific cloud site
  • Loading branch information
Timo authored Feb 4, 2021
2 parents 5ef66d2 + 7918e17 commit 3283f23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions VirtualMachineService/ancon/Playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,10 @@ def load_vars():
data[playbook_name + "_defined"][k] = v

site_specific_yml = "/{0}{1}.yml".format(playbook_name, "-" + self.cloud_site)
playbook_yml = ""
playbook_name_local = playbook_name
if os.path.isfile(self.playbooks_dir + site_specific_yml):
playbook_yml = site_specific_yml
else:
playbook_yml = "/{0}.yml".format(playbook_name)
playbook_name_local = playbook_name + "-" + self.cloud_site
playbook_yml = "/{0}.yml".format(playbook_name_local)
playbook_var_yml = "/{0}_vars_file.yml".format(playbook_name)
try:
shutil.copy(self.playbooks_dir + playbook_yml, self.directory.name)
Expand All @@ -174,26 +173,34 @@ def load_vars():
self.directory.name + playbook_var_yml, mode="w"
) as variables:
self.yaml_exec.dump(data, variables)
self.add_to_playbook_lists(playbook_name)
self.add_to_playbook_lists(playbook_name_local, playbook_name)
except shutil.Error as e:
LOG.exception(e)
self.add_tasks_only(playbook_name)
self.add_tasks_only(playbook_name_local)
except IOError as e:
LOG.exception(e)
self.add_tasks_only(playbook_name)
self.add_tasks_only(playbook_name_local)
except shutil.Error as e:
LOG.exception(e)
except IOError as e:
LOG.exception(e)

def add_to_playbook_lists(self, playbook_name):
def add_to_playbook_lists(self, playbook_name_local, playbook_name):
self.vars_files.append(playbook_name + "_vars_file.yml")
self.tasks.append(
dict(
name="Running {0} tasks".format(playbook_name),
import_tasks=playbook_name + ".yml",
name="Running {0} tasks".format(playbook_name_local),
import_tasks=playbook_name_local + ".yml",
)
)
LOG.info(
"Added playbook: "
+ playbook_name_local
+ ".yml"
+ ", vars file: "
+ playbook_name
+ "_vars_file.yml"
)

def add_tasks_only(self, playbook_name):
self.tasks.append(
Expand Down
2 changes: 1 addition & 1 deletion VirtualMachineService/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ bibigrid:
forc:
forc_url: https://proxy-dev.bi.denbi.de:5000/

cloud_site: bielefeld
cloud_site: giessen

0 comments on commit 3283f23

Please sign in to comment.