browbeat/ansible/install/roles/rally/tasks/main.yml

202 lines
7.0 KiB
YAML

---
#
# Browbeat's Rally Install
#
- name: Create rally virtualenv
command: virtualenv --python=python3 {{ rally_venv }} creates={{ rally_venv }}
when: ansible_distribution_major_version <= '8'
- name: Create rally virtualenv
command: python3 -m venv {{ rally_venv }} creates={{ rally_venv }}
when: ansible_distribution_major_version == '9'
- name: Rally Add browbeat to Python path
shell: echo 'export PYTHONPATH=$PYTHONPATH:{{ browbeat_path }}' >> {{ rally_venv }}/bin/activate
- name: Setup rally-venv CA certificate path
lineinfile:
dest: "{{ rally_venv }}/bin/activate"
line: 'export REQUESTS_CA_BUNDLE={{ overcloud_ca_path }}'
when: overcloud_ca_path is defined
- name: Upgrade pip if it is old
shell: |
source "{{ rally_venv }}/bin/activate"
if [ "$(pip --version | cut -d' ' -f2 | cut -d'.' -f1)" -lt "19" ]; then
pip install --upgrade 'pip<20'
fi
args:
executable: /bin/bash
chdir: "{{ browbeat_path }}"
- name: Install rally-requirements into rally-venv
pip:
requirements: "{{ browbeat_path }}/tools-requirements.txt"
virtualenv: "{{ rally_venv }}"
- name: Install Rally with OpenStack plugins into rally-venv
pip:
name: rally-openstack
version: "{{ rally_openstack_version }}"
virtualenv: "{{ rally_venv }}"
# Till https://bugs.launchpad.net/rally/+bug/1922707 fixed
- name: set decorator to 4.4.2
pip:
name: decorator
version: "4.4.2"
virtualenv: "{{ rally_venv }}"
# Till https://bugs.launchpad.net/rally/+bug/2004022 fixed
- name: Ensure SQLAlchemy<2.0.0
pip:
name: 'SQLAlchemy<2.0.0'
virtualenv: "{{ rally_venv }}"
# Till https://bugs.launchpad.net/rally/+bug/2042910 fixed
- name: Ensure testtools<2.7.0
pip:
name: 'testtools<2.7.0'
virtualenv: "{{ rally_venv }}"
# Till browbeat code is compatible with novaclient-18.3.0
# https://bugs.launchpad.net/openstack-browbeat/+bug/2008235
- name: Ensure python-novaclient<18.3.0
pip:
name: 'python-novaclient<18.3.0'
virtualenv: "{{ rally_venv }}"
- name: Create rally configuration directory
file:
path: "{{ rally_venv }}/etc/rally"
state: directory
- name: Setup rally.conf
template:
src: rally.conf.j2
dest: "{{ rally_venv }}/etc/rally/rally.conf"
- name: Setup rally database
shell: . {{ rally_venv }}/bin/activate; rally db recreate
# Install rally extra code which we develop in browbeat
# as python package. This code can be used in browbeat rally plugins.
# Sqlalchemy giving errors when we run this extra DB code as rally plugin
# so we came up with this python package approach.
- block:
- name: Install rally browbeat code
shell: |
source {{ rally_venv }}/bin/activate
pip install .
args:
executable: /bin/bash
chdir: "{{ role_path }}/files/browbeat-rally"
- name: Create lock table in rally db for dynamic workloads
shell: |
source {{ rally_venv }}/bin/activate
python {{ role_path }}/files/create_lock_table.py
when: is_rhoso_deployment or rhosp_version is version('13.0', '>=')
- block:
- name: copy of stackrc
copy:
src: "{{ stackrc }}"
dest: "{{home_dir}}/undercloudrc"
- name: Get the OS_AUTH_URL value in stackrc
shell: cat {{home_dir}}/undercloudrc | grep OS_AUTH_URL=
register: os_auth_url
when: (rhosp_version is version('17.0', '<'))
- name: Add v3 to OS_AUTH_URL in stackrc
replace:
path: "{{home_dir}}/undercloudrc"
regexp: "{{ os_auth_url.stdout }}"
replace: '{{ os_auth_url.stdout }}/v3'
when: (rhosp_version is version('17.0', '<'))
- name: Add OS_CACERT to undercloudrc
lineinfile:
path: "{{home_dir}}/undercloudrc"
insertafter: "export OS_USER"
line: "export OS_CACERT=/etc/pki/ca-trust/source/anchors/undercloud-cacert.pem"
when: rhosp_version is version('15.0', '>=') and (rhosp_version is version('17.0', '<'))
- name: Setup rally deployment for undercloud
shell: . {{ rally_venv }}/bin/activate; . "{{home_dir}}/undercloudrc"; rally deployment create --fromenv --name undercloud
- name: Check Rally deployment for undercloud
shell: . {{ rally_venv }}/bin/activate; . "{{home_dir}}/undercloudrc"; rally deployment check
register: rally_deployment_check_undercloud
- name: Fail if Rally deployment cannot be verfied on undercloud
fail:
msg: "Failed to verify that your deployment is ready to benchmark"
when: rally_deployment_check_undercloud.rc != 0
when: rally_undercloud_enabled
- block:
- name: Setup rally deployment for overcloud
shell: . {{ rally_venv }}/bin/activate; . {{ overcloudrc }}; rally deployment create --fromenv --name overcloud
- name: Check Rally deployment for overcloud
shell: . {{ rally_venv }}/bin/activate; . {{ overcloudrc }}; rally deployment check
register: rally_deployment_check_overcloud
- name: Fail if Rally deployment cannot be verified for overcloud
fail:
msg: "Failed to verify that your deployment is ready to benchmark"
when: rally_deployment_check_overcloud.rc != 0
when: not is_rhoso_deployment
- block:
- name: Read clouds.yaml file
ansible.builtin.command: cat "{{ clouds_yaml_path }}"
register: clouds_yaml_content
- name: Parse clouds.yaml content
ansible.builtin.set_fact:
clouds_yaml: "{{ clouds_yaml_content.stdout | from_yaml }}"
- name: Generate JSON content
ansible.builtin.set_fact:
json_content: |
{
"openstack": {
"auth_url": "{{ clouds_yaml.clouds.default.auth.auth_url }}",
"region_name": "{{ clouds_yaml.clouds.default.region_name }}",
"endpoint_type": "public",
"admin": {
"username": "{{ clouds_yaml.clouds.default.auth.username }}",
"password": "{{ clouds_yaml.clouds.default.auth.password }}",
"user_domain_name": "{{ clouds_yaml.clouds.default.auth.user_domain_name }}",
"project_name": "{{ clouds_yaml.clouds.default.auth.project_name }}",
"project_domain_name": "{{ clouds_yaml.clouds.default.auth.project_domain_name }}"
},
"https_insecure": {{ clouds_yaml.clouds.default.insecure | default(false) }}
}
}
- name: Write JSON content to file
ansible.builtin.copy:
content: "{{ json_content }}"
dest: "{{ json_output_path }}"
- name: Setup rally deployment for overcloud
shell: . {{ rally_venv }}/bin/activate; rally deployment create --file={{ json_output_path }} --name overcloud
- name: Check Rally deployment for overcloud
shell: . {{ rally_venv }}/bin/activate; rally deployment check
register: rally_deployment_check_overcloud
- name: Fail if Rally deployment cannot be verified for overcloud
fail:
msg: "Failed to verify that your deployment is ready to benchmark"
when: rally_deployment_check_overcloud.rc != 0
when: is_rhoso_deployment
vars:
json_output_path: "~/keystone-v3.json"