def __init__(self, inventory_creator=None, inventory_upgrade=None): super().__init__(__name__) self.inventory_creator = inventory_creator self.inventory_upgrade = inventory_upgrade if inventory_creator != None and inventory_upgrade == None: self.cluster_model = inventory_creator.cluster_model self.config_docs = [self.cluster_model] + inventory_creator.config_docs elif inventory_upgrade != None and inventory_creator == None: self.cluster_model = inventory_upgrade.cluster_model self.config_docs = load_all_documents_from_folder('common', 'defaults/configuration') else: raise Exception('Invalid AnsibleVarsGenerator configuration')
def get_full_config(self, config_docs): cluster_config_path = save_manifest(config_docs, self.name, self.name + '.yml') args = type('obj', (object, ), {'file': cluster_config_path})() with EpiphanyEngine(args) as engine: config_docs = engine.dry_run() infra_docs = load_all_documents_from_folder(self.provider, 'defaults/infrastructure') merged_docs = [*config_docs, *infra_docs] # set the provider for all docs for doc in merged_docs: if 'provider' not in doc.keys(): doc['provider'] = self.provider return merged_docs