[Ussuri-only] Bumping the ansible-lint version to 5.3.2 in order to resolve CI failure

Remove RoleNames ansible-lint custom rule

As this rule has been merged upstream, we don't need it anymore locally.

This patch also bumps the ansible-lint release from v4.3.5 to v5.0.3

It also mocks the following modules and roles coming from
validations-common to pass the --syntax-check:
- hiera, validations_read_ini and warn customs libs
- check_latest_packages_version role

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I9b17582c3ec1fc1a7e6223f5fcf9f47471f4c1ac
(cherry picked from commit 32e9e9e16e)
(cherry picked from commit 3257d51775)
(cherry picked from commit 5492f5f39a)
(cherry picked from commit 9808650864)
This commit is contained in:
Jiri Podivin 2022-01-11 08:58:59 +01:00
parent 14d6bf1c35
commit b2c3a1074a
4 changed files with 13 additions and 60 deletions

View File

@ -5,6 +5,15 @@ parseable: true
quiet: false
rulesdir:
- .ansible-lint_rules/
# Mock modules or roles in order to pass ansible-playbook --syntax-check
mock_modules:
- hiera
- validations_read_ini
- warn
mock_roles:
- check_latest_packages_version
skip_list:
# Lines should be no longer than 120 chars.
- '204'

View File

@ -1,57 +0,0 @@
# Copyright (c) 2020 Gael Chamoulaud <gchamoul@redhat.com>
# Copyright (c) 2020 Sorin Sbarnea <ssbarnea@redhat.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import re
from ansiblelint import AnsibleLintRule
ROLE_NAME_REGEX = '^[a-z][a-z0-9_]+$'
class RoleNames(AnsibleLintRule):
id = '710'
shortdesc = (
"Role name {} does not match `%s` pattern" % ROLE_NAME_REGEX
)
description = (
"Role names are now limited to contain only lowercase alphanumeric "
"characters, plus '_' and start with an alpha character. See "
"`developing collections "
"<https://docs.ansible.com/ansible/devel/dev_guide/developing_"
"collections.html#roles-directory>`_"
)
severity = 'HIGH'
done = [] # already noticed roles list
tags = ['metadata']
version_added = 'v4.3.0'
ROLE_NAME_REGEXP = re.compile(ROLE_NAME_REGEX)
def match(self, file, text):
path = file['path'].split("/")
if "roles" in path:
role_name = path[path.index("roles") + 1]
if role_name not in self.done:
self.done.append(role_name)
if not re.match(self.ROLE_NAME_REGEXP, role_name):
return self.shortdesc.format(role_name)
else:
return False
return False

View File

@ -1,7 +1,7 @@
import os
import yaml
from ansiblelint import AnsibleLintRule
from ansiblelint.rules import AnsibleLintRule
class ValidationHasMetadataRule(AnsibleLintRule):

View File

@ -21,8 +21,9 @@ repos:
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.3.5
- repo: https://github.com/ansible-community/ansible-lint
rev: v5.3.2
hooks:
- id: ansible-lint
always_run: true