Merge "Add setup script for kolla-cli / kolla-ansible"
This commit is contained in:
commit
635c978694
23
README.rst
23
README.rst
|
@ -19,6 +19,18 @@ deployments and perform upgrades.
|
|||
Installing
|
||||
==========
|
||||
|
||||
The installation process below assumes that the kolla-ansible repository
|
||||
exists at the same level as the kolla-cli repository. This is made clear
|
||||
in the cli-setup.py script which makes a relative '../' reference to
|
||||
the kolla-ansible repository. If your kolla-ansible directory is somewhere
|
||||
else then that location can be passed as an argument to the cli-setup.py
|
||||
script. The location on the system where the kolla-cli expects the
|
||||
kolla-ansible files to be and installs them to can be tweaked by setting
|
||||
the KOLLA_HOME and KOLLA_ETC environment variables before running the
|
||||
cli-setup.py script, and while running the kolla-cli command itself. The
|
||||
default value for KOLLA_HOME is /usr/share/kolla-ansible and the default
|
||||
value for KOLLA_ETC is /etc/kolla.
|
||||
|
||||
The following steps can be used to build / run the kolla-cli
|
||||
|
||||
* install ansible and docker
|
||||
|
@ -26,16 +38,7 @@ The following steps can be used to build / run the kolla-cli
|
|||
* . .venv/bin/activate
|
||||
* pip install -r requirements.txt
|
||||
* python setup.py install
|
||||
* mkdir /usr/share/kolla-ansible
|
||||
* cp -r kolla-ansible/ansible to /usr/share/kolla
|
||||
* mkdir -p /etc/kolla/kolla-cli/ansible
|
||||
* touch /etc/kolla/kolla-cli/ansible/inventory.json
|
||||
* mkdir -p /usr/share/kolla-ansible/kolla-cli/tools
|
||||
* mkdir /usr/share/kolla-ansible/kolla-cli/ansible
|
||||
* touch /usr/share/kolla-ansible/kolla-cli/ansible.lock
|
||||
* cp kolla-cli/tools /usr/share/kolla-ansible/kolla-cli/tools
|
||||
* mkdir /usr/share/kolla-ansible/ansible/host_vars
|
||||
* cp /etc/kolla/globals.yml /usr/share/kolla-ansible/ansible/group_vars/__GLOBAL__
|
||||
* python ./cli-setup.py
|
||||
* kolla-cli
|
||||
|
||||
At that point you will be dropped into the kollacli shell where
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
# Copyright 2018 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import os
|
||||
import sys
|
||||
|
||||
from kolla_cli.common import utils
|
||||
|
||||
kolla_ansible_source_base = '../kolla-ansible'
|
||||
kolla_ansible_home_target = utils.get_kolla_ansible_home()
|
||||
kolla_ansible_etc_target = utils.get_kolla_etc()
|
||||
ansible = 'ansible'
|
||||
kolla = 'kolla'
|
||||
kolla_cli = 'kolla-cli'
|
||||
tools = 'tools'
|
||||
|
||||
|
||||
def setup_ansible_etc():
|
||||
# if the kolla-cli directory for the inventory doesn't exist
|
||||
# already then make it. this will also create the directory the
|
||||
# globals and password file goes into
|
||||
cli_etc_dir = os.path.join(kolla_ansible_etc_target,
|
||||
kolla_cli, ansible)
|
||||
if not os.path.exists(cli_etc_dir):
|
||||
make_cli_etc_dir_cmd = ('mkdir -p %s' % cli_etc_dir)
|
||||
_command_exec(make_cli_etc_dir_cmd)
|
||||
|
||||
inventory_file_path = os.path.join(cli_etc_dir, 'inventory.json')
|
||||
if not os.path.exists(inventory_file_path):
|
||||
touch_inventory_file_cmd = ('touch %s' % inventory_file_path)
|
||||
_command_exec(touch_inventory_file_cmd)
|
||||
|
||||
# copy over all kolla ansible etc files
|
||||
kolla_ansible_etc_source = os.path.join(kolla_ansible_source_base,
|
||||
'etc', kolla)
|
||||
copy_kolla_etc_files_cmd = ('cp -a %s %s' % (kolla_ansible_etc_source,
|
||||
kolla_ansible_etc_target))
|
||||
_command_exec(copy_kolla_etc_files_cmd)
|
||||
|
||||
|
||||
def setup_ansible_home():
|
||||
# make cli home ansible directory
|
||||
cli_ansible_dir = os.path.join(kolla_ansible_home_target,
|
||||
kolla_cli, ansible)
|
||||
if not os.path.exists(cli_ansible_dir):
|
||||
make_cli_ansible_dir_cmd = ('mkdir -p %s' % cli_ansible_dir)
|
||||
_command_exec(make_cli_ansible_dir_cmd)
|
||||
|
||||
# make cli home tools directory
|
||||
cli_tools_dir = os.path.join(kolla_ansible_home_target,
|
||||
kolla_cli, tools)
|
||||
if not os.path.exists(cli_tools_dir):
|
||||
make_cli_tools_dir_cmd = ('mkdir -p %s' % cli_tools_dir)
|
||||
_command_exec(make_cli_tools_dir_cmd)
|
||||
|
||||
# move cli tools files to tools directory
|
||||
copy_cli_tools_files_cmd = ('cp -a %s %s' % ('./tools/*', cli_tools_dir))
|
||||
_command_exec(copy_cli_tools_files_cmd)
|
||||
|
||||
# create cli ansible lock file
|
||||
lock_file_path = os.path.join(kolla_ansible_home_target,
|
||||
kolla_cli, 'ansible.lock')
|
||||
if not os.path.exists(lock_file_path):
|
||||
touch_ansible_lock_file_cmd = ('touch %s' % lock_file_path)
|
||||
_command_exec(touch_ansible_lock_file_cmd)
|
||||
|
||||
# copy over all kolla ansible home files
|
||||
kolla_ansible_home_source = os.path.join(kolla_ansible_source_base,
|
||||
ansible)
|
||||
copy_kolla_home_files_cmd = ('cp -a %s %s' % (kolla_ansible_home_source,
|
||||
kolla_ansible_home_target))
|
||||
_command_exec(copy_kolla_home_files_cmd)
|
||||
|
||||
# create the host_vars directory if it doesn't exist already
|
||||
host_vars_path = os.path.join(kolla_ansible_home_target,
|
||||
ansible, 'host_vars')
|
||||
if not os.path.exists(host_vars_path):
|
||||
make_kolla_host_vars_dir_cmd = ('mkdir %s' % host_vars_path)
|
||||
_command_exec(make_kolla_host_vars_dir_cmd)
|
||||
|
||||
# make link from etc globals to home globals
|
||||
target_etc_path = os.path.join(kolla_ansible_etc_target, 'globals.yml')
|
||||
target_home_link = os.path.join(kolla_ansible_home_target,
|
||||
ansible, 'group_vars', '__GLOBAL__')
|
||||
if not os.path.exists(target_home_link):
|
||||
link_globals_file_cmd = ('ln -s %s %s' % (target_etc_path,
|
||||
target_home_link))
|
||||
_command_exec(link_globals_file_cmd)
|
||||
|
||||
|
||||
def _command_exec(command):
|
||||
print('running - %s' % command)
|
||||
error, _ = utils.run_cmd(command)
|
||||
if error:
|
||||
print('error - %s' % error)
|
||||
|
||||
|
||||
def main():
|
||||
"""make sure kolla-ansible and cli files are in the right places"""
|
||||
|
||||
if len(sys.argv) >= 2:
|
||||
global kolla_ansible_source_base
|
||||
kolla_ansible_source_base = sys.argv[1]
|
||||
|
||||
setup_ansible_etc()
|
||||
setup_ansible_home()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue