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

Use new requirements.yml format #1402

Merged
merged 1 commit into from
Jul 15, 2022
Merged

Conversation

codepuncher
Copy link

Fixes #1401

@swalkinshaw
Copy link
Member

🤔 where is this format from? Their examples reflect what we currently have: https://galaxy.ansible.com/docs/using/installing.html

@tangrufus
Copy link
Member

New format introduced because requirements.yml (our galaxy.yml) now supports both roles and collections.

See: https://docs.ansible.com/ansible/devel/user_guide/collections_using.html#install-multiple-collections-with-a-requirements-file

@codepuncher
Copy link
Author

Yep, that's it; thanks @tangrufus.

On third thought, I think it is best to rename galaxy.yml to requirements.yml.

The reason is that galaxy.yml is reserved for a different purpose than the original requirements.yml.

See more: https://docs.galaxyproject.org/en/master/admin/config.html#configuration-files, https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/config/sample/galaxy.yml.sample

Using galaxy.yml and running ansible-lint it will report Incorrect type. Expected "Ansible Collection Galaxy"..

@swalkinshaw
Copy link
Member

👍 we just need to verify if the oldest supported version of Ansible supports this format

@codepuncher
Copy link
Author

ansible/ansible#73347

According to this thread, the new format was introduced in 2.10. Since that is the minimum supported version for Trellis, using the new format should be fine.

Additionally, as galaxy.yml is reserved for a different purpose, we should rename it too.

I'll test this to be sure 👍

@codepuncher
Copy link
Author

Ansible 2.10.0 works using the new format.

$ trellis exec ansible --version
ansible 2.10.17
  config file = /Users/lee-work/Code/wordpress/roots/trellis/ansible.cfg
  configured module search path = ['/Users/lee-work/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/lee-work/Code/wordpress/roots/trellis/.trellis/virtualenv/lib/python3.9/site-packages/ansible
  executable location = /Users/lee-work/Code/wordpress/roots/trellis/.trellis/virtualenv/bin/ansible
  python version = 3.9.13 (main, May 24 2022, 21:28:31) [Clang 13.1.6 (clang-1316.0.21.2)]

$ trellis galaxy install
Starting galaxy role install process
- downloading role 'composer', owned by geerlingguy
...
# all works

@codepuncher codepuncher changed the title fix: galaxy.yml syntax to satisfy ansible-lint Use new requirements.yml format Jul 6, 2022
@swalkinshaw
Copy link
Member

Can we just update the format for now? We can decide on the name separately. Here's some reasoning why I renamed it before: #1100

Having requirements.txt and requirements.yml seems quite confusing to me

@codepuncher
Copy link
Author

How about roles.yml then?
I am pushing for the rename as galaxy.yml is reserved for different purposes than is used in Trellis.
Using ansible-lint on galaxy.yml expects a different schema, not requirements.yml contents.

@swalkinshaw
Copy link
Member

Sorry I missed the links in #1402 (comment)

However, that's for running a Galaxy server so it's a completely different context? (and it would be config/galaxy.yml). That file would never show up in an Ansible project for an end user I don't think.

roles.yml could work though

@codepuncher
Copy link
Author

codepuncher commented Jul 7, 2022

Ah, I wasn't aware of the Galaxy server context there. Good to know.
All I can say is what ansible-lint is telling me:

# galaxy.yml
---
roles:
  - name: composer
    src: geerlingguy.composer
    version: 1.9.0

  - name: ntp
    src: geerlingguy.ntp
    version: 2.3.1

  - name: logrotate
    src: nickhammond.logrotate
    version: v0.0.5

  - name: swapfile
    src: oefenweb.swapfile
    version: v2.0.32

  - name: mailhog
    src: geerlingguy.mailhog
    version: 2.2.0
 │     schema[galaxy]Description: Additional properties are not allowed ('roles' was unexpected) Ansible [1, 1]
 │     Missing property "readme". yaml-schema: Ansible Collection Galaxy (0) [2, 1]
 │     Missing property "authors". yaml-schema: Ansible Collection Galaxy (0) [2, 1]
 │     Missing property "description". yaml-schema: Ansible Collection Galaxy (0) [2, 1]
 │     Missing property "version". yaml-schema: Ansible Collection Galaxy (0) [2, 1]
 │     Missing property "namespace". yaml-schema: Ansible Collection Galaxy (0) [2, 1]
 │     Missing property "name". yaml-schema: Ansible Collection Galaxy (0) [2, 1]
 │     Property roles is not allowed. yaml-schema: Ansible Collection Galaxy (0) [2, 1]

Even after renaming to roles.yml, ansible-lint is still giving issues.

Linter seems to be pretty set on using requirements.yml.

syntax-check  Description: A playbook must be a list of plays, got a <class 'ansible.parsing.yaml.objects.AnsibleMapping'> instead

@swalkinshaw
Copy link
Member

Thanks @codepuncher 🚀

@swalkinshaw swalkinshaw merged commit cc25e69 into roots:master Jul 15, 2022
@codepuncher codepuncher deleted the patch-1 branch July 15, 2022 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: galaxy.yml is non-standard and breaks ansible-lint
3 participants