Skip to content

Commit

Permalink
Added 'make ansible_lint' and fixed some of the ansible-lint issues r…
Browse files Browse the repository at this point in the history
…eported

Details:

* Added ansible-lint to the development dependencies. Needed to increase some
  package dependencies for development and also for installation.

* Added a new make target 'ansible_lint' for running ansible-lint, in order
  to get a preview of the AutomationHub import warnings.

* Added 'make ansible_lint' as a new step to the Github Actions test workflow.

* Resolved the issues reported by 'make ansible_lint' where possible. The
  remaining issues are those that are also reported by the Ansible
  AutomationHub import.

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Dec 17, 2023
1 parent 5aeb641 commit 2c450b9
Show file tree
Hide file tree
Showing 47 changed files with 97 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ jobs:
PACKAGE_LEVEL: ${{ matrix.package_level }}
run: |
make sanity
- name: Run ansible_lint
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
run: |
make ansible_lint
- name: Run unit/function test
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ help:
@echo ' dist - Build the collection distribution archive in: $(dist_dir)'
@echo ' check - Run flake8'
@echo ' sanity - Run Ansible sanity tests (includes pep8, pylint, validate-modules)'
@echo ' ansible_lint - Run ansible-lint on distribution archive (and built it)'
@echo ' safety - Run safety on sources'
@echo ' check_reqs - Perform missing dependency checks'
@echo ' docs - Build the documentation for all enabled (docs/source/conf.py) versions in: $(doc_build_dir) using remote repo'
Expand Down Expand Up @@ -249,7 +250,7 @@ help:
@echo ' ansible-playbook playbooks/....'

.PHONY: all
all: install develop dist safety check sanity check_reqs docs docslocal linkcheck test end2end_mocked
all: install develop dist safety check sanity ansible_lint check_reqs docs docslocal linkcheck test end2end_mocked
@echo '$@ done.'

.PHONY: install
Expand Down Expand Up @@ -318,6 +319,15 @@ else
endif
@echo '$@ done.'

.PHONY: ansible_lint
ansible_lint: _check_version $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(dist_file)
echo 'Running ansible-lint on distribution archive'
rm -rf $(dist_dir)/tmp
mkdir -p $(dist_dir)/tmp
tar -xf $(dist_file) --directory $(dist_dir)/tmp
-sh -c "cd $(dist_dir)/tmp; ansible-lint --profile production -f pep8"
@echo '$@ done.'

.PHONY: check_reqs
check_reqs: _check_version $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done minimum-constraints.txt requirements.txt
ifeq ($(python_major_version),2)
Expand Down
5 changes: 3 additions & 2 deletions ansible-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ MarkupSafe>=2.0.0; python_version >= '3.9' # ansible >= 6
# Direct dependencies for development (must be consistent with dev-requirements.txt)

# ansible-test
yamllint==1.25.0
pathspec==0.8.0
yamllint==1.25.0; python_version <= '3.9'
yamllint==1.26.3; python_version >= '3.10'
pathspec==0.9.0
rstcheck==3.3.1; python_version <= '3.9' # ansible <= 2.10 (on minimum package levels)
16 changes: 13 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ coveralls>=3.3.0; python_version >= '3.5'
# PyYAML is specified in requirements.txt

# ansible-test
yamllint>=1.25.0
pathspec>=0.8.0
yamllint>=1.25.0; python_version <= '3.9'
yamllint>=1.26.3; python_version >= '3.10'
pathspec>=0.9.0
# rstcheck 3.5.0 introduced a FutureWarning about Python 3.7 causing ansible sanity check "rstcheck" to fail.
# ansible sanity check "rstcheck" is used only in ansible <= 2.10.
rstcheck>=3.3.1,<3.5; python_version >= '3.5' and python_version <= '3.6' # ansible <= 2.10 (on minimum package levels)
rstcheck>=3.3.1,<4.0; python_version >= '3.7' and python_version <= '3.9' # ansible >= 4

# ansible-lint
# ansible-lint requires black
# ansible-lint 6.14.0 depends on yamllint>=1.26.3, ansible-core>=2.12.0
ansible-lint>=4.2.0; python_version == '2.7'
ansible-lint>=4.2.0; python_version == '3.5'
ansible-lint>=5.4.0; python_version >= '3.6' and python_version <= '3.9'
ansible-lint>=6.14.0; python_version >= '3.10'
black>=22.8.0; python_version >= '3.6'

