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:
|
vars:
|
||||||
devstack_localrc:
|
devstack_localrc:
|
||||||
USE_PYTHON3: true
|
USE_PYTHON3: true
|
||||||
|
run_validation: true
|
||||||
irrelevant-files:
|
irrelevant-files:
|
||||||
- ^.*\.rst$
|
- ^.*\.rst$
|
||||||
- ^doc/.*$
|
- ^doc/.*$
|
||||||
|
@ -20,6 +20,6 @@
|
|||||||
group: false
|
group: false
|
||||||
loop:
|
loop:
|
||||||
- dest: "{{ log_path }}/validations-logs"
|
- dest: "{{ log_path }}/validations-logs"
|
||||||
src: "logs"
|
src: "artifacts"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vf_output
|
loop_var: vf_output
|
||||||
|
@ -1,30 +1,18 @@
|
|||||||
---
|
---
|
||||||
log_dir: "{{ ansible_user_dir }}/logs"
|
user_dir: "{{ ansible_env.HOME | default('') }}"
|
||||||
zuul_work_virtualenv: "{{ ansible_user_dir }}/.venv"
|
val_working_dir: "{{ ansible_env.HOME | default('') }}"
|
||||||
ansible_dir: "{{ zuul_work_virtualenv }}/share/ansible/"
|
zuul_work_virtualenv: "{{ user_dir }}/.venv"
|
||||||
validation_dir: "{{ zuul_work_virtualenv }}/share/ansible/validation-playbooks"
|
vf_log_dir: "{{ ansible_user_dir }}/logs"
|
||||||
vf_log_dir: "/var/log/validations"
|
ansible_dir: ""
|
||||||
val_exec: "source {{ zuul_work_virtualenv }}/bin/activate; validation"
|
|
||||||
command:
|
inventory: "localhost"
|
||||||
- output: "{{ log_dir }}/run.log"
|
component: "{{ job.component|default('validation') }}"
|
||||||
action: "run"
|
# both commands can be used:
|
||||||
command: >-
|
# "openstack tripleo validator" or "validation"
|
||||||
{{ val_exec }} run --validation check-ftype,512e
|
# the default is validation because this is the 1st entry available on
|
||||||
--validation-dir {{ validation_dir }}
|
# a system for validation.
|
||||||
--ansible-base-dir {{ ansible_dir }}
|
# The openstack command needs to install python-tripleoclient and its
|
||||||
--output-log {{ log_dir }}/run.log
|
# dependencies first. This value should be override as needed in the roles/vars
|
||||||
- output: "{{ log_dir }}/run-group.log"
|
# calls.
|
||||||
action: "run"
|
command: "validation"
|
||||||
command: >-
|
run_validation: true
|
||||||
{{ 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
|
|
||||||
|
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 }}"
|
group: "{{ ansible_user }}"
|
||||||
recurse: true
|
recurse: true
|
||||||
|
|
||||||
# @matbu: TODO make the /var/log/validations as a parameter
|
- name: check if virtualenv is used
|
||||||
# We should be able to write validation logs outside of the /var/log path
|
register: is_virtualenv
|
||||||
# This statement will have to be remove then.
|
stat:
|
||||||
- name: Create Validations log symlink
|
path: "{{ zuul_work_virtualenv }}"
|
||||||
file:
|
|
||||||
src: "{{ vf_log_dir }}"
|
|
||||||
dest: "{{ log_dir }}"
|
|
||||||
owner: "{{ ansible_user }}"
|
|
||||||
group: "{{ ansible_user }}"
|
|
||||||
state: link
|
|
||||||
|
|
||||||
# @matbu: TODO make ansible-runner depends on Ansible
|
- name: Set commmand if virtualenv exists
|
||||||
- name: Install Ansible
|
set_fact:
|
||||||
pip:
|
validation_command: "source {{ zuul_work_virtualenv }}/bin/activate; validation"
|
||||||
name: ansible
|
when: is_virtualenv.stat.exists
|
||||||
virtualenv: "{{ zuul_work_virtualenv }}"
|
|
||||||
|
|
||||||
- include: validations.yaml validation_command="{{ item.command }}" val_output="{{ item.output }}" action="{{ item.action }}"
|
- name: Set Validation directory if virtualenv exists
|
||||||
loop: "{{command}}"
|
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