update to the latest

This commit is contained in:
Taseer Ahmed 2018-02-17 17:53:22 +05:00
parent da359ee810
commit d17b8161aa
12 changed files with 170 additions and 82 deletions

View File

@ -96,4 +96,8 @@ blazar_galera_user: blazar
blazar_role_name: admin
blazar_bind_address: 0.0.0.0
blazar_service_port: 9800
blazar_program_name: blazar-server
blazar_program_name: blazar-server
## Tunable overrides
blazar_blazar_api_paste_ini_overrides: {}
blazar_blazar_conf_overrides: {}

View File

@ -15,8 +15,9 @@
# limitations under the License.
- name: create blazar database schema
command: "{{ blazar_bin }}/blazar-db-manage
--config-file {{ blazar_conf_dir }}/blazar.conf upgrade head"
command: >
{{ blazar_bin }}/blazar-db-manage
--config-file {{ blazar_conf_dir }}/blazar.conf upgrade head
become: yes
become_user: "{{ blazar_system_user_name }}"
changed_when: False

View File

@ -14,6 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Install distro packages
package:
name: "{{ blazar_distro_packages }}"
state: "{{ blazar_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages | success
retries: 5
delay: 2
- name: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"
@ -25,8 +36,8 @@
- name: Install required pip packages
pip:
name: "{{ blazar_requires_pip_packages | join(' ') }}"
state: "{{ blazar_package_state }}"
name: "{{ blazar_requires_pip_packages }}"
state: "{{ blazar_pip_package_state }}"
extra_args: >-
{{ blazar_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(''),'') }}
@ -41,7 +52,7 @@
url: "{{ blazar_venv_download_url | replace('tgz', 'checksum') }}"
return_content: yes
register: blazar_venv_checksum
when: not blazar_developer_mode | bool
when: blazar_venv_download | bool
- name: Attempt venv download
get_url:
@ -49,7 +60,7 @@
dest: "/var/cache/{{ blazar_venv_download_url | basename }}"
checksum: "sha1:{{ blazar_venv_checksum.content | trim }}"
register: blazar_get_venv
when: not blazar_developer_mode | bool
when: blazar_venv_download | bool
- name: Remove existing venv
file:
@ -69,32 +80,46 @@
src: "/var/cache/{{ blazar_venv_download_url | basename }}"
dest: "{{ blazar_bin | dirname }}"
copy: "no"
when:
- not blazar_developer_mode | bool
- blazar_get_venv | changed or blazar_venv_dir | changed
when: blazar_get_venv | changed
notify:
- Restart blazar services
- name: Install pip packages
pip:
name: "{{ blazar_pip_packages | join(' ') }}"
state: "{{ blazar_package_state }}"
state: "{{ blazar_pip_package_state }}"
virtualenv: "{{ blazar_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ blazar_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('') }}
register: install_packages
until: install_packages|success
retries: 5
delay: 2
when: blazar_developer_mode | bool
when: blazar_get_venv | failed or blazar_get_venv | skipped
notify:
- Restart blazar services
- name: Remove python from path first (CentOS, openSUSE)
file:
path: "{{ blazar_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- blazar_get_venv | changed
- name: Update virtualenv path
command: >
virtualenv-tools --update-path=auto --reinitialize {{ blazar_bin | dirname }}
when:
- not blazar_developer_mode | bool
- blazar_get_venv | changed or blazar_venv_dir | changed
shell: |
find {{ blazar_bin }} -name \*.pyc -delete
sed -si '1s/^.*python.*$/#!{{ blazar_bin | replace ('/','\/') }}\/python/' {{ blazar_bin }}/*
virtualenv {{ blazar_bin | dirname }}
when: blazar_get_venv | changed
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: blazar
option: venv_tag
value: "{{ blazar_venv_tag }}"
value: "{{ blazar_venv_tag }}"

View File

@ -14,11 +14,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: generate blazar configuration
template:
src: "{{ item }}"
dest: "{{ blazar_conf_dir }}"
- name: Deploy configuration files
config_template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "root"
group: "{{ blazar_system_group_name }}"
mode: "0640"
config_overrides: "{{ item.config_overrides }}"
config_type: "{{ item.config_type }}"
with_items:
- api-paste.ini
- policy.json
- blazar.conf
- src: "blazar.conf.j2"
dest: "{{ blazar_etc_dir }}/blazar.conf"
config_overrides: "{{ blazar_blazar_conf_overrides }}"
config_type: "ini"
notify:
- Restart blazar services

View File

@ -14,21 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: blazar_apt_packages.yml
- name: install pip packages
pip:
name: "{{ item }}"
with_items:
- virtualenv
- name: clone blazar repo
git:
repo: "{{ blazar_git_repo }}"
dest: /opt/blazar
clone: yes
version: master
- name: create blazar group
group:
name: "{{ blazar_system_group_name }}"
@ -40,10 +25,40 @@
group: "{{ blazar_system_group_name }}"
createhome: no
- name: make blazar configuration directory
- name: Create blazar directories
file:
path: "{{ item }}"
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner | default(blazar_system_user_name) }}"
group: "{{ item.group | default(blazar_system_group_name) }}"
mode: "{{ item.mode | default('0755') }}"
with_items:
- /etc/blazar
- /etc/blazar/snapshot
- path: "/openstack"
mode: "0755"
owner: "root"
group: "root"
- path: "{{ blazar_etc_dir }}"
mode: "0755"
group: "{{ blazar_system_group_name }}"
owner: "{{ blazar_system_user_name }}"
- name: test for log directory or link
shell: |
if [ -h "/var/log/blazar" ]; then
chown -h {{ blazar_system_user_name }}:{{ blazar_system_group_name }} "/var/log/blazar"
chown -R {{ blazar_system_user_name }}:{{ blazar_system_group_name }} "$(readlink /var/log/blazar)"
else
exit 1
fi
register: log_dir
failed_when: false
changed_when: log_dir.rc != 0
- name: Create blazar log dir
file:
path: "/var/log/blazar/"
state: directory
owner: "{{ blazar_system_user_name }}"
group: "{{ blazar_system_group_name }}"
mode: "0755"
when: log_dir.rc != 0

View File

@ -14,16 +14,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
- "{{ ansible_os_family | lower }}.yml"
tags:
- always
- include: blazar_pre_install.yml
tags:
- blazar-install
- include: blazar_install.yml
tags:
- blazar-install
- include: blazar_post_install.yml
tags:
- blazar-config
- include: blazar_service_setup.yml
when: >
inventory_hostname == groups['blazar_all'][0]
- include: "blazar_init_{{ ansible_service_mgr }}.yml"
tags:
- blazar-config
- include: blazar_db_setup.yml
when: >
inventory_hostname == groups['blazar_all'][0]
when:
- "inventory_hostname == ((groups['blazar']| intersect(ansible_play_hosts)) | list)[0]"
tags:
- blazar-config
- include: blazar_service_setup.yml
when:
- "inventory_hostname == ((groups['blazar']| intersect(ansible_play_hosts)) | list)[0]"
tags:
- blazar-config

15
templates/blazar.conf.j2 Normal file
View File

@ -0,0 +1,15 @@
[DEFAULT]
host=0.0.0.0
port={{ blazar_service_port }}
[manager]
plugins=physical.host.plugin,virtual.instance.plugin
[keystone_authtoken]
auth_type={{ blazar_keystone_auth_plugin }}
project_domain_name={{ blazar_service_project_domain_id }}
project_name={{ blazar_service_user_domain_id }}
user_domain_name={{ blazar_service_user_domain_id }}
username={{ blazar_service_user_name }}
password={{ blazar_service_password }}
auth_url={{ keystone_service_adminuri }}

View File

@ -13,18 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
blazar_service_tenant_name: service
# Use the tests repo values
blazar_rabbitmq_port: "{{ rabbitmq_port }}"
blazar_rabbitmq_servers: "{{ rabbitmq_servers }}"
blazar_rabbitmq_host_group: "{{ rabbitmq_host_group }}"
blazar_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}"
blazar_service_publicuri: "{{ blazar_service_proto }}://{{ hostvars[groups['blazar_all'][0]]['ansible_host'] }}:{{ blazar_service_port }}"
blazar_service_adminurl: "{{ blazar_service_proto }}://{{ hostvars[groups['blazar_all'][0]]['ansible_host'] }}:{{ blazar_service_port }}"
blazar_service_adminuri: "{{ blazar_service_proto }}://{{ hostvars[groups['blazar_all'][0]]['ansible_host'] }}:{{ blazar_service_port }}"
blazar_aodh_enabled: false
blazar_gnocchi_enabled: false
blazar_galera_address: "{{ test_galera_host }}"
# Required settings with no defaults
blazar_rabbitmq_password: "secrete"
blazar_service_password: "secrete"
blazar_container_mysql_password: "secrete"
# Force dev mode for the role test
blazar_developer_mode: true
blazar_galera_address: "{{ test_galera_host }}"
# The defaults use to the LB address, so we need to
# override them to the container address.
blazar_service_publicuri: "{{ blazar_service_proto }}://{{ hostvars[groups['blazar_all'][0]]['ansible_host'] }}:{{ blazar_service_port }}"
blazar_service_internaluri: "{{ blazar_service_publicuri }}"
blazar_service_adminuri: "{{ blazar_service_publicuri }}"

View File

@ -20,10 +20,18 @@
gather_facts: true
any_errors_fatal: true
pre_tasks:
- include: common/ensure-rabbitmq.yml
vhost_name: "{{ blazar_rabbitmq_vhost }}"
user_name: "{{ cblazar_rabbitmq_userid }}"
user_password: "{{ blazar_rabbitmq_password }}"
when:
- "groups['rabbitmq_all'] is defined"
- include: common/create-grant-db.yml
db_name: "{{ blazar_galera_database }}"
db_password: "{{ blazar_container_mysql_password }}"
roles:
- role: os_blazar
- role: "os_blazar"
vars_files:
- common/test-vars.yml
- common/test-vars.yml

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2017, Rackspace US, Inc.
# Copyright 2017, taseer94@gmail.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -33,7 +33,6 @@ set -e
export TESTING_HOME=${TESTING_HOME:-$HOME}
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
export CLONE_UPGRADE_TESTS=${CLONE_UPGRADE_TESTS:-no}
export ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
## Functions -----------------------------------------------------------------
@ -53,11 +52,7 @@ EOF
# If zuul-cloner is present, use it so that we
# also include any dependent patches from the
# tests repo noted in the commit message.
# We only want to use zuul-cloner if we detect
# zuul v2 running, so we check for the presence
# of the ZUUL_REF environment variable.
# ref: http://git.openstack.org/cgit/openstack-infra/zuul/tree/zuul/ansible/filter/zuul_filters.py?h=feature/zuulv3#n17
if [[ -x /usr/zuul-env/bin/zuul-cloner ]] && [[ "${ZUUL_REF:-none}" != "none" ]]; then
if [[ -x /usr/zuul-env/bin/zuul-cloner ]]; then
# Prepare the clonemap for zuul-cloner to use
create_tests_clonemap
@ -79,22 +74,9 @@ if [[ -x /usr/zuul-env/bin/zuul-cloner ]] && [[ "${ZUUL_REF:-none}" != "none" ]]
elif [[ ! -d tests/common ]]; then
# The tests repo doesn't need a clone, we can just
# symlink it. As zuul v3 clones into a folder called
# 'workspace' we have to use one of its environment
# variables to determine the project name.
if [[ "${ZUUL_SHORT_PROJECT_NAME:-none}" == "openstack-ansible-tests" ]] ||\
[[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
# symlink it.
if [[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
ln -s ${WORKING_DIR} ${WORKING_DIR}/tests/common
# In zuul v3 any dependent repository is placed into
# /home/zuul/src/git.openstack.org, so we check to see
# if there is a tests checkout there already. If so, we
# symlink that and use it.
elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
ln -s "${ZUUL_TESTS_CLONE_LOCATION}" ${WORKING_DIR}/tests/common
# Otherwise we're clearly not in zuul or using a previously setup
# repo in some way, so just clone it from upstream.
else
git clone \
https://git.openstack.org/openstack/openstack-ansible-tests \
@ -114,4 +96,4 @@ if [[ "${CLONE_UPGRADE_TESTS}" == "yes" ]]; then
https://git.openstack.org/openstack/openstack-ansible-tests \
${WORKING_DIR}/tests/common/previous
fi
fi
fi

View File

@ -1 +0,0 @@
# vars