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: I74cefdfa885fa26dd7199fd0798527f511bf329d
This commit is contained in:
Dmitriy Rabotyagov 2023-07-12 16:07:09 +02:00
parent 2d0e465fd3
commit 8ae6540d0b
9 changed files with 47 additions and 37 deletions

View File

@ -18,7 +18,7 @@ debug: False
## Cap the maximum number of threads / workers when a user value is unspecified. ## Cap the maximum number of threads / workers when a user value is unspecified.
repo_nginx_threads_max: 16 repo_nginx_threads_max: 16
repo_nginx_threads: "{{ [[ansible_facts['processor_vcpus']|default(2) // 2, 1] | max, repo_nginx_threads_max] | min }}" repo_nginx_threads: "{{ [[ansible_facts['processor_vcpus'] | default(2) // 2, 1] | max, repo_nginx_threads_max] | min }}"
## APT Cache Options ## APT Cache Options
cache_timeout: 600 cache_timeout: 600
@ -53,12 +53,12 @@ repo_server_systemd_mounts: []
# Example using remote shared filesystem to synchronise the repo contents between # Example using remote shared filesystem to synchronise the repo contents between
# several repo servers # several repo servers
#repo_server_systemd_mounts: # repo_server_systemd_mounts:
# - what: "gluster-server:gluster-volume-name" # - what: "gluster-server:gluster-volume-name"
# where: "/var/www/repo" # where: "/var/www/repo"
# type: glusterfs # type: glusterfs
# state: 'started' # state: 'started'
# enabled: true # enabled: true
### ###
### Backend TLS ### Backend TLS
@ -113,6 +113,6 @@ repo_pki_install_certificates:
condition: "{{ repo_user_ssl_ca_cert is defined }}" condition: "{{ repo_user_ssl_ca_cert is defined }}"
# Define user-provided SSL certificates # Define user-provided SSL certificates
#repo_user_ssl_cert: <path to cert on ansible deployment host> # repo_user_ssl_cert: <path to cert on ansible deployment host>
#repo_user_ssl_key: <path to cert on ansible deployment host> # repo_user_ssl_key: <path to cert on ansible deployment host>
#repo_user_ssl_ca_cert: <path to cert on ansible deployment host> # repo_user_ssl_ca_cert: <path to cert on ansible deployment host>

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: reload nginx - name: Reload nginx
service: service:
name: "nginx" name: "nginx"
enabled: yes enabled: yes

View File

@ -18,19 +18,21 @@ galaxy_info:
description: Install package repo server description: Install package repo server
company: Rackspace company: Rackspace
license: Apache2 license: Apache2
min_ansible_version: 2.2 role_name: repo_server
namespace: openstack
min_ansible_version: "2.10"
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- buster - bullseye
- name: Ubuntu - name: Ubuntu
versions: versions:
- bionic
- focal - focal
- jammy
- name: EL - name: EL
versions: versions:
- 8 - "9"
categories: galaxy_tags:
- cloud - cloud
- python - python
- development - development

View File

@ -30,15 +30,18 @@
- always - always
# TODO (jrosser) Remove this task for the Z release # TODO (jrosser) Remove this task for the Z release
- ansible.builtin.include_tasks: repo_sync_cleanup.yml - name: Including repo_sync_cleanup tasks
ansible.builtin.include_tasks: repo_sync_cleanup.yml
tags: tags:
- repo_server-install - repo_server-install
- ansible.builtin.include_tasks: repo_pre_install.yml - name: Including repo_pre_install tasks
ansible.builtin.include_tasks: repo_pre_install.yml
tags: tags:
- repo_server-install - repo_server-install
- ansible.builtin.include_tasks: repo_install.yml - name: Including repo_install tasks
ansible.builtin.include_tasks: repo_install.yml
tags: tags:
- repo_server-install - repo_server-install
@ -62,7 +65,8 @@
tags: tags:
- always - always
- ansible.builtin.include_tasks: repo_post_install.yml - name: Including repo_post_install tasks
ansible.builtin.include_tasks: repo_post_install.yml
tags: tags:
- repo_server-config - repo_server-config
@ -72,7 +76,8 @@
path: "{{ repo_service_home_folder }}/.ssh/authorized_keys" path: "{{ repo_service_home_folder }}/.ssh/authorized_keys"
state: absent state: absent
- ansible.builtin.include_tasks: repo_install_constraints.yml - name: Including repo_install_constraints tasks
ansible.builtin.include_tasks: repo_install_constraints.yml
when: inventory_hostname == groups['repo_all'][0] when: inventory_hostname == groups['repo_all'][0]
tags: repo_server-config tags: repo_server-config

