Skip to content

Commit

Permalink
ci: Use supported ansible-lint action; run ansible-lint against the c…
Browse files Browse the repository at this point in the history
…ollection

The old ansible-community ansible-lint is deprecated.  There is a
new ansible-lint github action.  The new ansible-lint has several checks
related to ansible-test and the ignore files.  Many of our ignore settings
are not allowed any more and are required to be fixed or addressed in the
Ansible preferred way.

The python imports have to be wrapped in a try/except ImportError, and
where possible, an error must be returned from the module explaining
what was not able to be imported.

The module documentation must comply with the Ansible standards.

Because the module code uses mypy, we have to tell ansible-test
to ignore some code with `compile-2.7!skip` and `import-x.y!skip`,
which ansible-lint does not like, so we have to add
```
skip_list:
  - sanity[cannot-ignore]
```
to make ansible-lint happy.

The latest Ansible repo gating tests run ansible-lint against
the collection format instead of against individual roles.
We have to convert the role to collection format before running
ansible-test.

Role developers can run this locally using
`tox -e collection,ansible-lint-collection`
See linux-system-roles/tox-lsr#125

Add `---` doc start to .markdownlint.yaml

Get rid of tests_include_vars_from_parent.yml - does not work anymore

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Jan 6, 2024
1 parent d930513 commit f9cce07
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 167 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ kinds:
skip_list:
- fqcn-builtins
- var-naming[no-role-prefix]
- sanity[cannot-ignore]
exclude_paths:
- tests/roles/
- .github/
Expand Down
1 change: 1 addition & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Default state for all rules
default: true

