Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2974 and #2976 #2977

Merged
merged 21 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cli/src/ansible/AnsibleInventoryUpgrade.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from cli.src.helpers.build_io import (get_inventory_path_for_build,
load_inventory, load_manifest,
save_inventory)
from cli.src.helpers.data_loader import load_schema_obj
from cli.src.helpers.data_loader import types as data_types
from cli.src.helpers.data_loader import load_schema_obj, schema_types
from cli.src.helpers.doc_list_helpers import select_single
from cli.src.helpers.objdict_helpers import merge_objdict
from cli.src.models.AnsibleHostModel import AnsibleHostModel
Expand Down Expand Up @@ -73,7 +72,7 @@ def upgrade(self):
self.cluster_model = select_single(self.manifest_docs, lambda x: x.kind == 'epiphany-cluster')

# Merge manifest cluster config with newer defaults
default_cluster_model = load_schema_obj(data_types.DEFAULT, self.cluster_model.provider, 'epiphany-cluster')
default_cluster_model = load_schema_obj(schema_types.DEFAULT, self.cluster_model.provider, 'epiphany-cluster')
merge_objdict(default_cluster_model, self.cluster_model)
self.cluster_model = default_cluster_model

Expand Down
6 changes: 2 additions & 4 deletions cli/src/ansible/AnsibleRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
get_ansible_path_for_build,
get_inventory_path,
get_inventory_path_for_build)
from cli.src.helpers.data_loader import BASE_DIR, types
from cli.src.helpers.data_loader import ANSIBLE_PLAYBOOK_PATH
from cli.src.helpers.naming_helpers import to_role_name
from cli.src.Step import Step


class AnsibleRunner(Step):
ANSIBLE_PLAYBOOKS_PATH = os.path.join(BASE_DIR, types.ANSIBLE, 'playbooks')

def __init__(self, cluster_model=None, config_docs=None, build_dir=None, backup_build_dir=None,
ansible_options=None, ping_retries: int = 5):
super().__init__(__name__)
Expand Down Expand Up @@ -54,7 +52,7 @@ def copy_resources(self):
ansible_dir = get_ansible_path_for_build(self.build_dir)

delete_directory(ansible_dir)
copy_files_recursively(AnsibleRunner.ANSIBLE_PLAYBOOKS_PATH, ansible_dir)
copy_files_recursively(ANSIBLE_PLAYBOOK_PATH, ansible_dir)

def pre_flight(self, inventory_path):
self.logger.info('Checking connection to each machine')
Expand Down
7 changes: 3 additions & 4 deletions cli/src/ansible/AnsibleVarsGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
get_ansible_path_for_build,
get_ansible_vault_path)
from cli.src.helpers.data_loader import (load_all_schema_objs_from_directory,
load_schema_obj, types)
load_schema_obj, schema_types)
from cli.src.helpers.doc_list_helpers import (ExpectedSingleResultException,
select_first, select_single)
from cli.src.helpers.naming_helpers import to_feature_name, to_role_name
Expand All @@ -33,7 +33,7 @@ def __init__(self, inventory_creator=None, inventory_upgrade=None):
elif inventory_upgrade is not None and inventory_creator is None:
self.cluster_model = inventory_upgrade.cluster_model
self.config_docs = []
defaults = load_all_schema_objs_from_directory(types.DEFAULT, 'common', 'configuration')
defaults = load_all_schema_objs_from_directory(schema_types.DEFAULT, 'common', 'configuration')
for default in defaults:
config_doc = select_first(inventory_upgrade.config_docs, lambda x: x.kind == default.kind)
if config_doc is None:
Expand Down Expand Up @@ -90,7 +90,6 @@ def generate(self):

document = select_first(self.config_docs, lambda x: x.kind == kind)
if document is None:
self.logger.warn('No config document for enabled role: ' + role)
continue
document.specification['provider'] = self.cluster_model.provider

Expand Down Expand Up @@ -164,7 +163,7 @@ def populate_group_vars(self, ansible_dir):

# Fallback if there is completely no trace of the shared-config doc
if shared_config_doc is None:
shared_config_doc = load_schema_obj(types.DEFAULT, 'common', 'configuration/shared-config')
shared_config_doc = load_schema_obj(schema_types.DEFAULT, 'common', 'configuration/shared-config')

self.set_vault_path(shared_config_doc)
main_vars.update(shared_config_doc.specification)
Expand Down
Loading