View File

@ -23,8 +23,7 @@
- name: Clean yum metadata when nginx repo is removed - name: Clean yum metadata when nginx repo is removed
command: dnf clean metadata command: dnf clean metadata
args: changed_when: false
warn: no
when: when:
- ansible_facts['pkg_mgr'] == 'dnf' - ansible_facts['pkg_mgr'] == 'dnf'
- _repo_removed is changed - _repo_removed is changed

View File

@ -17,6 +17,7 @@
file: file:
state: directory state: directory
path: "{{ repo_upper_constraints_path }}" path: "{{ repo_upper_constraints_path }}"
mode: "0755"
delegate_to: localhost delegate_to: localhost
# by default the u-c file is retrieved by https # by default the u-c file is retrieved by https
@ -24,12 +25,13 @@
get_url: get_url:
url: "{{ user_requirements_git_url | default('https://releases.openstack.org/constraints/upper/' ~ requirements_git_install_branch | default('master')) }}" url: "{{ user_requirements_git_url | default('https://releases.openstack.org/constraints/upper/' ~ requirements_git_install_branch | default('master')) }}"
dest: "{{ repo_upper_constraints_path }}/{{ 'upper_constraints_' ~ requirements_git_install_branch | default('master') ~ '.txt' }}" dest: "{{ repo_upper_constraints_path }}/{{ 'upper_constraints_' ~ requirements_git_install_branch | default('master') ~ '.txt' }}"
mode: "0644"
when: requirements_git_repo is search('http') when: requirements_git_repo is search('http')
delegate_to: localhost delegate_to: localhost
- name: Retrieve local filesystem upper constraints in CI - name: Retrieve local filesystem upper constraints in CI
command: command:
git --git-dir={{ requirements_git_repo.split('file://')[1] }}/.git show {{ requirements_git_install_branch | default('master') }}:upper-constraints.txt git --git-dir={{ requirements_git_repo.split('file://')[1] }}/.git show {{ requirements_git_install_branch | default('master') }}:upper-constraints.txt
when: requirements_git_repo is search('file://') when: requirements_git_repo is search('file://')
register: _uc_contents_git register: _uc_contents_git
delegate_to: localhost delegate_to: localhost
@ -40,6 +42,7 @@
copy: copy:
content: "{{ _uc_contents_git.stdout }}" content: "{{ _uc_contents_git.stdout }}"
dest: "{{ repo_upper_constraints_path }}/{{ 'upper_constraints_' ~ requirements_git_install_branch | default('master') ~ '.txt' }}" dest: "{{ repo_upper_constraints_path }}/{{ 'upper_constraints_' ~ requirements_git_install_branch | default('master') ~ '.txt' }}"
mode: "0644"
when: requirements_git_repo is search('file://') when: requirements_git_repo is search('file://')
delegate_to: localhost delegate_to: localhost
@ -49,7 +52,7 @@
dest: "{{ repo_service_home_folder }}/repo/constraints/" dest: "{{ repo_service_home_folder }}/repo/constraints/"
owner: "{{ repo_service_user_name }}" owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}" group: "{{ repo_service_group_name }}"
mode: 0644 mode: "0644"
- name: Create a symlink for constraints file - name: Create a symlink for constraints file
file: file:
@ -58,4 +61,4 @@
owner: "{{ repo_service_user_name }}" owner: "{{ repo_service_user_name }}"
group: "{{ repo_service_group_name }}" group: "{{ repo_service_group_name }}"
state: link state: link
mode: 0644 mode: "0644"

View File