# Safety CI by pyup.io
# Safety is run only on Python >=3.6
# Safety 2.3.5 (running only on Python >=3.6) requires packaging<22.0,>=21.0, but safety 2.3.4 does not
Expand Down Expand Up @@ -138,7 +148,7 @@ astroid>=2.4.0,<2.5; python_version >= '3.5' and python_version <= '3.7' # astr
astroid>=2.4.0,<2.7; python_version >= '3.8' and python_version <= '3.9' # astroid 2.6
astroid>=2.4.0,<2.13; python_version >= '3.10' and python_version <= '3.11' # astroid 2.12
astroid>=3.0.1; python_version >= '3.12' # astroid 3.x
typed-ast>=1.4.0,<1.5.0; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
typed-ast>=1.4.2,<1.5.0; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
# used by pylint 2.14 which requires python_version >= '3.7' and is used by us only on py>=3.10
dill>=0.2; python_version == '3.11'
dill>=0.3.7; python_version >= '3.12'
Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ Examples




See Also
--------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_adapter_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ Examples




See Also
--------

Expand Down
3 changes: 1 addition & 2 deletions docs/source/modules/zhmc_cpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Examples
state: set
properties:
acceptable_status:
- active
- active
description: "This is CPC {{ my_cpc_name }}"
register: cpc1

Expand All @@ -224,7 +224,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_cpc_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_crypto_attachment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_ldap_server_definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ Examples




Return Values
-------------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/modules/zhmc_lpar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ Examples
state: inactive
register: lpar1

- name: Ensure the LPAR is active (using the default image profile when it needs to be activated), and then set the CP sharing weight to 20
- name: "Ensure the LPAR is active (using the default image profile when it needs to be activated),
and then set the CP sharing weight to 20"
zhmc_lpar:
hmc_host: "{{ my_hmc_host }}"
hmc_auth: "{{ my_hmc_auth }}"
Expand Down Expand Up @@ -332,7 +333,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_lpar_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_lpar_messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_nic_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ Examples




See Also
--------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_partition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ Examples




See Also
--------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_partition_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ Examples




See Also
--------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_partition_messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_password_rule.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ Examples




Return Values
-------------

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_storage_group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ Examples




Notes
-----

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_storage_group_attachment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ Examples




Notes
-----

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_storage_volume.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ Examples




Notes
-----

Expand Down
1 change: 0 additions & 1 deletion docs/source/modules/zhmc_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ Examples




Return Values
-------------

Expand Down
15 changes: 10 additions & 5 deletions docs/source/modules/zhmc_user_role.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,18 @@ Examples
properties:
description: "Example user role 1"
permissions:
- task: "configure-storage-storageadmin" # Task permission to "configure-storage-storageadmin"
- task: "hardware-messages" # Task permission to the view-only version of "hardware-messages"
# Task permission to "configure-storage-storageadmin":
- task: "configure-storage-storageadmin"
# Task permission to the view-only version of "hardware-messages":
- task: "hardware-messages"
view_only: true
- class: cpc # Object permission to all CPCs
- partition: part1 # Object permission to part1 in cpc1
# Object permission to all CPCs:
- class: cpc
# Object permission to part1 in cpc1:
- partition: part1
cpc: cpc1
- partition: part2 # Object permission to part2 in cpc2
# Object permission to part2 in cpc2:
- partition: part2
cpc: cpc2
register: rule1

Expand Down
11 changes: 11 additions & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ Availability: `AutomationHub`_, `Galaxy`_, `GitHub`_
that retrieve and return console messages from the operating system running
in an LPAR or DPM partition. (issue #565)

* Added a new make target 'make lint' which invokes ansible-lint.
Fixed some of the warnings reported by ansible-lint.
(related to issue #784)

* Increased the minimum versions of the following packages used for installing
the collection:

- packaging to 21.3 (on Python >= 3.6)
- PyYAML to 6.0.1 (on Python >= 3.6)
- jsonschema to 4.10.0 (on Python >= 3.7)

**Cleanup:**

* Removed documentation and test files (except sanity test ignore files) from
Expand Down
3 changes: 3 additions & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ build_ignore:
- .coveragerc
- .flake8 # only in older branches
- .travis.yml
- .whitesource
- .safety-policy.yml
- CODE_OF_CONDUCT.md
- CONTRIBUTING.rst # only in older branches
- DCO1.1.txt # only in older branches
- LICENSE
- Makefile
# requirements.txt is intentionally included for dependent install
- dev-requirements.txt
- ansible-constraints.txt
- minimum-constraints.txt
- tools
- docs_local
Expand Down
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Keep in sync with lowest ansible version in requirements.txt and minimum-constraints.txt

Check failure on line 1 in meta/runtime.yml

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 3.11, latest)

meta-runtime[unsupported-version]

requires_ansible key must be set to a supported version.

Check failure on line 1 in meta/runtime.yml

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 3.12, latest)

