Fix linters and metadata

With update of ansible-lint to version >=6.0.0 a lot of new
linters were added, that enabled by default. In order to comply
with linter rules we're applying changes to the role.

With that we also update metdata to reflect current state.

Change-Id: I6b4b83ec472d4a3de9139eb4e7c7b2dc8a9fc260
This commit is contained in:
Dmitriy Rabotyagov 2023-07-12 12:56:25 +02:00 committed by Dmitriy Rabotyagov
parent 0e1abb2858
commit 43032d25cf
9 changed files with 53 additions and 17 deletions

View File

@ -83,7 +83,7 @@ venv_pip_build_env: {}
venv_default_pip_install_args: >-
{%- if (groups[venv_build_group] is defined) and (groups[venv_build_group] | length > 0) and (venv_wheel_build_enable | bool) %}
--find-links {{ openstack_repo_url | default('http://localhost') }}/os-releases/{{ openstack_release | default('master') }}/{{ _venv_build_dist_arch }}/wheels
--trusted-host {{ (openstack_repo_url | default('http://localhost')) | urlsplit('hostname') }}
--trusted-host {{ (openstack_repo_url | default('http://localhost')) | urlsplit('hostname') -}}
{%- endif %}
# Arguments to pass to pip when installing into the venv

View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: venv changed
- name: Virtual Environment changed
meta: noop
when: false
listen:
- venv changed

View File

@ -18,19 +18,21 @@ galaxy_info:
description: Python venv preparation
company: OpenStack
license: Apache2
min_ansible_version: 2.4
role_name: python_venv_build
namespace: openstack
min_ansible_version: "2.10"
platforms:
- name: Debian
versions:
- buster
- bullseye
- name: Ubuntu
versions:
- bionic
- focal
- jammy
- name: EL
versions:
- 8
categories:
- "9"
galaxy_tags:
- cloud
- python
- development

View File

@ -28,7 +28,7 @@
tags:
- always
- name: gather build target facts
- name: Gather build target facts
setup:
gather_subset: '!all:min'
delegate_to: "{{ item }}"
@ -73,7 +73,8 @@
- venv_wheel_build_enable | bool
- _venv_build_dist_arch not in venv_build_targets
- include_tasks: "python_venv_wheel_build.yml"
- name: Including python_venv_wheel_build tasks
include_tasks: "python_venv_wheel_build.yml"
args:
apply:
tags:
@ -84,11 +85,13 @@
tags:
- always
- import_tasks: "python_venv_install.yml"
- name: Including python_venv_install tasks
import_tasks: "python_venv_install.yml"
tags:
- install
- include_tasks: "python_venv_set_facts.yml"
- name: Including python_venv_set_facts tasks
include_tasks: "python_venv_set_facts.yml"
args:
apply:
tags:

View File

@ -28,7 +28,18 @@
- name: Install distro packages for venv build
package:
name: "{{ (venv_wheel_build_enable | bool) | ternary(venv_install_base_distro_package_list | union(venv_install_distro_package_list), (venv_build_base_distro_package_list | union(venv_build_distro_package_list) | union(venv_install_base_distro_package_list) | union(venv_install_distro_package_list))) }}"
name: >-
{{
(venv_wheel_build_enable | bool) | ternary(
venv_install_base_distro_package_list | union(venv_install_distro_package_list),
(
venv_build_base_distro_package_list |
union(venv_build_distro_package_list) |
union(venv_install_base_distro_package_list) |
union(venv_install_distro_package_list)
)
)
}}
state: "{{ venv_distro_package_state }}"
update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(venv_distro_cache_valid_time, omit) }}"
@ -51,6 +62,7 @@
file:
path: "{{ venv_install_destination_path }}"
state: directory
mode: "0755"
# Note(jrosser)
# If the constraints file from the wheel build has been previously collected
@ -84,6 +96,7 @@
copy:
dest: "{{ item.dest }}"
content: "{{ item.content }}"
mode: "0644"
with_items:
- dest: "{{ venv_install_destination_path }}/requirements.txt"
content: |-

View File

