Update role for new source build process

The variables cloudkitty_developer_mode and cloudkitty_venv_download
no longer carry any meaning. This review changes cloudkitty to
do the equivalent of what developer_mode was all the time,
meaning that it always builds the venv and never requires
the repo server, but it will use a repo server when available.

As part of this, we move the installation out of its own file
because it's now a single task to include the venv build role.
This is just to make it easier to follow the code.

We also change include_tasks to import_tasks and include_role
to import_role so that the tags in the python_venv_build role
will work.

Change-Id: Ieaec0a12a1ed6ea1f9a98a615fd8c6bff67a9d0c
This commit is contained in:
Dmitriy Rabotjagov 2019-03-28 09:59:38 +02:00
parent 6470449d6e
commit fb6af2f3f0
5 changed files with 39 additions and 76 deletions

View File

@ -58,32 +58,19 @@ cloudkitty_system_comment: meow
cloudkitty_system_shell: /bin/false
cloudkitty_system_home_folder: "/var/lib/{{ cloudkitty_system_user_name }}"
# TODO(odyssey4me):
# This can be simplified once all the roles are using
# python_venv_build. We can then switch to using a
# set of constraints in pip.conf inside the venv,
# perhaps prepared by giving a giving a list of
# constraints to the role.
cloudkitty_pip_install_args: >-
{{ cloudkitty_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''), '') }}
{{ pip_install_options | default('') }}
cloudkitty_pip_install_args: "{{ pip_install_options | default('') }}"
cloudkitty_venv_tag: "{{ venv_tag | default('untagged') }}"
cloudkitty_bin: "/openstack/venvs/cloudkitty-{{ cloudkitty_venv_tag }}/bin"
# venv_download, even when true, will use the fallback method of building the
# venv from scratch if the venv download fails.
cloudkitty_venv_download: "{{ not cloudkitty_developer_mode | bool }}"
cloudkitty_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/cloudkitty.tgz
cloudkitty_git_repo: https://git.openstack.org/openstack/cloudkitty
cloudkitty_git_install_branch: master
cloudkitty_developer_constraints:
cloudkitty_upper_constraints_url: "{{ requirements_git_url | default('https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=' ~ requirements_git_install_branch | default('master')) }}"
cloudkitty_git_constraints:
- "git+{{ cloudkitty_git_repo }}@{{ cloudkitty_git_install_branch }}#egg=cloudkitty"
- "--constraint {{ cloudkitty_upper_constraints_url }}"
cloudkitty_developer_mode: false
cloudkitty_notification_topics: notifications
cloudkitty_collected_services: compute
cloudkitty_collector: gnocchi

View File

@ -1,52 +0,0 @@
---
# Copyright 2016, Rackspace US, Inc.
#
# (C) 2016 Michael Rice <michael.rice@rackspace.com>
#
# 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.
# TODO(odyssey4me):
# This can be simplified once all the roles are using
# python_venv_build. We can then switch to using a
# set of constraints in pip.conf inside the venv,
# perhaps prepared by giving a giving a list of
# constraints to the role.
- name: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"
content: |
{% for item in cloudkitty_developer_constraints %}
{{ item }}
{% endfor %}
when: cloudkitty_developer_mode | bool
- name: Ensure remote wheel building is disabled in developer mode
set_fact:
venv_build_host: "{{ ansible_hostname }}"
when:
- cloudkitty_developer_mode | bool
- name: Install the python venv
include_role:
name: "python_venv_build"
private: yes
vars:
venv_build_distro_package_list: "{{ cloudkitty_devel_distro_packages }}"
venv_install_destination_path: "{{ cloudkitty_bin | dirname }}"
venv_install_distro_package_list: "{{ cloudkitty_distro_packages }}"
venv_pip_install_args: "{{ cloudkitty_pip_install_args }}"
venv_pip_packages: "{{ (cloudkitty_oslomsg_amqp1_enabled | bool) | ternary(cloudkitty_pip_packages + cloudkitty_optional_oslomsg_amqp1_pip_packages, cloudkitty_pip_packages) }}"
venv_facts_when_changed:
- section: "cloudkitty"
option: "venv_tag"
value: "{{ cloudkitty_venv_tag }}"

View File

@ -39,14 +39,39 @@
tags:
- always
- include_tasks: cloudkitty_pre_install.yml
- include_tasks: cloudkitty_install.yml
- include_tasks: cloudkitty_post_install.yml
- import_tasks: cloudkitty_pre_install.yml
tags:
- cloudkitty-install
- include_tasks: cloudkitty_wsgi.yml
- name: Install the python venv
import_role:
name: "python_venv_build"
vars:
venv_build_constraints: "{{ cloudkitty_git_constraints }}"
venv_build_distro_package_list: "{{ cloudkitty_devel_distro_packages }}"
venv_install_destination_path: "{{ cloudkitty_bin | dirname }}"
venv_install_distro_package_list: "{{ cloudkitty_distro_packages }}"
venv_pip_install_args: "{{ cloudkitty_pip_install_args }}"
venv_pip_packages: "{{ cloudkitty_pip_packages | union((cloudkitty_oslomsg_amqp1_enabled | bool) | ternary(cloudkitty_optional_oslomsg_amqp1_pip_packages, [])) }}"
venv_facts_when_changed:
- section: "cloudkitty"
option: "venv_tag"
value: "{{ cloudkitty_venv_tag }}"
tags:
- cloudkitty-install
- include_tasks: cloudkitty_service_setup.yml
- import_tasks: cloudkitty_post_install.yml
tags:
- cloudkitty-config
- import_tasks: cloudkitty_wsgi.yml
tags:
- cloudkitty-config
- import_tasks: cloudkitty_service_setup.yml
when: inventory_hostname == groups['cloudkitty_all'][0]
tags:
- cloudkitty-config
- import_tasks: mq_setup.yml
when:
@ -66,9 +91,11 @@
- common-mq
- cloudkitty-config
- include: cloudkitty_db_setup.yml
- import_tasks: cloudkitty_db_setup.yml
when:
- inventory_hostname == groups['cloudkitty_all'][0]
tags:
- cloudkitty-config
- name: Run the systemd service role
include_role:

View File

@ -60,6 +60,8 @@ backend = {{ cloudkitty_output_backend }}
[state]
[storage]
backend = sqlalchemy
version = 1
[tenant_fetcher]

View File

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cloudkitty_developer_mode: true
cloudkitty_galera_address: "{{ test_galera_host }}"
cloudkitty_container_mysql_password: "SuperSecrete"
cloudkitty_service_password: "secrete"