@ -23,22 +23,24 @@
file: file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: "{{ item.state | default('absent') }}" state: "{{ item.state | default('absent') }}"
mode: "0644"
with_items: with_items:
- path: "/etc/nginx/sites-enabled/default" - path: "/etc/nginx/sites-enabled/default"
notify: notify:
- reload nginx - Reload nginx
- name: Drop NGINX configuration files - name: Drop NGINX configuration files
template: template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
mode: "0644"
with_items: with_items:
- src: "nginx.conf.j2" - src: "nginx.conf.j2"
dest: "/etc/nginx/nginx.conf" dest: "/etc/nginx/nginx.conf"
- src: "openstack-slushee.vhost.j2" - src: "openstack-slushee.vhost.j2"
dest: "/etc/nginx/sites-available/openstack-slushee.vhost" dest: "/etc/nginx/sites-available/openstack-slushee.vhost"
notify: notify:
- reload nginx - Reload nginx
- name: Enable openstack-slushee site - name: Enable openstack-slushee site
file: file:
@ -46,4 +48,4 @@
dest: "/etc/nginx/sites-enabled/openstack-slushee.vhost" dest: "/etc/nginx/sites-enabled/openstack-slushee.vhost"
state: "link" state: "link"
notify: notify:
- reload nginx - Reload nginx

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: create the system group - name: Create the system group
group: group:
name: "{{ repo_service_group_name }}" name: "{{ repo_service_group_name }}"
state: "present" state: "present"
@ -30,13 +30,13 @@
home: "{{ repo_service_home_folder }}" home: "{{ repo_service_home_folder }}"
# NOTE(jrosser) remove this task in release after Z # NOTE(jrosser) remove this task in release after Z
- name: Test if {{ repo_service_home_folder }}/repo exists - name: Test if {{ repo_service_home_folder }}/repo exists # noqa: name[template]
stat: stat:
path: "{{ repo_service_home_folder }}/repo" path: "{{ repo_service_home_folder }}/repo"
register: _repo_folder_stat register: _repo_folder_stat
# NOTE(jrosser) remove this task in release after Z # NOTE(jrosser) remove this task in release after Z
- name: Test if {{ repo_service_home_folder }} is a mountpoint - name: Test if a path is a mountpoint {{ repo_service_home_folder }}
command: mountpoint -q {{ repo_service_home_folder }}/repo command: mountpoint -q {{ repo_service_home_folder }}/repo
register: _repo_folder_mountpoint register: _repo_folder_mountpoint
failed_when: False failed_when: False
@ -62,14 +62,15 @@
- skip_ansible_lint - skip_ansible_lint
# NOTE(jrosser) remove this task in release after Z # NOTE(jrosser) remove this task in release after Z
- file: - name: Remove folder dir during migration from lsyncd
file:
path: "{{ repo_service_home_folder }}/repo" path: "{{ repo_service_home_folder }}/repo"
state: absent state: absent
when: when:
- _repo_folder_stat.stat.exists - _repo_folder_stat.stat.exists
- _repo_folder_mountpoint.rc != 0 - _repo_folder_mountpoint.rc != 0
notify: notify:
- reload nginx - Reload nginx
- name: Mount any remote volumes - name: Mount any remote volumes
include_role: include_role:
@ -79,7 +80,7 @@
when: repo_server_systemd_mounts | length > 0 when: repo_server_systemd_mounts | length > 0
# NOTE(jrosser) ensure there is no race condition between mounting and using the filesystem # NOTE(jrosser) ensure there is no race condition between mounting and using the filesystem
- name: Wait until {{ repo_service_home_folder }} is a mounted - name: Wait until mount will finish for {{ repo_service_home_folder }}
command: mountpoint -q {{ repo_service_home_folder }}/repo command: mountpoint -q {{ repo_service_home_folder }}/repo
changed_when: false changed_when: false
register: _repo_folder_is_mounted register: _repo_folder_is_mounted

View File

@ -57,5 +57,3 @@
file: file:
path: "{{ repo_service_home_folder }}/.ssh" path: "{{ repo_service_home_folder }}/.ssh"
state: absent state: absent