aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-07 07:26:38 +0000
committerGerrit Code Review <review@openstack.org>2016-09-07 07:26:38 +0000
commit00ffed38727b9f5b09562777d75f42e096f8bc36 (patch)
treee196f9204bb40f9917d7faa6c69775bf566b0bbc
parent9d9f3eea04a57798817d16635a08860e778535ef (diff)
parentd3d3472326598b89a2d589e4446ac167d989521a (diff)
downloadkolla-00ffed38727b9f5b09562777d75f42e096f8bc36.tar.gz
kolla-00ffed38727b9f5b09562777d75f42e096f8bc36.zip
Merge "Implement Ansible rally role"
-rw-r--r--ansible/group_vars/all.yml1
-rw-r--r--ansible/inventory/all-in-one3
-rw-r--r--ansible/inventory/multinode3
-rw-r--r--ansible/roles/rally/defaults/main.yml18
-rw-r--r--ansible/roles/rally/meta/main.yml3
-rw-r--r--ansible/roles/rally/tasks/bootstrap.yml41
-rw-r--r--ansible/roles/rally/tasks/bootstrap_service.yml20
-rw-r--r--ansible/roles/rally/tasks/config.yml26
-rw-r--r--ansible/roles/rally/tasks/deploy.yml4
-rw-r--r--ansible/roles/rally/tasks/do_reconfigure.yml64
-rw-r--r--ansible/roles/rally/tasks/main.yml2
-rw-r--r--ansible/roles/rally/tasks/pull.yml6
-rw-r--r--ansible/roles/rally/tasks/reconfigure.yml3
-rw-r--r--ansible/roles/rally/tasks/start.yml11
-rw-r--r--ansible/roles/rally/tasks/upgrade.yml4
-rw-r--r--ansible/roles/rally/templates/rally.conf.j29
-rw-r--r--ansible/roles/rally/templates/rally.json.j211
-rw-r--r--ansible/site.yml6
-rw-r--r--docker/rally/extend_start.sh2
-rw-r--r--etc/kolla/globals.yml2
-rw-r--r--etc/kolla/passwords.yml2
-rw-r--r--releasenotes/notes/add-rally-c6d1468accfb1da6.yaml3
22 files changed, 242 insertions, 2 deletions
diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index 32d1ea79d..f14b86b4e 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -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"
diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one
index 8f0358007..ae7a68467 100644
--- a/ansible/inventory/all-in-one
+++ b/ansible/inventory/all-in-one
@@ -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.
#
diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode
index 7775448ae..0e09ee8fb 100644
--- a/ansible/inventory/multinode
+++ b/ansible/inventory/multinode
@@ -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.
#
diff --git a/ansible/roles/rally/defaults/main.yml b/ansible/roles/rally/defaults/main.yml
new file mode 100644
index 000000000..ced0999cb
--- /dev/null
+++ b/ansible/roles/rally/defaults/main.yml
@@ -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 }}"
diff --git a/ansible/roles/rally/meta/main.yml b/ansible/roles/rally/meta/main.yml
new file mode 100644
index 000000000..6b4fff8fe
--- /dev/null
+++ b/ansible/roles/rally/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - { role: common }
diff --git a/ansible/roles/rally/tasks/bootstrap.yml b/ansible/roles/rally/tasks/bootstrap.yml
new file mode 100644
index 000000000..9875c3e57
--- /dev/null
+++ b/ansible/roles/rally/tasks/bootstrap.yml
@@ -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
diff --git a/ansible/roles/rally/tasks/bootstrap_service.yml b/ansible/roles/rally/tasks/bootstrap_service.yml
new file mode 100644
index 000000000..6d5f1f086
--- /dev/null
+++ b/ansible/roles/rally/tasks/bootstrap_service.yml
@@ -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] }}" \ No newline at end of file
diff --git a/ansible/roles/rally/tasks/config.yml b/ansible/roles/rally/tasks/config.yml
new file mode 100644
index 000000000..c210dc338
--- /dev/null
+++ b/ansible/roles/rally/tasks/config.yml
@@ -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"
diff --git a/ansible/roles/rally/tasks/deploy.yml b/ansible/roles/rally/tasks/deploy.yml
new file mode 100644
index 000000000..1dc8c04e3
--- /dev/null
+++ b/ansible/roles/rally/tasks/deploy.yml
@@ -0,0 +1,4 @@
+---
+- include: config.yml
+- include: bootstrap.yml
+- include: start.yml
diff --git a/ansible/roles/rally/tasks/do_reconfigure.yml b/ansible/roles/rally/tasks/do_reconfigure.yml
new file mode 100644
index 000000000..79c3dde5a
--- /dev/null
+++ b/ansible/roles/rally/tasks/do_reconfigure.yml
@@ -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 }}"
diff --git a/ansible/roles/rally/tasks/main.yml b/ansible/roles/rally/tasks/main.yml
new file mode 100644
index 000000000..b017e8b4a
--- /dev/null
+++ b/ansible/roles/rally/tasks/main.yml
@@ -0,0 +1,2 @@
+---
+- include: "{{ action }}.yml"
diff --git a/ansible/roles/rally/tasks/pull.yml b/ansible/roles/rally/tasks/pull.yml
new file mode 100644
index 000000000..bcada160d
--- /dev/null
+++ b/ansible/roles/rally/tasks/pull.yml
@@ -0,0 +1,6 @@
+---
+- name: Pulling rally image
+ kolla_docker:
+ action: "pull_image"
+ common_options: "{{ docker_common_options }}"
+ image: "{{ rally_image_full }}"
diff --git a/ansible/roles/rally/tasks/reconfigure.yml b/ansible/roles/rally/tasks/reconfigure.yml
new file mode 100644
index 000000000..66933249b
--- /dev/null
+++ b/ansible/roles/rally/tasks/reconfigure.yml
@@ -0,0 +1,3 @@
+---
+- include: do_reconfigure.yml
+ serial: "30%"
diff --git a/ansible/roles/rally/tasks/start.yml b/ansible/roles/rally/tasks/start.yml
new file mode 100644
index 000000000..f95000fa1
--- /dev/null
+++ b/ansible/roles/rally/tasks/start.yml
@@ -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/"
diff --git a/ansible/roles/rally/tasks/upgrade.yml b/ansible/roles/rally/tasks/upgrade.yml
new file mode 100644
index 000000000..1f16915ad
--- /dev/null
+++ b/ansible/roles/rally/tasks/upgrade.yml
@@ -0,0 +1,4 @@
+---
+- include: config.yml
+
+- include: start.yml
diff --git a/ansible/roles/rally/templates/rally.conf.j2 b/ansible/roles/rally/templates/rally.conf.j2
new file mode 100644
index 000000000..853751871
--- /dev/null
+++ b/ansible/roles/rally/templates/rally.conf.j2
@@ -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
diff --git a/ansible/roles/rally/templates/rally.json.j2 b/ansible/roles/rally/templates/rally.json.j2
new file mode 100644
index 000000000..c7c2d0217
--- /dev/null
+++ b/ansible/roles/rally/templates/rally.json.j2
@@ -0,0 +1,11 @@
+{
+ "command": "sleep infinity",
+ "config_files":[
+ {
+ "source": "{{ container_config_directory }}/rally.conf",
+ "dest": "/etc/rally/rally.conf",
+ "owner": "root",
+ "perm": "0600"
+ }
+ ]
+}
diff --git a/ansible/site.yml b/ansible/site.yml
index 7bec545b8..b69695642 100644
--- a/ansible/site.yml
+++ b/ansible/site.yml
@@ -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
diff --git a/docker/rally/extend_start.sh b/docker/rally/extend_start.sh
index a3af2c96e..06d4d6086 100644
--- a/docker/rally/extend_start.sh
+++ b/docker/rally/extend_start.sh
@@ -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
diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml
index 554ef1e66..a5a575de4 100644
--- a/etc/kolla/globals.yml
+++ b/etc/kolla/globals.yml
@@ -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
###################
diff --git a/etc/kolla/passwords.yml b/etc/kolla/passwords.yml
index b635c6851..b54a33c02 100644
--- a/etc/kolla/passwords.yml
+++ b/etc/kolla/passwords.yml
@@ -73,6 +73,8 @@ watcher_keystone_password:
congress_database_password:
congress_keystone_password:
+rally_database_password:
+
horizon_secret_key:
telemetry_secret_key:
diff --git a/releasenotes/notes/add-rally-c6d1468accfb1da6.yaml b/releasenotes/notes/add-rally-c6d1468accfb1da6.yaml
new file mode 100644
index 000000000..3874b6fad
--- /dev/null
+++ b/releasenotes/notes/add-rally-c6d1468accfb1da6.yaml
@@ -0,0 +1,3 @@
+---
+features:
+ - Implement rally ansible role