diff --git a/ansible/install/browbeat.yml b/ansible/install/browbeat.yml index 1b18912bd..ac9d50963 100644 --- a/ansible/install/browbeat.yml +++ b/ansible/install/browbeat.yml @@ -1,26 +1,15 @@ --- -# -# Playbook to install Browbeat (Rally + Shaker) on undercloud -# +- hosts: localhost + tasks: + - debug: + msg: "redirecting to browbeat installation based on deployment type" -- hosts: Browbeat - remote_user: "{{ browbeat_user }}" - roles: - - common - - osp_version - - browbeat - - stockpile - - { role: browbeat-results, when: browbeat_results_in_httpd|bool} - - firewall - - rally - - shaker - - { role: flavors, when: browbeat_create_flavors|bool} - - { role: images, when: browbeat_upload_guest_images|bool} - - { role: workloads, when: install_browbeat_workloads|bool} - - { role: e2e-benchmarking, when: install_e2e_benchmarking|bool} - environment: "{{proxy_env}}" +- name: Install browbeat + import_playbook: browbeat_rhoso.yaml + vars: + rally_undercloud_enabled: false + when: is_rhoso_deployment -- hosts: Controller*, Compute* - remote_user: "{{ host_remote_user }}" - roles: - - no-sshd-dns +- name: Install browbeat + import_playbook: browbeat_rhosp.yaml + when: not is_rhoso_deployment diff --git a/ansible/install/browbeat_rhoso.yaml b/ansible/install/browbeat_rhoso.yaml new file mode 100644 index 000000000..b2b1f0625 --- /dev/null +++ b/ansible/install/browbeat_rhoso.yaml @@ -0,0 +1,18 @@ +--- +# +# Playbook to install Browbeat(Rally) for RHOSO +# + +- hosts: localhost + gather_facts: true + vars: + ansible_user: "{{ browbeat_user }}" + ansible_python_interpreter: "{{ python_interpreter }}" + roles: + - browbeat + - { role: browbeat-results, when: browbeat_results_in_httpd|bool} + - firewall + - rally + - { role: flavors, when: browbeat_create_flavors|bool} + - { role: images, when: browbeat_upload_guest_images|bool} + environment: "{{proxy_env}}" diff --git a/ansible/install/browbeat_rhosp.yaml b/ansible/install/browbeat_rhosp.yaml new file mode 100644 index 000000000..1b18912bd --- /dev/null +++ b/ansible/install/browbeat_rhosp.yaml @@ -0,0 +1,26 @@ +--- +# +# Playbook to install Browbeat (Rally + Shaker) on undercloud +# + +- hosts: Browbeat + remote_user: "{{ browbeat_user }}" + roles: + - common + - osp_version + - browbeat + - stockpile + - { role: browbeat-results, when: browbeat_results_in_httpd|bool} + - firewall + - rally + - shaker + - { role: flavors, when: browbeat_create_flavors|bool} + - { role: images, when: browbeat_upload_guest_images|bool} + - { role: workloads, when: install_browbeat_workloads|bool} + - { role: e2e-benchmarking, when: install_e2e_benchmarking|bool} + environment: "{{proxy_env}}" + +- hosts: Controller*, Compute* + remote_user: "{{ host_remote_user }}" + roles: + - no-sshd-dns diff --git a/ansible/install/group_vars/all.yml b/ansible/install/group_vars/all.yml index 45be88a64..d2adada8e 100644 --- a/ansible/install/group_vars/all.yml +++ b/ansible/install/group_vars/all.yml @@ -15,6 +15,14 @@ host_remote_user: heat-admin # Tripleo is the only installer supported currently tripleo: true +# Set to true if the deployment is RHOSO +is_rhoso_deployment: false + +python_interpreter: /usr/bin/python3.6 + +# Make sure clouds.yaml exists at this path for RHOSO +clouds_yaml_path: "~/.config/openstack/clouds.yaml" + home_dir: "/home/{{browbeat_user}}" browbeat_path: "{{home_dir}}/browbeat" diff --git a/ansible/install/roles/browbeat/tasks/main.yml b/ansible/install/roles/browbeat/tasks/main.yml index a3fa3731d..b2072c8fd 100644 --- a/ansible/install/roles/browbeat/tasks/main.yml +++ b/ansible/install/roles/browbeat/tasks/main.yml @@ -117,37 +117,40 @@ line: 'export REQUESTS_CA_BUNDLE={{ overcloud_ca_path }}' when: overcloud_ca_path is defined -- name: Determine if generate_tripleo_hostfile has been run - stat: - path: "{{ browbeat_path }}/ansible/hosts" - register: hosts_file_exists +- block: + - name: Determine if generate_tripleo_hostfile has been run + stat: + path: "{{ browbeat_path }}/ansible/hosts" + register: hosts_file_exists -- name: Determine if generate_tripleo_inventory has been run - stat: - path: "{{ browbeat_path }}/ansible/hosts.yml" - register: hosts_yml_file_exists + - name: Determine if generate_tripleo_inventory has been run + stat: + path: "{{ browbeat_path }}/ansible/hosts.yml" + register: hosts_yml_file_exists -- name: set either of inventory file exists - set_fact: - inventry_file: "{{ (hosts_file_exists.stat.exists and hosts_file_exists.stat.isreg) or (hosts_yml_file_exists.stat.exists and hosts_yml_file_exists.stat.isreg) }}" + - name: set either of inventory file exists + set_fact: + inventry_file: "{{ (hosts_file_exists.stat.exists and hosts_file_exists.stat.isreg) or (hosts_yml_file_exists.stat.exists and hosts_yml_file_exists.stat.isreg) }}" -- debug: msg="Hosts file is already generated. {{ inventry_file }}" - when: inventry_file + - debug: + msg: "Hosts file is already generated. {{ inventry_file }}" + when: inventry_file -- name: Generate hosts and ssh-config on Browbeat Machine - Default(stack) - shell: . {{ home_dir }}/stackrc; {{ browbeat_path }}/ansible/generate_tripleo_inventory.sh -l --user stack - when: tripleo and (not inventry_file) and ansible_user!= "zuul" + - name: Generate hosts and ssh-config on Browbeat Machine - Default(stack) + shell: . {{ home_dir }}/stackrc; {{ browbeat_path }}/ansible/generate_tripleo_inventory.sh -l --user stack + when: tripleo and (not inventry_file) and ansible_user != "zuul" -- name: Generate hosts and ssh-config on Browbeat Machine - Zuul - shell: . {{ home_dir }}/stackrc; {{ browbeat_path }}/ansible/generate_tripleo_inventory.sh -l --user zuul - when: tripleo and (not inventry_file) and ansible_user== "zuul" + - name: Generate hosts and ssh-config on Browbeat Machine - Zuul + shell: . {{ home_dir }}/stackrc; {{ browbeat_path }}/ansible/generate_tripleo_inventory.sh -l --user zuul + when: tripleo and (not inventry_file) and ansible_user == "zuul" -- name: Move files to correct location - command: mv {{item}} {{ browbeat_path }}/ansible/{{item}} - with_items: - - hosts.yml - - heat-admin-id_rsa - when: "(tripleo and (not inventry_file))" + - name: Move files to correct location + command: mv {{ item }} {{ browbeat_path }}/ansible/{{ item }} + with_items: + - hosts.yml + - heat-admin-id_rsa + when: tripleo and (not inventry_file) + when: not is_rhoso_deployment - name: Install requirements.txt into browbeat-venv pip: @@ -180,4 +183,4 @@ insertafter: "hide" line: " v.Optional('regex',default=''): v.All(str)," - when: collectd_prometheus + when: collectd_prometheus and not is_rhoso_deployment diff --git a/ansible/install/roles/flavors/tasks/main.yml b/ansible/install/roles/flavors/tasks/main.yml index f4c5c5482..06519f924 100644 --- a/ansible/install/roles/flavors/tasks/main.yml +++ b/ansible/install/roles/flavors/tasks/main.yml @@ -5,6 +5,15 @@ # Ignore errors here incase the flavors already exist. - name: Add flavors to overcloud - shell: . {{ overcloudrc }}; nova flavor-create {{item.name}} auto {{item.memory}} {{item.disk}} {{item.cpu}} + shell: . {{ overcloudrc }}; openstack flavor create {{item.name}} auto {{item.memory}} {{item.disk}} {{item.cpu}} with_items: "{{browbeat_flavors}}" ignore_errors: true + when: not is_rhoso_deployment + +- name: Add flavors to overcloud + shell: | + export OS_CLOUD=default + openstack flavor create --ram {{ item.memory }} --disk {{ item.disk }} --vcpus {{ item.cpu }} {{ item.name }} + with_items: "{{ browbeat_flavors }}" + ignore_errors: true + when: is_rhoso_deployment diff --git a/ansible/install/roles/images/tasks/main.yml b/ansible/install/roles/images/tasks/main.yml index daa33f2af..2cb3b2c42 100644 --- a/ansible/install/roles/images/tasks/main.yml +++ b/ansible/install/roles/images/tasks/main.yml @@ -15,6 +15,17 @@ ignore_errors: true changed_when: false with_items: "{{ browbeat_guest_images }}" + when: not is_rhoso_deployment + +- name: Determine if image exists + shell: | + export OS_CLOUD=default + openstack image list | grep '{{ browbeat_guest_images[item].name }}' + register: image_exists + ignore_errors: true + changed_when: false + with_items: "{{ browbeat_guest_images }}" + when: is_rhoso_deployment - name: Remove image from dictionary of images if image exists set_fact: @@ -31,14 +42,38 @@ when: "browbeat_guest_images[item].convert_to_raw" with_items: "{{ browbeat_guest_images }}" -- name: Upload image into cloud (Newton and Ocata versions) - shell: . {{ overcloudrc }}; openstack image create --public --disk-format={{ browbeat_guest_images[item].type }} --container-format=bare {{ browbeat_guest_images[item].name }} < {{ home_dir }}/{{ browbeat_guest_images[item].name }}.{{ browbeat_guest_images[item].type }} - ignore_errors: true - when: "not browbeat_guest_images[item].convert_to_raw" - with_items: "{{ browbeat_guest_images }}" +- block: + - name: Upload image into cloud (Newton and Ocata versions) + shell: | + . {{ overcloudrc }} + openstack image create --public --disk-format={{ browbeat_guest_images[item].type }} --container-format=bare {{ browbeat_guest_images[item].name }} < {{ home_dir }}/{{ browbeat_guest_images[item].name }}.{{ browbeat_guest_images[item].type }} + ignore_errors: true + when: "not browbeat_guest_images[item].convert_to_raw" + with_items: "{{ browbeat_guest_images }}" -- name: Upload raw image into cloud (Newton and Ocata versions) - shell: . {{ overcloudrc }}; openstack image create --public --disk-format=raw --container-format=bare {{ browbeat_guest_images[item].name }} < {{ home_dir }}/{{ browbeat_guest_images[item].name }}.raw - ignore_errors: true - when: "browbeat_guest_images[item].convert_to_raw" - with_items: "{{ browbeat_guest_images }}" + - name: Upload raw image into cloud (Newton and Ocata versions) + shell: | + . {{ overcloudrc }} + openstack image create --public --disk-format=raw --container-format=bare {{ browbeat_guest_images[item].name }} < {{ home_dir }}/{{ browbeat_guest_images[item].name }}.raw + ignore_errors: true + when: "browbeat_guest_images[item].convert_to_raw" + with_items: "{{ browbeat_guest_images }}" + when: not is_rhoso_deployment + +- block: + - name: Upload image into cloud (Newton and Ocata versions) + shell: | + export OS_CLOUD=default + openstack image create --public --disk-format={{ browbeat_guest_images[item].type }} --container-format=bare {{ browbeat_guest_images[item].name }} < {{ home_dir }}/{{ browbeat_guest_images[item].name }}.{{ browbeat_guest_images[item].type }} + ignore_errors: true + when: "not browbeat_guest_images[item].convert_to_raw" + with_items: "{{ browbeat_guest_images }}" + + - name: Upload raw image into cloud (Newton and Ocata versions) + shell: | + export OS_CLOUD=default + openstack image create --public --disk-format=raw --container-format=bare {{ browbeat_guest_images[item].name }} < {{ home_dir }}/{{ browbeat_guest_images[item].name }}.raw + ignore_errors: true + when: "browbeat_guest_images[item].convert_to_raw" + with_items: "{{ browbeat_guest_images }}" + when: is_rhoso_deployment diff --git a/ansible/install/roles/rally/tasks/main.yml b/ansible/install/roles/rally/tasks/main.yml index 24d501a63..ff6e02a53 100644 --- a/ansible/install/roles/rally/tasks/main.yml +++ b/ansible/install/roles/rally/tasks/main.yml @@ -84,20 +84,20 @@ # 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. -- name: install rally browbeat code - shell: | - source {{ rally_venv }}/bin/activate - pip install . - args: - executable: /bin/bash - chdir: "{{ role_path }}/files/browbeat-rally" - when: rhosp_version is version('13.0', '>=') +- 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: rhosp_version is version('13.0', '>=') + - 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 @@ -138,15 +138,64 @@ when: rally_undercloud_enabled -- name: Setup rally deployment for overcloud - shell: . {{ rally_venv }}/bin/activate; . {{ overcloudrc }}; rally deployment create --fromenv --name overcloud +- 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: 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 verfied for overcloud - fail: - msg: "Failed to verify that your deployment is ready to benchmark" - when: rally_deployment_check_overcloud.rc != 0 + - 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"