Expand Down
33 changes: 12 additions & 21 deletions .sanity-ansible-ignore-2.13.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
plugins/modules/pcs_api_v2.py compile-2.7!skip
plugins/modules/pcs_api_v2.py import-2.7!skip
plugins/modules/pcs_api_v2.py import-3.5!skip
plugins/modules/pcs_api_v2.py import-3.6!skip
plugins/modules/pcs_api_v2.py import-3.7!skip
plugins/modules/pcs_api_v2.py import-3.8!skip
plugins/modules/pcs_api_v2.py import-3.9!skip
plugins/modules/pcs_api_v2.py import-3.10!skip
plugins/modules/pcs_api_v2.py validate-modules:import-error
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.8!skip
plugins/modules/pcs_qdevice_certs.py compile-2.7!skip
plugins/modules/pcs_qdevice_certs.py import-2.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.5!skip
plugins/modules/pcs_qdevice_certs.py import-3.6!skip
plugins/modules/pcs_qdevice_certs.py import-3.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.8!skip
plugins/modules/pcs_qdevice_certs.py import-3.9!skip
plugins/modules/pcs_qdevice_certs.py import-3.10!skip
plugins/modules/pcs_qdevice_certs.py validate-modules:import-error
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.9!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.10!skip
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
38 changes: 16 additions & 22 deletions .sanity-ansible-ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
plugins/modules/pcs_api_v2.py compile-2.7!skip
plugins/modules/pcs_api_v2.py compile-3.5!skip
plugins/modules/pcs_api_v2.py import-2.7!skip
plugins/modules/pcs_api_v2.py import-3.5!skip
plugins/modules/pcs_api_v2.py import-3.6!skip
plugins/modules/pcs_api_v2.py import-3.7!skip
plugins/modules/pcs_api_v2.py import-3.8!skip
plugins/modules/pcs_api_v2.py import-3.9!skip
plugins/modules/pcs_api_v2.py import-3.10!skip
plugins/modules/pcs_api_v2.py import-3.11!skip
plugins/modules/pcs_api_v2.py validate-modules:import-error
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.8!skip
plugins/modules/pcs_qdevice_certs.py compile-2.7!skip
plugins/modules/pcs_qdevice_certs.py compile-3.5!skip
plugins/modules/pcs_qdevice_certs.py import-2.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.5!skip
plugins/modules/pcs_qdevice_certs.py import-3.6!skip
plugins/modules/pcs_qdevice_certs.py import-3.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.8!skip
plugins/modules/pcs_qdevice_certs.py import-3.9!skip
plugins/modules/pcs_qdevice_certs.py import-3.10!skip
plugins/modules/pcs_qdevice_certs.py import-3.11!skip
plugins/modules/pcs_qdevice_certs.py validate-modules:import-error
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.9!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.10!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.11!skip
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
38 changes: 16 additions & 22 deletions .sanity-ansible-ignore-2.15.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
plugins/modules/pcs_api_v2.py compile-2.7!skip
plugins/modules/pcs_api_v2.py compile-3.5!skip
plugins/modules/pcs_api_v2.py import-2.7!skip
plugins/modules/pcs_api_v2.py import-3.5!skip
plugins/modules/pcs_api_v2.py import-3.6!skip
plugins/modules/pcs_api_v2.py import-3.7!skip
plugins/modules/pcs_api_v2.py import-3.8!skip
plugins/modules/pcs_api_v2.py import-3.9!skip
plugins/modules/pcs_api_v2.py import-3.10!skip
plugins/modules/pcs_api_v2.py import-3.11!skip
plugins/modules/pcs_api_v2.py validate-modules:import-error
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.8!skip
plugins/modules/pcs_qdevice_certs.py compile-2.7!skip
plugins/modules/pcs_qdevice_certs.py compile-3.5!skip
plugins/modules/pcs_qdevice_certs.py import-2.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.5!skip
plugins/modules/pcs_qdevice_certs.py import-3.6!skip
plugins/modules/pcs_qdevice_certs.py import-3.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.8!skip
plugins/modules/pcs_qdevice_certs.py import-3.9!skip
plugins/modules/pcs_qdevice_certs.py import-3.10!skip
plugins/modules/pcs_qdevice_certs.py import-3.11!skip
plugins/modules/pcs_qdevice_certs.py validate-modules:import-error
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.5!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.9!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.10!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.11!skip
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
35 changes: 12 additions & 23 deletions .sanity-ansible-ignore-2.16.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
plugins/modules/pcs_api_v2.py compile-2.7!skip
plugins/modules/pcs_api_v2.py import-2.7!skip
plugins/modules/pcs_api_v2.py import-3.6!skip
plugins/modules/pcs_api_v2.py import-3.7!skip
plugins/modules/pcs_api_v2.py import-3.8!skip
plugins/modules/pcs_api_v2.py import-3.9!skip
plugins/modules/pcs_api_v2.py import-3.10!skip
plugins/modules/pcs_api_v2.py import-3.11!skip
plugins/modules/pcs_api_v2.py import-3.12!skip
plugins/modules/pcs_api_v2.py validate-modules:import-error
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.8!skip
plugins/modules/pcs_qdevice_certs.py compile-2.7!skip
plugins/modules/pcs_qdevice_certs.py import-2.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.6!skip
plugins/modules/pcs_qdevice_certs.py import-3.7!skip
plugins/modules/pcs_qdevice_certs.py import-3.8!skip
plugins/modules/pcs_qdevice_certs.py import-3.9!skip
plugins/modules/pcs_qdevice_certs.py import-3.10!skip
plugins/modules/pcs_qdevice_certs.py import-3.11!skip
plugins/modules/pcs_qdevice_certs.py import-3.12!skip
plugins/modules/pcs_qdevice_certs.py validate-modules:import-error
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-2.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.6!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.7!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.9!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.10!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.11!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.12!skip
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
21 changes: 20 additions & 1 deletion library/pcs_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
cmd_params:
description: parameters of the command specified in cmd_name
type: dict
default: {}
cmd_options:
description: generic command options
type: dict
default: {}
suboptions:
request_timeout:
description: request timeout
Expand Down Expand Up @@ -119,8 +121,25 @@
# pylint: disable=no-name-in-module
from ansible.module_utils.ha_cluster_lsr import pcs_api_v2_utils as api_utils

import traceback

# pylint: enable=no-name-in-module
from pcs.common.async_tasks.dto import CommandDto, CommandOptionsDto
try:
from pcs.common.async_tasks.dto import CommandDto, CommandOptionsDto
except ImportError:
HAS_PCS = False
PCS_IMPORT_ERROR = traceback.format_exc()

