Merge "Update validations role to be used by tripleo CI and devstack tests"
This commit is contained in:
commit
54093ee5cb
@ -11,6 +11,7 @@
|
||||
vars:
|
||||
devstack_localrc:
|
||||
USE_PYTHON3: true
|
||||
run_validation: true
|
||||
irrelevant-files:
|
||||
- ^.*\.rst$
|
||||
- ^doc/.*$
|
||||
|
@ -20,6 +20,6 @@
|
||||
group: false
|
||||
loop:
|
||||
- dest: "{{ log_path }}/validations-logs"
|
||||
src: "logs"
|
||||
src: "artifacts"
|
||||
loop_control:
|
||||
loop_var: vf_output
|
||||
|
@ -1,30 +1,18 @@
|
||||
---
|
||||
log_dir: "{{ ansible_user_dir }}/logs"
|
||||
zuul_work_virtualenv: "{{ ansible_user_dir }}/.venv"
|
||||
ansible_dir: "{{ zuul_work_virtualenv }}/share/ansible/"
|
||||
validation_dir: "{{ zuul_work_virtualenv }}/share/ansible/validation-playbooks"
|
||||
vf_log_dir: "/var/log/validations"
|
||||
val_exec: "source {{ zuul_work_virtualenv }}/bin/activate; validation"
|
||||
command:
|
||||
- output: "{{ log_dir }}/run.log"
|
||||
action: "run"
|
||||
command: >-
|
||||
{{ val_exec }} run --validation check-ftype,512e
|
||||
--validation-dir {{ validation_dir }}
|
||||
--ansible-base-dir {{ ansible_dir }}
|
||||
--output-log {{ log_dir }}/run.log
|
||||
- output: "{{ log_dir }}/run-group.log"
|
||||
action: "run"
|
||||
command: >-
|
||||
{{ val_exec }} run --group prep --validation-dir {{ validation_dir }}
|
||||
--ansible-base-dir {{ ansible_dir }}
|
||||
--output-log {{ log_dir }}/run-group.log
|
||||
--extra-vars minimal_ram_gb=7
|
||||
- output: "{{ log_dir }}/list.log"
|
||||
action: "list"
|
||||
command: >-
|
||||
{{ val_exec }} list --validation-dir {{ validation_dir }} -f json > {{ log_dir }}/list.log 2>&1
|
||||
- output: "{{ log_dir }}/show.log"
|
||||
action: "show"
|
||||
command: >-
|
||||
{{ val_exec }} show --validation-dir {{ validation_dir }} check-ram -f json > {{ log_dir }}/show.log 2>&1
|
||||
user_dir: "{{ ansible_env.HOME | default('') }}"
|
||||
val_working_dir: "{{ ansible_env.HOME | default('') }}"
|
||||
zuul_work_virtualenv: "{{ user_dir }}/.venv"
|
||||
vf_log_dir: "{{ ansible_user_dir }}/logs"
|
||||
ansible_dir: ""
|
||||
|
||||
inventory: "localhost"
|
||||
component: "{{ job.component|default('validation') }}"
|
||||
# both commands can be used:
|
||||
# "openstack tripleo validator" or "validation"
|
||||
# the default is validation because this is the 1st entry available on
|
||||
# a system for validation.
|
||||
# The openstack command needs to install python-tripleoclient and its
|
||||
# dependencies first. This value should be override as needed in the roles/vars
|
||||
# calls.
|
||||
command: "validation"
|
||||
run_validation: true
|
||||
|
6
roles/validations/tasks/list.yaml
Normal file
6
roles/validations/tasks/list.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: List Validation
|
||||
register: list_output
|
||||
shell:
|
||||
cmd: "{{ validation_command }} list {{ validation_dir }} -f json > {{ val_working_dir }}/list.log 2>&1"
|
||||
executable: /bin/bash
|
@ -9,22 +9,46 @@
|
||||
group: "{{ ansible_user }}"
|
||||
recurse: true
|
||||
|
||||
# @matbu: TODO make the /var/log/validations as a parameter
|
||||
# We should be able to write validation logs outside of the /var/log path
|
||||
# This statement will have to be remove then.
|
||||
- name: Create Validations log symlink
|
||||
file:
|
||||
src: "{{ vf_log_dir }}"
|
||||
dest: "{{ log_dir }}"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
state: link
|
||||
- name: check if virtualenv is used
|
||||
register: is_virtualenv
|
||||
stat:
|
||||
path: "{{ zuul_work_virtualenv }}"
|
||||
|
||||
# @matbu: TODO make ansible-runner depends on Ansible
|
||||
- name: Install Ansible
|
||||
pip:
|
||||
name: ansible
|
||||
virtualenv: "{{ zuul_work_virtualenv }}"
|
||||
- name: Set commmand if virtualenv exists
|
||||
set_fact:
|
||||
validation_command: "source {{ zuul_work_virtualenv }}/bin/activate; validation"
|
||||
when: is_virtualenv.stat.exists
|
||||
|
||||
- include: validations.yaml validation_command="{{ item.command }}" val_output="{{ item.output }}" action="{{ item.action }}"
|
||||
loop: "{{command}}"
|
||||
- name: Set Validation directory if virtualenv exists
|
||||
set_fact:
|
||||
validation_dir: "--validation-dir {{ zuul_work_virtualenv }}/share/ansible/validation-playbooks"
|
||||
when: is_virtualenv.stat.exists
|
||||
|
||||
- name: Set Ansible base directory if virtualenv exists
|
||||
set_fact:
|
||||
ansible_dir: "--ansible-base-dir {{ zuul_work_virtualenv }}/share/ansible/"
|
||||
when: is_virtualenv.stat.exists
|
||||
|
||||
- name: Set commmand without virtualenv
|
||||
set_fact:
|
||||
validation_command: "validation"
|
||||
when: not is_virtualenv.stat.exists
|
||||
|
||||
- name: Set validation dir without virtualenv
|
||||
set_fact:
|
||||
validation_dir: "--validation-dir /usr/share/ansible/validation-playbooks"
|
||||
when: not is_virtualenv.stat.exists
|
||||
|
||||
- include: run.yaml name="{{ item }}"
|
||||
when:
|
||||
- run_validation|default(false)|bool
|
||||
- component | length > 0
|
||||
with_dict: "{{ validations_list[component] }}"
|
||||
|
||||
- include: list.yaml
|
||||
|
||||
- include: show.yaml name="{{ item }}"
|
||||
when:
|
||||
- run_validation|default(false)|bool
|
||||
- component | length > 0
|
||||
with_dict: "{{ validations_list[component] }}"
|
||||
|
31
roles/validations/tasks/run.yaml
Normal file
31
roles/validations/tasks/run.yaml
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
- name: Run validations
|
||||
register: run_validation
|
||||
shell:
|
||||
cmd: "{{ validation_command }} run --validation {{ name.key }} {{ validation_dir }} {{ ansible_dir }} \
|
||||
--inventory {{ inventory }} --output-log validation_{{ name.key }}.log {{ name.value.extra_args }}"
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Get Run results
|
||||
block:
|
||||
- name: Get run results
|
||||
register: result
|
||||
shell:
|
||||
cmd: "cat validation_{{ name.key }}.log"
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Get json data
|
||||
set_fact:
|
||||
jsondata: "{{ result.stdout | from_json }}"
|
||||
|
||||
- name: Get Validations Status
|
||||
set_fact:
|
||||
status: "{{ jsondata | json_query(jsonres) }}"
|
||||
vars:
|
||||
jsonres: 'results[*].Status'
|
||||
|
||||
- fail:
|
||||
msg: "Validation failed: some of the validations has failed."
|
||||
when:
|
||||
- item != "PASSED"
|
||||
loop: "{{ status }}"
|
6
roles/validations/tasks/show.yaml
Normal file
6
roles/validations/tasks/show.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Show Validation
|
||||
register: show_output
|
||||
shell:
|
||||
cmd: "{{ validation_command }} show {{ validation_dir }} --validation {{ name.key }} -f json > {{ val_working_dir }}/show.log 2>&1"
|
||||
executable: /bin/bash
|
23
roles/validations/vars/main.yaml
Normal file
23
roles/validations/vars/main.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
validations_list:
|
||||
compute:
|
||||
- nova-status:
|
||||
extra_args: ""
|
||||
network:
|
||||
- undercloud-neutron-sanity-check:
|
||||
extra_args: ""
|
||||
validation:
|
||||
- check-cpu:
|
||||
extra_args: "--extra-vars minimal_cpu_count=2"
|
||||
- 512e:
|
||||
extra_args: ""
|
||||
- check-ram:
|
||||
extra_args: "--extra-vars minimal_ram_gb=2"
|
||||
tripleo:
|
||||
- undercloud-process-count:
|
||||
extra_args: ""
|
||||
validations_group:
|
||||
compute:
|
||||
- compute
|
||||
network:
|
||||
- network
|
Loading…
x
Reference in New Issue
Block a user