geerlingguy / ansible-role-mysql

Ansible Role - MySQL
https://galaxy.ansible.com/geerlingguy/mysql/
MIT License
1.05k stars 861 forks source link

Missing community.mysql #505

Closed giorgioma closed 1 year ago

giorgioma commented 1 year ago

I have recently updated my ansible tower to a later version (ansible [core 2.12.5.post0]) and it is now returning these messages whenever i try to run tasks

TASK [geerlingguy.mysql : include_tasks] ***************************************
fatal: [db1]: FAILED! => {"reason": "couldn't resolve module/action 'mysql_user'. This often indicates a misspelling, missing collection, or incorrect module path.\n\nThe error appears to be in '/runner/requirements_roles/geerlingguy.mysql/tasks/secure-installation.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Ensure default user is present.\n  ^ here\n"}

or

TASK [Generate database] *******************************************************
ERROR! couldn't resolve module/action 'mysql_db'. This often indicates a misspelling, missing collection, or incorrect module path.

I have manually required community.mysql in my requirements and it does seem to fix the error.

The weirder part is that on my local machine (ansible [core 2.13.6]) it does not return this error even if I don't have community.mysql installed in any of my ansible collection locations ...

Is there a way to include a collection as a galaxy role dependency? there does not seem to be any documentation on collections dependencies

By logic it should look something like this

# meta/main.yml
---
dependencies:
  - collection: community.mysql

but the docs only exaplains role dependencies

geerlingguy commented 1 year ago

In my use of Ansible, I install with pip3 install ansible, which installs default collections like community.mysql by default. Since collections can't be required by roles, it's a bit annoying that if you only install ansible-core, there's no way for me to automatically have my role suggest or require a collection... but it is what it is :(

I just recommend people install the full 'ansible' package and not ansible-core, but failing that, at least for a period of time, you'll have to manually require certain collections if you don't want the full ansible package.

geerlingguy commented 1 year ago

Also see follow-up feature request in Ansible core: https://github.com/ansible/ansible/issues/79442