Merge "Implement Ansible rally role"

This commit is contained in:
Jenkins 2016-09-07 07:26:38 +00:00 committed by Gerrit Code Review
commit 00ffed3872
22 changed files with 242 additions and 2 deletions

View File

@ -245,6 +245,7 @@ enable_murano: "no"
enable_neutron_lbaas: "no"
enable_neutron_qos: "no"
enable_neutron_agent_ha: "no"
enable_rally: "no"
enable_swift: "no"
enable_tempest: "no"
enable_watcher: "no"

View File

@ -103,6 +103,9 @@ control
[watcher:children]
control
[rally:children]
control
# Additional control implemented here. These groups allow you to control which
# services run on which hosts at a per-service level.
#

View File

@ -120,6 +120,9 @@ control
[watcher:children]
control
[rally:children]
control
# Additional control implemented here. These groups allow you to control which
# services run on which hosts at a per-service level.
#

View File

@ -0,0 +1,18 @@
---
project_name: "rally"
########
# Docker
########
rally_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-rally"
rally_tag: "{{ openstack_release }}"
rally_image_full: "{{ rally_image }}:{{ rally_tag }}"
####################
# Database
####################
rally_database_name: "rally"
rally_database_user: "rally"
rally_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"

View File

@ -0,0 +1,3 @@
---
dependencies:
- { role: common }

View File

@ -0,0 +1,41 @@
---
- name: Creating rally database
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_db
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ rally_database_name }}'"
register: database
changed_when: "{{ database.stdout.find('localhost | SUCCESS => ') != -1 and
(database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['rally'][0] }}"
- name: Reading json from variable
set_fact:
database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
- name: Creating rally database user and setting permissions
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_user
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ rally_database_name }}'
password='{{ rally_database_password }}'
host='%'
priv='{{ rally_database_name }}.*:ALL'
append_privs='yes'"
register: database_user_create
changed_when: "{{ database_user_create.stdout.find('localhost | SUCCESS => ') != -1 and
(database_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database_user_create.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['rally'][0] }}"
- include: bootstrap_service.yml
when: database_created

View File

@ -0,0 +1,20 @@
---
- name: Running rally bootstrap container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
detach: False
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ rally_image_full }}"
labels:
BOOTSTRAP:
name: "bootstrap_rally"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/rally/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True
delegate_to: "{{ groups['rally'][0] }}"

View File

@ -0,0 +1,26 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
with_items:
- "rally"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "rally"
- name: Copying over rally.conf
merge_configs:
vars:
project_name: "rally"
sources:
- "{{ role_path }}/templates/rally.conf.j2"
- "{{ node_custom_config }}/rally.conf"
dest: "{{ node_config_directory }}/{{ item }}/rally.conf"
with_items:
- "rally"

View File

@ -0,0 +1,4 @@
---
- include: config.yml
- include: bootstrap.yml
- include: start.yml

View File

@ -0,0 +1,64 @@
---
- name: Ensuring the containers up
kolla_docker:
name: "{{ item.name }}"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups[item.group]
with_items:
- { name: rally, group: rally }
- include: config.yml
- name: Check the configs
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups[item.group]
with_items:
- { name: rally, group: rally }
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
# just remove the container and start again
- name: Containers config strategy
kolla_docker:
name: "{{ item.name }}"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups[item.group]
with_items:
- { name: rally, group: rally }
- name: Remove the containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "remove_container"
register: remove_containers
when:
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: rally, group: rally }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "restart_container"
when:
- config_strategy == 'COPY_ALWAYS'
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- item[2]['rc'] == 1
- inventory_hostname in groups[item[0]['group']]
with_together:
- [{ name: rally, group: rally }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"

View File

@ -0,0 +1,2 @@
---
- include: "{{ action }}.yml"

View File

@ -0,0 +1,6 @@
---
- name: Pulling rally image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ rally_image_full }}"

View File

@ -0,0 +1,3 @@
---
- include: do_reconfigure.yml
serial: "30%"

View File

@ -0,0 +1,11 @@
---
- name: Starting rally container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ rally_image_full }}"
name: "rally"
volumes:
- "{{ node_config_directory }}/rally/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"

View File

@ -0,0 +1,4 @@
---
- include: config.yml
- include: start.yml

View File

@ -0,0 +1,9 @@
[DEFAULT]
debug = {{ openstack_logging_debug }}
log_file = rally.log
use_stderr = False
log_dir = /var/log/kolla/rally/
[database]
connection = mysql+pymysql://{{ rally_database_user }}:{{ rally_database_password }}@{{ rally_database_address }}/{{ rally_database_name }}
max_retries = -1

View File

@ -0,0 +1,11 @@
{
"command": "sleep infinity",
"config_files":[
{
"source": "{{ container_config_directory }}/rally.conf",
"dest": "/etc/rally/rally.conf",
"owner": "root",
"perm": "0600"
}
]
}

View File

@ -260,6 +260,12 @@
tags: tempest,
when: enable_tempest | bool }
- hosts: rally
roles:
- { role: rally,
tags: rally,
when: enable_rally | bool }
- hosts:
- watcher-api
- watcher-engine

View File

@ -3,7 +3,7 @@
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
rally-manage db recreate
rally-manage db create || rally-manage db upgrade
exit 0
fi

View File

@ -140,11 +140,11 @@ kolla_internal_vip_address: "10.10.10.254"
#enable_neutron_lbaas: "no"
#enable_neutron_qos: "no"
#enable_neutron_agent_ha: "no"
#enable_rally: "no"
#enable_swift: "no"
#enable_tempest: "no"
#enable_watcher: "no"
###################
# Ceph options
###################

View File

@ -73,6 +73,8 @@ watcher_keystone_password:
congress_database_password:
congress_keystone_password:
rally_database_password:
horizon_secret_key:
telemetry_secret_key:

View File

@ -0,0 +1,3 @@
---
features:
- Implement rally ansible role