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 module documentation must comply with the Ansible standards.  One
aspect of this is the `version_added` must be a valid ansible-core
version in X.Y.Z format.  Note that this version isn't really used
anywhere, so it doesn't matter for users of the role, it is purely
an `ansible-test` and import gating issue.  So removing it.

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

Add cleanup to tests_include_vars_from_parent.yml

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Jan 6, 2024
1 parent 2e79e32 commit f4fb0e6
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 17 deletions.
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
2 changes: 0 additions & 2 deletions .sanity-ansible-ignore-2.11.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
plugins/modules/nbde_client_clevis.py validate-modules:missing-gplv3-license
plugins/modules/nbde_client_clevis.py validate-modules:module-invalid-version-added
plugins/modules/nbde_client_clevis.py validate-modules:parameter-list-no-elements
2 changes: 0 additions & 2 deletions .sanity-ansible-ignore-2.12.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
plugins/modules/nbde_client_clevis.py validate-modules:missing-gplv3-license
plugins/modules/nbde_client_clevis.py validate-modules:module-invalid-version-added
plugins/modules/nbde_client_clevis.py validate-modules:parameter-list-no-elements
1 change: 0 additions & 1 deletion .sanity-ansible-ignore-2.13.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
plugins/modules/nbde_client_clevis.py validate-modules:missing-gplv3-license
plugins/modules/nbde_client_clevis.py validate-modules:parameter-list-no-elements
1 change: 0 additions & 1 deletion .sanity-ansible-ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
plugins/modules/nbde_client_clevis.py validate-modules:missing-gplv3-license
plugins/modules/nbde_client_clevis.py validate-modules:parameter-list-no-elements
1 change: 0 additions & 1 deletion .sanity-ansible-ignore-2.15.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
plugins/modules/nbde_client_clevis.py validate-modules:missing-gplv3-license
plugins/modules/nbde_client_clevis.py validate-modules:parameter-list-no-elements
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.16.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
plugins/modules/nbde_client_clevis.py validate-modules:missing-gplv3-license
13 changes: 6 additions & 7 deletions library/nbde_client_clevis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
---
module: nbde_client_clevis
short_description: Handle clevis-related operations on LUKS devices
version_added: "2.9"
description:
- "WARNING: Do not use this module directly! It is only for role internal use."
- "Module manages clevis bindings on encrypted devices to match the state
Expand All @@ -26,6 +25,7 @@
either added or removed from a given device/slot. It supports
the following keys:
type: list
elements: dict
suboptions:
device:
description:
Expand Down Expand Up @@ -88,13 +88,12 @@
- http://server1.example.com
- http://server2.example.com
- name: Remove binding from slot 2 in /dev/sda1
nbde_client_bindings:
- device: /dev/sda1
encryption_password: password
slot: 2
state: absent
- device: /dev/sda1
encryption_password: password
slot: 2
state: absent
"""

RETURN = """
Expand Down Expand Up @@ -1593,7 +1592,7 @@ def run_module():
"""The entry point of the module."""

module_args = dict(
bindings=dict(type="list", required=False),
bindings=dict(type="list", elements="dict", required=False),
data_dir=dict(type="str", required=False),
)

Expand Down
6 changes: 4 additions & 2 deletions tests/roles/caller/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
# tasks file for caller

- include_role:
- name: Call role
include_role:
name: "{{ roletoinclude }}"

- assert:
- name: Assert variable not overridden
assert:
that: not __caller_override
11 changes: 10 additions & 1 deletion tests/tests_include_vars_from_parent.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Test role variable override
- name: Test role include variable override
hosts: all
gather_facts: true
tasks:
Expand Down Expand Up @@ -38,9 +38,18 @@
varfiles: "{{ [facts['distribution']] | product(separators) |
map('join') | product(versions) | map('join') | list +
[facts['distribution'], facts['os_family']] }}"
register: __varfiles_created

- name: Import role
import_role:
name: caller
vars:
roletoinclude: linux-system-roles.nbde_client

- name: Cleanup
file:
path: "{{ item.dest }}"
state: absent
loop: "{{ __varfiles_created.results }}"
delegate_to: localhost
when: inventory_hostname == ansible_play_hosts_all[0]

0 comments on commit f4fb0e6

Please sign in to comment.