Fix linters python3.10 issues
Bump the version of ansible-lint and fix all warnings and failures found by ansible-lint. Also remove any python2 related code/tasks from install-packages.yaml Change-Id: If466227fb9872f1112b4577670c891bef5b31627
This commit is contained in:
parent
9d585d1f7e
commit
3a3fb4f48b
@ -3,7 +3,11 @@ parseable: true
|
||||
skip_list:
|
||||
# Add skips here only as last resort, like:
|
||||
# https://github.com/ansible/ansible-lint/issues/557
|
||||
- 302 # [E302] mkdir used in place of argument state=directory to file module
|
||||
- 303 # [E303] ... used in place of ... module
|
||||
- 208 # [E208]
|
||||
- 106 # [E106]
|
||||
- '302' # [E302] mkdir used in place of argument state=directory to file module
|
||||
- '303' # [E303] ... used in place of ... module
|
||||
- '208' # [E208]
|
||||
- '106' # [E106]
|
||||
- 'no-changed-when'
|
||||
- 'name[missing]'
|
||||
- 'name[template]'
|
||||
- 'jinja[spacing]'
|
||||
|
@ -21,7 +21,7 @@ repos:
|
||||
types: [file, yaml]
|
||||
entry: yamllint --strict -f parsable
|
||||
- repo: https://github.com/ansible/ansible-lint.git
|
||||
rev: v5.3.2
|
||||
rev: v6.16.0
|
||||
hooks:
|
||||
- id: ansible-lint
|
||||
always_run: true
|
||||
@ -29,7 +29,7 @@ repos:
|
||||
# results when called with individual files.
|
||||
# https://github.com/ansible/ansible-lint/issues/611
|
||||
verbose: true
|
||||
entry: env ANSIBLE_LIBRARY=./library ansible-lint --force-color -v .
|
||||
entry: env ANSIBLE_LIBRARY=./library ansible-lint --force-color -v tasks/
|
||||
- repo: https://github.com/openstack-dev/bashate.git
|
||||
rev: 0.6.0
|
||||
hooks:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Generate tempest_admin.conf as admin
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
set -ex
|
||||
source .venv/bin/activate
|
||||
source {{ source_admin_credentials }}
|
||||
@ -16,7 +16,7 @@
|
||||
when: additional_tempestconf_params is not defined
|
||||
|
||||
- name: Generate tempest_admin.conf as admin additional params
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
set -ex
|
||||
source .venv/bin/activate
|
||||
source {{ source_admin_credentials }}
|
||||
@ -33,7 +33,7 @@
|
||||
when: additional_tempestconf_params is defined
|
||||
|
||||
- name: Cat generated tempest_admin.conf file
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
cat ./etc/tempest_admin.conf
|
||||
args:
|
||||
executable: /bin/bash
|
||||
@ -41,11 +41,11 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Set path to tempest_admin.conf
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
path_to_admin_tempest_config: "{{ refstack_client_source }}/etc/tempest_admin.conf"
|
||||
|
||||
- name: Generate tempest accounts.yaml file
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
set -ex
|
||||
export PATH=$PATH:/usr/local/sbin:/usr/sbin
|
||||
source .tempest/.venv/bin/activate
|
||||
@ -62,7 +62,7 @@
|
||||
changed_when: accounts_path is not defined
|
||||
|
||||
- name: Cat generated accounts.yaml file
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
cat ./etc/accounts.yaml
|
||||
args:
|
||||
executable: /bin/bash
|
||||
@ -70,5 +70,5 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Set path to newly generated accounts.yaml
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
path_to_accounts_file: "{{ refstack_client_source }}/etc/accounts.yaml"
|
||||
|
@ -2,12 +2,12 @@
|
||||
- when: "'shared_file_system' in refstack_target_programs"
|
||||
block:
|
||||
- name: Copy python script for parsing tempest.conf
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: parse_ini_get_tempestconf_overrides.py
|
||||
dest: "{{ refstack_client_source }}/parse_ini_get_tempestconf_overrides.py"
|
||||
|
||||
- name: Parse share config from tempest_admin.conf
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
python3 ./parse_ini_get_tempestconf_overrides.py \
|
||||
backend_names,enable_protocols,multitenancy_enabled \
|
||||
share \
|
||||
@ -17,17 +17,17 @@
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
|
||||
- name: Form share overrides for tempestconf
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
share_tempestconf_overrides: "{{ share_tempestconf_overrides.stdout_lines }}"
|
||||
|
||||
- name: Generate tempest configuration script
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: generate-tempestconf.sh.j2
|
||||
dest: "{{ refstack_client_source }}/generate-tempestconf.sh"
|
||||
mode: 0744
|
||||
|
||||
- name: Generate tempest configuration file
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
./generate-tempestconf.sh
|
||||
args:
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
@ -35,7 +35,7 @@
|
||||
changed_when: tempest_config_path is not defined
|
||||
|
||||
- name: Cat generated tempest.conf file
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
cat ./etc/tempest.conf
|
||||
args:
|
||||
executable: /bin/bash
|
||||
@ -43,5 +43,5 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Set path to newly generated tempest.conf
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
path_to_tempest_config: "{{ refstack_client_source }}/etc/tempest.conf"
|
||||
|
@ -1,64 +1,23 @@
|
||||
---
|
||||
- name: Is python3 available
|
||||
command: "python3 --version"
|
||||
ansible.builtin.command: "python3 --version"
|
||||
ignore_errors: true
|
||||
register: python3_is_available
|
||||
changed_when: false
|
||||
|
||||
- name: Is python2 available
|
||||
command: "python2 --version"
|
||||
ignore_errors: true
|
||||
changed_when: false
|
||||
when: python3_is_available.failed
|
||||
|
||||
- name: Install git
|
||||
become: true
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
name: git
|
||||
|
||||
- name: Install virtualenv (py3)
|
||||
become: true
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
name: python3-virtualenv
|
||||
when: not python3_is_available.failed
|
||||
|
||||
- name: Install virtualenv (py2)
|
||||
become: true
|
||||
package:
|
||||
name: python-virtualenv
|
||||
when: python3_is_available.failed
|
||||
|
||||
- name: Check if pip is already installed
|
||||
command: "pip --version"
|
||||
ansible.builtin.command: "pip --version"
|
||||
ignore_errors: true
|
||||
register: pip_is_installed
|
||||
when: python3_is_available.failed
|
||||
|
||||
# pip3 is a dependency of a python3 package, so if there is a python3
|
||||
# installed, pip3 should be installed already as well
|
||||
- when:
|
||||
- python3_is_available.failed
|
||||
- pip_is_installed.rc != 0
|
||||
block:
|
||||
- name: get python version
|
||||
command: "python --version"
|
||||
register: python_version
|
||||
|
||||
- name: Print python version
|
||||
debug:
|
||||
var: python_version
|
||||
|
||||
- name: download get-pip.py for python 2.7
|
||||
get_url: url=https://bootstrap.pypa.io/pip/2.7/get-pip.py dest=/tmp
|
||||
when: '"2.7" in python_version.stderr'
|
||||
|
||||
- name: download get-pip.py for ptython 2.6
|
||||
get_url: url=https://bootstrap.pypa.io/pip/2.6/get-pip.py dest=/tmp
|
||||
when: '"2.6" in python_version.stderr'
|
||||
|
||||
- name: install pip
|
||||
become: true
|
||||
command: "python /tmp/get-pip.py"
|
||||
|
||||
- name: delete get-pip.py
|
||||
file: state=absent path=/tmp/get-pip.py
|
||||
|
@ -1,33 +1,33 @@
|
||||
---
|
||||
- name: Check if refstack_client_source dir exists and if it's empty
|
||||
find:
|
||||
ansible.builtin.find:
|
||||
paths: "{{ refstack_client_source }}"
|
||||
register: local_refstack_found
|
||||
|
||||
- name: Print refstack_client_source variable
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: refstack_client_source
|
||||
|
||||
- name: Clone refstack-client
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: 'https://opendev.org/openinfra/refstack-client.git'
|
||||
dest: "{{ refstack_client_source }}"
|
||||
version: "{{ refstack_client_version }}"
|
||||
when: local_refstack_found.matched == 0
|
||||
|
||||
- name: Look for python3
|
||||
command: "python3 --version"
|
||||
ansible.builtin.command: "python3 --version"
|
||||
ignore_errors: true
|
||||
register: python3_is_available
|
||||
changed_when: false
|
||||
|
||||
- name: Set python3 params for setup_env
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
python3_param: "-p 3"
|
||||
when: python3_is_available.rc == 0
|
||||
|
||||
- name: Clone py2 python-tempestconf
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: 'https://git.openstack.org/openinfra/python-tempestconf.git'
|
||||
dest: "{{ refstack_client_source }}/.tempestconf_source"
|
||||
version: "2.5.0"
|
||||
@ -45,19 +45,19 @@
|
||||
# refstack_tempest_plugins: ===> refstack_tempest_plugins:
|
||||
# <tempest_plugin_name>:<tag/branch> ===> manila:1.3.0
|
||||
- name: Add additional requirements for external test suites
|
||||
replace:
|
||||
ansible.builtin.replace:
|
||||
path: "{{ refstack_client_source }}/setup_env"
|
||||
regexp: '#(.*tempest-additional-requirements.txt$)'
|
||||
replace: '\1'
|
||||
|
||||
- name: Add tempest plugins to tempest-additional-requirements.txt
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ refstack_client_source }}/tempest-additional-requirements.txt"
|
||||
line: "git+https://opendev.org/openstack/{{ item.key }}-tempest-plugin.git@{{ item.value }}"
|
||||
with_dict: "{{ refstack_tempest_plugins }}"
|
||||
|
||||
- name: Install refstack-client
|
||||
shell: >
|
||||
ansible.builtin.shell: >
|
||||
./setup_env {{ python3_param | default('') }}
|
||||
{% if tempest_tag is defined %}
|
||||
-t {{ tempest_tag }}
|
||||
|
@ -1,36 +1,36 @@
|
||||
---
|
||||
- name: Install required packages
|
||||
include: install-packages.yaml
|
||||
ansible.builtin.include_tasks: install-packages.yaml
|
||||
|
||||
- include_tasks: install-refstack-client.yaml
|
||||
- ansible.builtin.include_tasks: install-refstack-client.yaml
|
||||
|
||||
- name: Generate accounts.yaml file
|
||||
include: generate-accounts.yaml
|
||||
ansible.builtin.include_tasks: generate-accounts.yaml
|
||||
when: accounts_path is not defined
|
||||
|
||||
- name: Set path to provided accounts.yaml
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
path_to_accounts_file: "{{ accounts_path }}"
|
||||
when: accounts_path is defined
|
||||
|
||||
- name: Generate tempest.conf file
|
||||
include: generate-tempestconf.yaml
|
||||
ansible.builtin.include_tasks: generate-tempestconf.yaml
|
||||
when: tempest_config_path is not defined
|
||||
|
||||
- name: Set path to provided tempest.conf
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
path_to_tempest_config: "{{ tempest_config_path }}"
|
||||
when: tempest_config_path is defined
|
||||
|
||||
- include_tasks: run-refstack-client.yaml
|
||||
- ansible.builtin.include_tasks: run-refstack-client.yaml
|
||||
|
||||
- include_tasks: post-tasks.yaml
|
||||
- ansible.builtin.include_tasks: post-tasks.yaml
|
||||
when: upload_results | bool or download_artifacts | bool
|
||||
|
||||
- when: test_list is defined
|
||||
block:
|
||||
- name: Check if we passed refstack tests
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Refstack tests failed."
|
||||
# the refstack_result var got set in run-refstack-client.yaml
|
||||
when: refstack_result.rc > 0
|
||||
@ -38,7 +38,7 @@
|
||||
- when: test_list is not defined
|
||||
block:
|
||||
- name: Check if we passed tests of all specified target programs
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Refstack tests failed."
|
||||
# the refstack_results var got set in run-refstack-client.yaml
|
||||
when: item.rc > 0
|
||||
|
@ -2,7 +2,7 @@
|
||||
# The task finds the latest result file in case there are more of them
|
||||
# e.g. refstack-client was already executed in the current env
|
||||
- name: Find the test result json file
|
||||
find:
|
||||
ansible.builtin.find:
|
||||
path: "{{ refstack_client_source }}/.tempest/.stestr"
|
||||
patterns: '*.json'
|
||||
register: ls_out
|
||||
@ -16,7 +16,7 @@
|
||||
- name: Copy private key
|
||||
block:
|
||||
- name: Copy private key from local machine
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "{{ private_key_path_src }}"
|
||||
dest: "{{ private_key_path }}"
|
||||
mode: '0600'
|
||||
@ -25,7 +25,7 @@
|
||||
- private_key_path_src is defined
|
||||
rescue:
|
||||
- name: Copy private key from remote machine
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ private_key_path_src }}"
|
||||
dest: "{{ private_key_path }}"
|
||||
mode: '0600'
|
||||
@ -34,7 +34,7 @@
|
||||
- private_key_path_src is defined
|
||||
|
||||
- name: Upload results with signature
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
set -ex
|
||||
source .venv/bin/activate
|
||||
refstack-client upload -y "{{ ls_out.files[-(item[0] | int + 1) | int].path }}" \
|
||||
@ -49,7 +49,7 @@
|
||||
- private_key_path is defined
|
||||
|
||||
- name: Print output of the upload command
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ upload_out }}"
|
||||
|
||||
# this becomes handy when the role is executed on a remote node from
|
||||
@ -58,21 +58,21 @@
|
||||
- when: download_artifacts | bool
|
||||
block:
|
||||
- name: Download results file in .json
|
||||
fetch:
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ ls_out.files[-(item[0] | int + 1) | int].path }}"
|
||||
dest: "{{ dest_dir }}/test_results{{ (item[0] | int + 1) | int }}.json"
|
||||
flat: true
|
||||
with_indexed_items: "{{ refstack_target_programs }}"
|
||||
|
||||
- name: Download results file in subunit
|
||||
fetch:
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ ls_out.files[-(item[0] | int + 1) | int].path | splitext | first }}"
|
||||
dest: "{{ dest_dir }}/test_results_subunit {{ (item[0] | int + 1) | int }}"
|
||||
flat: true
|
||||
with_indexed_items: "{{ refstack_target_programs }}"
|
||||
|
||||
- name: Dump output of upload command
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ upload_out }}"
|
||||
dest: "{{ dest_dir }}/upload_output.txt"
|
||||
mode: '0644'
|
||||
@ -80,19 +80,19 @@
|
||||
when: upload_results | bool
|
||||
|
||||
- name: Download tempest_admin.conf file
|
||||
fetch:
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ path_to_admin_tempest_config }}"
|
||||
dest: "{{ dest_dir }}/tempest_admin.conf"
|
||||
flat: true
|
||||
|
||||
- name: Download tempest.conf file
|
||||
fetch:
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ path_to_tempest_config }}"
|
||||
dest: "{{ dest_dir }}/tempest.conf"
|
||||
flat: true
|
||||
|
||||
- name: Download accounts.yaml file
|
||||
fetch:
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ path_to_accounts_file }}"
|
||||
dest: "{{ dest_dir }}/accounts.yaml"
|
||||
flat: true
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Validate setup
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
set -ex
|
||||
source .venv/bin/activate
|
||||
refstack-client test -c {{ path_to_tempest_config }} \
|
||||
@ -13,7 +13,7 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Run tests with the defined test list
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
set -ex
|
||||
export PATH=$PATH:/usr/local/sbin:/usr/sbin
|
||||
source .venv/bin/activate
|
||||
@ -33,7 +33,7 @@
|
||||
when: test_list is defined
|
||||
|
||||
- name: "Run {{ refstack_target_programs }} program tests associated within the {{ guideline }} guideline"
|
||||
shell: "set -ex;
|
||||
ansible.builtin.shell: "set -ex;
|
||||
export PATH=$PATH:/usr/local/sbin:/usr/sbin;
|
||||
source .venv/bin/activate;
|
||||
printenv;
|
||||
|
Loading…
Reference in New Issue
Block a user