meta-runtime[unsupported-version]

requires_ansible key must be set to a supported version.

Check failure on line 1 in meta/runtime.yml

View workflow job for this annotation

GitHub Actions / test (macos-latest, 3.11, latest)

meta-runtime[unsupported-version]

requires_ansible key must be set to a supported version.
requires_ansible: ">=2.9"
requires_ansible: ">=2.9.27"
28 changes: 20 additions & 8 deletions minimum-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ importlib-metadata==1.1.0; python_version >= '3.8' and python_version <= '3.11'
importlib-metadata==4.8.3; python_version >= '3.12'

packaging==20.5; python_version <= '3.5'
packaging==21.0; python_version >= '3.6'
PyYAML==5.3.1
packaging==21.3; python_version >= '3.6'
PyYAML==5.3.1; python_version <= '3.5'
PyYAML==6.0.1; python_version >= '3.6'

python-dateutil==2.8.2
jsonschema==3.0.1
jsonschema==3.0.1; python_version <= '3.6'
jsonschema==4.10.0; python_version >= '3.7'
urllib3==1.26.18; python_version == '2.7'
urllib3==1.26.9; python_version == '3.5'
urllib3==1.26.18; python_version >= '3.6'
Expand Down Expand Up @@ -144,10 +146,18 @@ pytest-cov==2.7.0
coveralls==3.3.0; python_version >= '3.5'

# ansible-test
yamllint==1.25.0
pathspec==0.8.0
yamllint==1.25.0; python_version <= '3.9'
yamllint==1.26.3; python_version >= '3.10'
pathspec==0.9.0
rstcheck==3.3.1; python_version <= '3.9' # ansible <= 2.10 (on minimum package levels)

# ansible-lint
ansible-lint==4.2.0; python_version == '2.7'
ansible-lint==4.2.0; python_version == '3.5'
ansible-lint==5.4.0; python_version >= '3.6' and python_version <= '3.9'
ansible-lint==6.14.0; python_version >= '3.10'
black==22.8.0; python_version >= '3.6'

# Safety CI by pyup.io
# Safety is run only on Python >=3.6
safety==2.2.0; python_version >= '3.6'
Expand Down Expand Up @@ -191,7 +201,7 @@ astroid==2.4.0; python_version >= '3.5' and python_version <= '3.11'
# astroid==2.6.1; python_version >= '3.8' and python_version <= '3.9'
# astroid==2.12.4; python_version >= '3.10' and python_version <= '3.11'
astroid==3.0.1; python_version >= '3.12'
typed-ast==1.4.0; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
typed-ast==1.4.2; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
# used by pylint 2.14 which requires python_version >= '3.7' and is used by us only on py>=3.10
dill==0.2; python_version == '3.11'
dill==0.3.7; python_version >= '3.12'
Expand Down Expand Up @@ -241,7 +251,9 @@ contextlib2==0.6.0
custom-inherit==2.2.2
docopt==0.6.2
enum34==1.1.6; python_version == '2.7' # technically: python_version <= '3.3'
filelock==3.2.0; python_version <= '3.11'
filelock==3.2.0; python_version == '2.7'
filelock==3.2.0; python_version == '3.5'
filelock==3.3.0; python_version >= '3.6' and python_version <= '3.11'
filelock==3.11.0; python_version >= '3.12'
future==0.18.3
futures==3.3.0; python_version == '2.7' # technically: python_version <= '3.1'
Expand Down Expand Up @@ -287,7 +299,7 @@ toml==0.10.0
traceback2==1.4.0
traitlets==4.3.1
typing==3.6.1; python_version == '2.7' # technically: python_version <= '3.4'
typing-extensions==3.7.4.3 # Used in some combinations of Python version and package level
typing-extensions==3.10.0.0 # Used in some combinations of Python version and package level
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==1.2.6
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/zhmc_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@
cpc_name: "{{ my_cpc_name }}"
name: "{{ my_adapter_name }}"
state: absent
"""

RETURN = """
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/zhmc_adapter_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
cpc_name: CPCA
adapter_family: "ficon"
register: adapter_list
"""

RETURN = """
Expand Down
Loading

0 comments on commit 2c450b9

Please sign in to comment.