Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate-modules: don't error on valid Ansible YAML in EXAMPLES #74384

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

flowerysong
Copy link
Contributor

SUMMARY

Use Ansible's custom loader to support tags like !unsafe during YAML validation.

When a module takes a parameter that usually needs to be marked unsafe, it should be able to provide usable examples in the documentation without failing sanity tests.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

validate-modules

ADDITIONAL INFORMATION
EXAMPLES = '''
- name: Configure LDAP authentication
  flowerysong.hvault.ldap_config:
    url: ldaps://ldap.umich.edu
    userdn: ou=People,dc=umich,dc=edu
    userattr: cn
    groupdn: ou=User Groups,ou=Groups,dc=umich,dc=edu
    groupfilter: !unsafe (member={{.UserDN}})
    groupattr: cn
'''

Without this change:

Running sanity test 'validate-modules' with Python 3.7
ERROR: Found 1 validate-modules issue(s) which need to be resolved:
ERROR: plugins/modules/ldap_config.py:152:18: invalid-examples: EXAMPLES is not valid YAML

@ansibot ansibot added affects_2.12 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Apr 22, 2021
@bcoca bcoca requested a review from mattclay April 22, 2021 19:33
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Apr 22, 2021
@mattclay mattclay merged commit 7b5dad2 into ansible:devel Apr 22, 2021
@flowerysong flowerysong deleted the validate_modules_yaml branch April 22, 2021 20:02
@ansible ansible locked and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.12 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants