Upgrade ansible-lint to 5.0

- remove role name rule as is included in newer versions
- added .cache folder to git ignore (used by linter)
- enabled optional yamllint run on ansible-lint
- assured repository has a valid root requirements.yml (so linter can make use of it)
- assured that we do not mix playbooks with non playbooks inside same folders
- renamed undocumented "role" argument received by import_role to official "name".
- added mocked roles/modules to avoid linter errors (ideally they should be provided by
  requiremetns.yml).

Change-Id: I14b855f8a15afccaf4973e2a612aa7e9eae3bfa5
This commit is contained in:
Sorin Sbarnea 2021-01-13 17:11:03 +00:00 committed by Sorin Sbârnea
parent a301ffdc24
commit af40f9ff8e
13 changed files with 69 additions and 69 deletions

View File

@ -5,5 +5,56 @@ quiet: false
rulesdir:
- .ansible-lint_rules/
verbosity: 1
warn_list:
- '901' # Failed to load or parse file
# Mocking modules is not recommended as it prevents testing of invalid
# arguments or lack of their presence at runtime. It is preffered to
# make use of requirements.yml to declare them.
mock_roles:
- ceph-defaults
- ceph-facts
mock_modules:
- baremetal_nodes_validate
- baremetal_register_or_update_nodes
- ceph_key
- ceph_pool
- config_template
- container_startup_config
- lvm2_physical_devices_facts
- metalsmith_instances
- os_baremetal_clean_node
- os_baremetal_provide_node
- os_tripleo_baremetal_configure
- os_tripleo_baremetal_node_introspection
- podman_container
- podman_container_info
- podman_volume_info
- tripleo_baremetal_check_existing
- tripleo_baremetal_expand_roles
- tripleo_baremetal_populate_environment
- tripleo_build_heat_environment
- tripleo_composable_network
- tripleo_config_download
- tripleo_container_config_scripts
- tripleo_container_configs
- tripleo_container_image_prepare
- tripleo_derive_hci_parameters
- tripleo_diff_exec
- tripleo_fernet_keys_rotate
- tripleo_generate_ansible_inventory
- tripleo_generate_overcloudrc
- tripleo_get_flatten_stack
- tripleo_get_introspected_data
- tripleo_get_role_list
- tripleo_image_params_prepare
- tripleo_iptables
- tripleo_network_populate_environment
- tripleo_network_ports_populate_environment
- tripleo_os_net_config
- tripleo_os_net_config_mappings
- tripleo_overcloud_network_extract
- tripleo_overcloud_network_ports
- tripleo_passwords_rotate
- tripleo_plan_deploy
- tripleo_plan_parameters_update
- tripleo_swift_tempurl
- tripleo_templates_upload
- tripleo_unmanaged_populate_environment

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

1
.gitignore vendored
View File

@ -38,3 +38,4 @@ doc/build/*
# JetBrain
.idea/
.cache

View File

@ -30,12 +30,13 @@ repos:
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/ansible/ansible-lint
rev: v4.3.5
- repo: https://github.com/ansible-community/ansible-lint
rev: v5.0.3
hooks:
- id: ansible-lint
additional_dependencies:
- 'ansible<2.10'
- yamllint
- repo: https://github.com/openstack-dev/bashate.git
rev: 2.0.0
hooks:

0
galaxy.yml Normal file
View File

1
requirements.yml Symbolic link
View File

@ -0,0 +1 @@
../tripleo-ansible/tripleo_ansible/requirements.yml

View File

@ -14,6 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
# DEPRECATED, the official location for dependencies is now
# /requirements.yaml file.
- name: openstack-operations
scm: git
src: https://opendev.org/openstack/ansible-role-openstack-operations

View File

@ -10,7 +10,7 @@
register: container_startup_config_tmp_dir
- name: Generate container startup configs
container_startup_config:
config_data: "{{ lookup('file', playbook_dir + '/container-configs.yml', errors='ignore') | default({}, True) | from_yaml }}"
config_data: "{{ lookup('file', playbook_dir + '/files/container-configs.yml', errors='ignore') | default({}, True) | from_yaml }}"
config_base_dir: "{{ container_startup_config_tmp_dir.path }}"
- name: Check that HAproxy container configuration file was created
stat:

View File

@ -18,7 +18,7 @@
hosts: all
- name: upgrade ceph mdss cluster, deactivate all rank > 0
hosts: "{{ groups[mon_group_name|default('mons')][0] }}"
hosts: "{{ groups[mon_group_name|default('mons')][0]|default([]) }}"
become: true
tasks:
- name: deactivate all mds rank > 0

View File

@ -18,31 +18,31 @@
tasks:
- name: Satisfy Ceph prerequisites
import_role:
role: tripleo_cephadm
name: tripleo_cephadm
tasks_from: pre
- name: Bootstrap Ceph
import_role:
role: tripleo_cephadm
name: tripleo_cephadm
tasks_from: bootstrap
- name: Apply Ceph spec
import_role:
role: tripleo_cephadm
name: tripleo_cephadm
tasks_from: apply_spec
when: not tripleo_cephadm_spec_on_bootstrap
- name: Create Pools
import_role:
role: tripleo_cephadm
name: tripleo_cephadm
tasks_from: pools
- name: Create Keys
import_role:
role: tripleo_cephadm
name: tripleo_cephadm
tasks_from: keys
- name: Export configuration for tripleo_ceph_client
import_role:
role: tripleo_cephadm
name: tripleo_cephadm
tasks_from: export