Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 13 additions & 4 deletions osism/commands/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tabulate import tabulate

from osism.core import enums
from osism.core.playbooks import MAP_ROLE2ENVIRONMENT
from osism.core.playbooks import MAP_ROLE2ENVIRONMENT, MAP_ROLE2RUNTIME
from osism.tasks import ansible, ceph, kolla, handle_task


Expand Down Expand Up @@ -356,9 +356,18 @@ def _prepare_task(
else:
kolla_arguments = [f"-e kolla_action={action}"] + arguments

t = kolla.run.si(
environment, role, kolla_arguments, auto_release_time=task_timeout
)
if (
role not in ["common"]
and "osism-ansible" in MAP_ROLE2RUNTIME
and role in MAP_ROLE2RUNTIME["osism-ansible"]
):
t = ansible.run.si(
environment, role, arguments, auto_release_time=task_timeout
)
else:
t = kolla.run.si(
environment, role, kolla_arguments, auto_release_time=task_timeout
Comment thread
berendt marked this conversation as resolved.
)
else:
# Overwrite the environment
if overwrite:
Expand Down
17 changes: 14 additions & 3 deletions osism/core/playbooks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# SPDX-License-Identifier: Apache-2.0

import os
from pathlib import Path
from typing import Dict, Any

from loguru import logger
import yaml

MAP_ROLE2ENVIRONMENT: Dict[str, Any] = {}
MAP_ROLE2RUNTIME: Dict[str, Any] = {}

for path in Path("/interface/playbooks").glob("*-ansible.yml"):
with open(path) as fp:
data = yaml.load(fp, Loader=yaml.SafeLoader)
try:
with open(path) as fp:
data = yaml.load(fp, Loader=yaml.SafeLoader)

MAP_ROLE2ENVIRONMENT = MAP_ROLE2ENVIRONMENT | data
MAP_ROLE2ENVIRONMENT = MAP_ROLE2ENVIRONMENT | data
MAP_ROLE2RUNTIME[os.path.basename(path)[:-4]] = data.keys()

# Ignore YAML errors here so that we can prevent the command
# from being non-functional if a runtime environment provides
# an invalid interface file.
except yaml.YAMLError as e:
logger.warning(e)