class CommandOptionsDto(object):
def __init__(self, **kwargs):
pass

class CommandDto(object):
pass

else:
HAS_PCS = True
PCS_IMPORT_ERROR = None


def run_module() -> None:
Expand Down
20 changes: 19 additions & 1 deletion library/pcs_qdevice_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
cmd_options:
description: pcs API v2 command options
type: dict
default: {}
suboptions:
request_timeout:
description: request timeout
Expand Down Expand Up @@ -112,8 +113,25 @@
# pylint: disable=no-name-in-module
from ansible.module_utils.ha_cluster_lsr import pcs_api_v2_utils as api_utils

import traceback

# pylint: enable=no-name-in-module
from pcs.common.async_tasks.dto import CommandDto, CommandOptionsDto
try:
from pcs.common.async_tasks.dto import CommandDto, CommandOptionsDto
except ImportError:
HAS_PCS = False
PCS_IMPORT_ERROR = traceback.format_exc()

class CommandOptionsDto(object):
def __init__(self, **kwargs):
pass

class CommandDto(object):
pass

else:
HAS_PCS = True
PCS_IMPORT_ERROR = None


def run_module() -> None:
Expand Down
50 changes: 41 additions & 9 deletions module_utils/ha_cluster_lsr/pcs_api_v2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# pylint: enable=invalid-name

import sys
import traceback


# Add paths to pcs bundled libraries to make Dacite available
sys.path.insert(0, "/usr/lib64/pcs/pcs_bundled/packages/")
Expand All @@ -24,15 +26,45 @@

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url
from dacite import DaciteError
from pcs.common.async_tasks.dto import (
CommandDto,
CommandOptionsDto,
TaskResultDto,
)
from pcs.common.async_tasks.types import TaskFinishType, TaskKillReason
from pcs.common.interface.dto import from_dict, to_dict
from pcs.common.reports import ReportItemDto, ReportItemSeverity

try:
from dacite import DaciteError
except ImportError:
HAS_DACITE = False
DACITE_IMPORT_ERROR = traceback.format_exc()
else:
HAS_DACITE = True
DACITE_IMPORT_ERROR = None

try:
from pcs.common.async_tasks.dto import (
CommandDto,
CommandOptionsDto,
TaskResultDto,
)
from pcs.common.async_tasks.types import TaskFinishType, TaskKillReason
from pcs.common.interface.dto import from_dict, to_dict
from pcs.common.reports import ReportItemDto, ReportItemSeverity
except ImportError:
HAS_PCS = False
PCS_IMPORT_ERROR = traceback.format_exc()

class CommandOptionsDto(object):
def __init__(self, **kwargs):
pass

class ReportItemDto(object):
pass

class TaskResultDto(object):
pass

class CommandDto(object):
pass

else:
HAS_PCS = True
PCS_IMPORT_ERROR = None

PCSD_SOCKET = "/var/run/pcsd.socket"
API_ENDPOINT = "http://doesntmatter/api/v2/task/run"
Expand Down
4 changes: 2 additions & 2 deletions tasks/shell_pcs/sbd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
loop: "{{ ha_cluster.sbd_watchdog_modules_blocklist | d([]) }}"

- name: Unload watchdog kernel modules from blocklist
modprobe:
community.general.modprobe:
name: "{{ item }}"
state: absent
loop: "{{ ha_cluster.sbd_watchdog_modules_blocklist | d([]) }}"
Expand All @@ -38,7 +38,7 @@
loop: "{{ ha_cluster.sbd_watchdog_modules | d([]) }}"

- name: Load watchdog kernel modules
modprobe:
community.general.modprobe:
name: "{{ item }}"
state: present
loop: "{{ ha_cluster.sbd_watchdog_modules | d([]) }}"
Expand Down
10 changes: 0 additions & 10 deletions tests/roles/caller/tasks/main.yml

This file was deleted.

4 changes: 0 additions & 4 deletions tests/roles/caller/vars/main.yml

This file was deleted.

Loading

0 comments on commit f9cce07

Please sign in to comment.