Summary
I have a problem with Automation Hub gating which (afaict) uses ansible-lint 24.12.2, ansible-core 2.16, and python 3.12 - and using mock_modules in .ansible-lint - ansible-lint generates a mocked python module which fails ansible-lint - steps to reproduce:
# python3.12 -mvenv .venv
# . .venv/bin/activate
# pip install ansible-lint==24.* ansible-core==2.16.*
# ansible-galaxy collection init myns.mycoll
# cd myns/mycoll
# cat .ansible-lint
mock_modules:
- some_ns.some_coll.some_module
# ansible-lint
load-failure: Failed to load or parse file.
.ansible/collections/ansible_collections/some_ns/some_coll/plugins/modules/some_module.py:14
yaml[new-line-at-end-of-file]: No new line character at the end of file
.ansible/collections/ansible_collections/some_ns/some_coll/plugins/modules/some_module.py:14
afaict, the problem is the generated EXAMPLES = '''mocked''' and RETURN = '''mocked''' - these are being flagged as invalid YAML by rules init.py matchyaml -
# yaml returned can be an AnsibleUnicode (a string) when the yaml
# file contains a single string. YAML spec allows this but we consider
# this an fatal error.
I don't know if the v24 branch is being maintained upstream but this is the version being used by Automation Hub.
Issue Type
OS / ENVIRONMENT
ansible-lint --version
24.12.2
ansible --version
2.16.2
- ansible installation method: pip
- ansible-lint installation method: pip
STEPS TO REPRODUCE
see above
Desired Behavior
Should be able to use mock_modules and ansible-lint will pass.
Actual Behavior
See above.
Summary
I have a problem with Automation Hub gating which (afaict) uses ansible-lint 24.12.2, ansible-core 2.16, and python 3.12 - and using
mock_modulesin .ansible-lint - ansible-lint generates a mocked python module which fails ansible-lint - steps to reproduce:afaict, the problem is the generated
EXAMPLES = '''mocked'''andRETURN = '''mocked'''- these are being flagged as invalid YAML by rules init.py matchyaml -I don't know if the v24 branch is being maintained upstream but this is the version being used by Automation Hub.
Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
see above
Desired Behavior
Should be able to use
mock_modulesand ansible-lint will pass.Actual Behavior
See above.