Skip to content

Conversation

shatakshiiii
Copy link
Contributor

@shatakshiiii shatakshiiii commented Jun 24, 2025

SUMMARY

This PR adds a new rule pattern for validating a sample pattern directory structure within an ansible collection.

Pattern rule consists of following sub-rules -

  • pattern[missing-readme]- triggers when the README.md file is missing from a pattern directory.
  • pattern[missing-meta] - triggers when a pattern.json spec file exists but parent meta directory is missing.
  • pattern[missing-playbook] - triggers when either the required playbooks directory or playbook file is missing.
  • pattern[name-mismatch] - triggers when pattern name does not matches with the name key in pattern.json file.

Steps to validate pattern dir structure -

  • Scaffold a pattern to an existing collection using ansible-creator -
    ansible-creator add resource pattern sample_pattern path/to/coll_proj
  • Navigate to the collection directory - cd coll_proj
  • Run ansible-lint on the pattern definition meta file -
    ansible-lint extensions/patterns/sample_pattern/meta/pattern.json
  • Review the validation results.

Fixes: #4665
Fixes: AAP-47360

@shatakshiiii shatakshiiii self-assigned this Jun 25, 2025
@shatakshiiii shatakshiiii requested a review from cidrblock June 25, 2025 13:57
Copy link
Contributor

@alisonlhart alisonlhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@samccann
Copy link
Contributor

Since the draft spec talks about 64 character limit to the pattern name and characters allowed, should this PR also validate that as well?

@shatakshiiii
Copy link
Contributor Author

shatakshiiii commented Jul 1, 2025

Since the draft spec talks about 64 character limit to the pattern name and characters allowed, should this PR also validate that as well?

There is a function in ansible-creator that validates pattern name early on during the scaffolding of pattern. I did not added same logic here in lint thinking it would be redundant.

As per my understanding - User will first use ansible-creator to scaffold a pattern (where if pattern name does not follow the spec then it will fail right there). Then use ansible-lint to validate the same pattern.

Looking for your thoughts here @samccann @ssbarnea @alisonlhart !

@shatakshiiii shatakshiiii requested a review from samccann July 1, 2025 08:22
@github-project-automation github-project-automation bot moved this from In Progress to Review in 🧰 devtools project board Jul 1, 2025
@ssbarnea ssbarnea enabled auto-merge (squash) July 1, 2025 14:14
@ssbarnea ssbarnea disabled auto-merge July 1, 2025 14:34
@ssbarnea ssbarnea merged commit 35a3b85 into main Jul 1, 2025
41 of 43 checks passed
@ssbarnea ssbarnea deleted the validate_pattern_dir branch July 1, 2025 14:40
@github-project-automation github-project-automation bot moved this from Review to Done in 🧰 devtools project board Jul 1, 2025
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jul 30, 2025
This MR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pipx:ansible-lint](https://github.com/ansible/ansible-lint) ([changelog](https://github.com/ansible/ansible-lint/releases)) | `25.6.1` -> `25.7.0` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/ansible-lint/25.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/ansible-lint/25.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/ansible-lint/25.6.1/25.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ansible-lint/25.6.1/25.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>ansible/ansible-lint (pipx:ansible-lint)</summary>

### [`v25.7.0`](https://github.com/ansible/ansible-lint/releases/tag/v25.7.0)

[Compare Source](ansible/ansible-lint@v25.6.1...v25.7.0)

#### Enhancements

- Use 'x-ansible-lint' key for path patterns in schema tests ([#&#8203;4690](ansible/ansible-lint#4690)) [@&#8203;alisonlhart](https://github.com/alisonlhart)
- Address disable\_lookups deprecation with ansible-core 2.19 ([#&#8203;4683](ansible/ansible-lint#4683)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
- Add auto-fixing implementation for pattern rule ([#&#8203;4679](ansible/ansible-lint#4679)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
- Remove patterns specific playbook meta folder ([#&#8203;4669](ansible/ansible-lint#4669)) [@&#8203;alisonlhart](https://github.com/alisonlhart)
- Allow loading of yamllint config from a different location ([#&#8203;4644](ansible/ansible-lint#4644)) [@&#8203;dbrennand](https://github.com/dbrennand)
- Add new rule to validate pattern directory structure ([#&#8203;4662](ansible/ansible-lint#4662)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
- Add play argspec schema validation to schema rule ([#&#8203;4667](ansible/ansible-lint#4667)) [@&#8203;alisonlhart](https://github.com/alisonlhart)
- Add schema check for validating pattern specification file ([#&#8203;4653](ansible/ansible-lint#4653)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
- Enable testing with python 3.14 ([#&#8203;4637](ansible/ansible-lint#4637)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

#### Bugfixes

- Check for gh\_action\_ref explicitly and document GHA inputs ([#&#8203;4701](ansible/ansible-lint#4701)) [@&#8203;alisonlhart](https://github.com/alisonlhart)
- jinja spacing warning line-endings ([#&#8203;4691](ansible/ansible-lint#4691)) [@&#8203;anusshukla](https://github.com/anusshukla)
- Handle lookup templating checks with ASTs ([#&#8203;4698](ansible/ansible-lint#4698)) [@&#8203;alisonlhart](https://github.com/alisonlhart)
- Fix var-naming\[no-role-prefix] rule incorrectly applying to role variables ([#&#8203;4677](ansible/ansible-lint#4677)) [@&#8203;vills](https://github.com/vills)
- schema: add missing subset 'systemd' to gather\_subset ([#&#8203;4664](ansible/ansible-lint#4664)) [@&#8203;eliba](https://github.com/eliba)
- Fix typos in --list-tags help text ([#&#8203;4661](ansible/ansible-lint#4661)) [@&#8203;correctmost](https://github.com/correctmost)
- Avoid import errors from filters when running in nodeps mode ([#&#8203;4651](ansible/ansible-lint#4651)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

#### Maintenance

- packit: reformat, remove deprecated syntax and try merge queue ([#&#8203;4639](ansible/ansible-lint#4639)) [@&#8203;mfocko](https://github.com/mfocko)
- Remove patch report from codecov ([#&#8203;4671](ansible/ansible-lint#4671)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
- Improve cspell configuration ([#&#8203;4668](ansible/ansible-lint#4668)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
- Update test deps ([#&#8203;4658](ansible/ansible-lint#4658)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40NS4wIiwidXBkYXRlZEluVmVyIjoiNDEuNDUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add new rule to validate pattern directory structure

6 participants