@ -25,7 +25,12 @@
vars:
_venv_python_major_version: "{{ (_python_venv_details.files[0].path | basename | split('.') )[0] }}"
shell: >-
{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('dpkg -L ' ~ (venv_packages_to_symlink | join(' ')), 'rpm -ql ' ~ (venv_packages_to_symlink | join(' ')) ) }}
{{
(ansible_facts['pkg_mgr'] == 'apt') | ternary(
'dpkg -L ' ~ (venv_packages_to_symlink | join(' ')),
'rpm -ql ' ~ (venv_packages_to_symlink | join(' '))
)
}}
| egrep '^.*{{ _venv_python_major_version }}.*/(site|dist)-packages/.*'
| egrep -v "__pycache__"
changed_when: false

View File

@ -18,6 +18,7 @@
file:
path: /etc/ansible/facts.d
state: directory
mode: "0755"
- name: Record the necessary facts
become: true
@ -26,6 +27,7 @@
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value | string }}"
mode: "0644"
with_items: "{{ venv_facts_when_changed }}"
when:
- (_install_venv_pip_packages is defined and

View File

@ -50,6 +50,7 @@
state: directory
owner: "{{ venv_build_host_user_name | default(omit) }}"
group: "{{ venv_build_host_group_name | default(omit) }}"
mode: "0755"
with_items:
- "{{ venv_build_host_wheel_path }}"
- "{{ venv_build_host_requirements_path }}"
@ -61,6 +62,7 @@
content: "{{ item.content }}"
owner: "{{ venv_build_host_user_name | default(omit) }}"
group: "{{ venv_build_host_group_name | default(omit) }}"
mode: "0644"
with_items:
- dest: "{{ _venv_build_requirements_prefix }}-requirements.txt"
content: |-
@ -111,7 +113,7 @@
path: "/tmp/{{ venv_install_destination_path | basename }}"
state: absent
- name: Build wheels for the packages to be installed into the venv
- name: Build wheels for the packages to be installed into the venv # noqa: no-changed-when
command: >-
{{ venv_build_host_venv_path }}/bin/pip wheel
--requirement {{ _venv_build_requirements_prefix }}-requirements.txt
@ -147,6 +149,7 @@
- name: Move built wheels to common wheel path
shell: >-
mv /tmp/{{ venv_install_destination_path | basename }}/* {{ venv_build_host_wheel_path }}/
changed_when: false
args:
executable: /bin/bash
@ -160,3 +163,4 @@
dest: "{{ _venv_build_requirements_prefix }}-constraints.txt"
owner: "{{ venv_build_host_user_name | default(omit) }}"
group: "{{ venv_build_host_group_name | default(omit) }}"
mode: "0644"

View File

@ -55,7 +55,7 @@ venv_build_targets: |-
{% endfor %}
{{ targets }}
_venv_wheels_play_hosts: |
_venv_wheels_play_hosts: |-
{% set wheel_groups = {} %}
{% for host in ansible_play_hosts %}
{% set arch = hostvars[host]['ansible_facts']['architecture'] %}
@ -70,7 +70,7 @@ _venv_wheels_play_hosts: |
{% endfor %}
{{ wheel_groups }}
_venv_wheels_first_play_hosts: |
_venv_wheels_first_play_hosts: |-
{% set first_hosts = [] %}
{% for distro_arch_hosts in _venv_wheels_play_hosts.values() %}
{% set _ = first_hosts.append(distro_arch_hosts | first) %}
@ -79,6 +79,11 @@ _venv_wheels_first_play_hosts: |
_venv_pip_packages: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort | select | list }}"
_venv_build_dist_arch: "{{ (ansible_facts['distribution'] | lower) | replace(' ', '_') }}-{{ ansible_facts['distribution_version'].split('.')[:2] | join('.') }}-{{ ansible_facts['architecture'] | lower }}"
_venv_build_dist_arch: >-
{{
((ansible_facts['distribution'] | lower) | replace(' ', '_')) ~ '-' ~
(ansible_facts['distribution_version'].split('.')[:2] | join('.')) ~ '-' ~
(ansible_facts['architecture'] | lower)
}}
_venv_build_requirements_prefix: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}"