Allow playbooks to come from a venv version
Today if you pip install tripleoclient and pip install tripleo-ansible, you can't run some of the cli commands because they cannot be found. In order to support this, we need to check if the playbook folder is available in a venv and fall back to the /usr/share/ansible version if it does not exist. Change-Id: I27ac01aae7155cfc84bf5aef926ae220b57373c9
This commit is contained in:
parent
3d88738370
commit
37996551cb
|
@ -14,6 +14,7 @@
|
|||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from osc_lib.i18n import _
|
||||
from six.moves import configparser
|
||||
|
@ -25,7 +26,6 @@ try:
|
|||
except NameError:
|
||||
FileNotFoundError = IOError
|
||||
|
||||
|
||||
TRIPLEO_HEAT_TEMPLATES = "/usr/share/openstack-tripleo-heat-templates/"
|
||||
OVERCLOUD_YAML_NAME = "overcloud.yaml"
|
||||
OVERCLOUD_ROLES_FILE = "roles_data.yaml"
|
||||
|
@ -117,8 +117,30 @@ ANSIBLE_VALIDATION_DIR = (
|
|||
else "/usr/share/ansible/validation-playbooks"
|
||||
)
|
||||
|
||||
ANSIBLE_TRIPLEO_PLAYBOOKS = \
|
||||
'/usr/share/ansible/tripleo-playbooks'
|
||||
# NOTE(mwhahaha): So if we pip install tripleoclient, we need to also
|
||||
# honor pulling some other files from a venv (e.g. cli playbooks,
|
||||
# and container image yaml for building). This logic will create a
|
||||
# constant for a venv share path which we can use to check to see if things
|
||||
# like tripleo-common or tripleo-ansible have also been pip installed.
|
||||
SHARE_BASE_PATH = os.path.join(sys.prefix, 'share')
|
||||
if sys.prefix != '/usr' and not os.path.isdir(SHARE_BASE_PATH):
|
||||
SHARE_BASE_PATH = os.path.join('/usr', 'share')
|
||||
|
||||
ANSIBLE_TRIPLEO_PLAYBOOKS = os.path.join(
|
||||
SHARE_BASE_PATH, 'ansible', 'tripleo-playbooks'
|
||||
)
|
||||
if sys.prefix != '/usr' and not os.path.isdir(ANSIBLE_TRIPLEO_PLAYBOOKS):
|
||||
ANSIBLE_TRIPLEO_PLAYBOOKS = os.path.join(
|
||||
'/usr', 'share', 'ansible', 'tripleo-playbooks'
|
||||
)
|
||||
CONTAINER_IMAGES_BASE_PATH = os.path.join(
|
||||
SHARE_BASE_PATH, "tripleo-common", "container-images"
|
||||
)
|
||||
if sys.prefix != "/usr" and not os.path.isdir(CONTAINER_IMAGES_BASE_PATH):
|
||||
CONTAINER_IMAGES_BASE_PATH = os.path.join(
|
||||
"/usr", "share", "tripleo-common", "container-images"
|
||||
)
|
||||
|
||||
|
||||
VALIDATION_GROUPS_INFO = (
|
||||
'/usr/share/ansible/groups.yaml'
|
||||
|
|
|
@ -17,7 +17,6 @@ import collections
|
|||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import uuid
|
||||
import yaml
|
||||
|
||||
|
@ -29,17 +28,10 @@ from tripleo_common.exception import NotFound
|
|||
from tripleo_common.image.builder import buildah
|
||||
|
||||
from tripleoclient import command
|
||||
from tripleoclient import constants
|
||||
from tripleoclient import utils
|
||||
|
||||
|
||||
BASE_PATH = os.path.join(
|
||||
sys.prefix, "share", "tripleo-common", "container-images"
|
||||
)
|
||||
# NOTE(cloudnull): This will ensure functionality even when running in a venv.
|
||||
if sys.prefix != "/usr" and not os.path.isdir(BASE_PATH):
|
||||
BASE_PATH = os.path.join(
|
||||
"/usr", "share", "tripleo-common", "container-images"
|
||||
)
|
||||
DEFAULT_AUTHFILE = "{}/containers/auth.json".format(
|
||||
os.environ.get("XDG_RUNTIME_DIR", os.path.expanduser("~"))
|
||||
)
|
||||
|
@ -95,7 +87,7 @@ class Build(command.Command):
|
|||
"--config-path",
|
||||
dest="config_path",
|
||||
metavar="<config-path>",
|
||||
default=BASE_PATH,
|
||||
default=constants.CONTAINER_IMAGES_BASE_PATH,
|
||||
help=_(
|
||||
"Base configuration path. This is the base path for all "
|
||||
"container-image files. The defined containers must reside "
|
||||
|
|
Loading…
Reference in New Issue