diff --git a/cyber_sandbox_creator/input_parser/sandbox.py b/cyber_sandbox_creator/input_parser/sandbox.py index 2565173fbbaa67149abf7b88f3d9a2d202dbd82c..db41e4c019433a801bf8f5d54ccffd23f6bda6a1 100644 --- a/cyber_sandbox_creator/input_parser/sandbox.py +++ b/cyber_sandbox_creator/input_parser/sandbox.py @@ -128,6 +128,11 @@ class Sandbox: self.ansible_installed: bool = ansible_installed self.verbose_ansible: bool = verbose_ansible self.user_provisioning_dir: Optional[Path] = user_provisioning_dir + if self.user_provisioning_dir is not None: + self.include_requirements: bool = (self.user_provisioning_dir / + "requirements.yml").is_file() + else: + self.include_requirements: bool = False self.extra_vars: Optional[Path] = extra_vars_file self.config: Dict = Reader.open_yaml(configuration_path) self.flavors: List[Flavor] = self._load_flavors(flavors_path) diff --git a/cyber_sandbox_creator/vagrant_generator/vagrantfile.py b/cyber_sandbox_creator/vagrant_generator/vagrantfile.py index 9f35afd76e360a06abbc721e414c5329e232ca94..18b167f0dde9694d0657ea56a188ad3e2473a959 100644 --- a/cyber_sandbox_creator/vagrant_generator/vagrantfile.py +++ b/cyber_sandbox_creator/vagrant_generator/vagrantfile.py @@ -113,6 +113,15 @@ class Vagrantfile: if sandbox.extra_vars is not None: attributes.append(String("extra_vars", sandbox.config["user_extra_vars"])) + if sandbox.include_requirements: + attributes.append(String("galaxy_role_file", + "provisioning/requirements.yml")) + attributes.append(String("galaxy_roles_path", "provisioning/roles")) + attributes.append(String("galaxy_command", + "sudo ansible-galaxy install --role-file=" + "%{role_file} --roles-path=%{roles_path} " + "--force")) + return attributes @staticmethod