Closed codepuncher closed 2 years ago
🤔 where is this format from? Their examples reflect what we currently have: https://galaxy.ansible.com/docs/using/installing.html
New format introduced because requirements.yml
(our galaxy.yml
) now supports both roles
and collections
.
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".
.
👍 we just need to verify if the oldest supported version of Ansible supports this format
https://github.com/ansible/ansible/issues/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 👍
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
Can we just update the format for now? We can decide on the name separately. Here's some reasoning why I renamed it before: https://github.com/roots/trellis/pull/1100
Having requirements.txt
and requirements.yml
seems quite confusing to me
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.
Sorry I missed the links in https://github.com/roots/trellis/pull/1402#issuecomment-1174753620
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
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
Thanks @codepuncher 🚀
Fixes #1401