Does Ansible have naming rules for roles and collections regarding the use of -
(dash) and _
(underscore)?
I noticed that since around 2019, geerlingguy only uses underscores for role names (snake_case), but the names of his older roles contain dashes (kebab-case).
For one role in the Ansible Galaxy, I encountered the following note:
NOTE: This role has been renamed from acme-sh to acme_sh to fullfill Ansible Galaxy requirements.
I then looked through the Ansible Galaxy documentation, but only found naming conventions (limitations) for namespaces, but not for role or collection names. The example on the Creating Roles page of the Ansible Galaxy documentation also uses dashes in the name:
test-role-1
.I am aware that all Ansible Builtin modules use underscores only, so strictly snake_case (as far as I have seen so far). There are probably modules that allow parameters via alias also in kebab-case (e.g. apt), but rather few.
In the Role Names section, I found this hint in the first note:
Role names are limited to lowercase word characters (i.e., a-z, 0-9) and ‘_’.
However, it is unclear to me for which places or operations this applies, because there are quite a few roles in the Ansible Galaxy with dashes in the name, likewise an
ansible-galaxy role init my-super-role
works without problems and without any hint.
Are there any Ansible or Ansible Galaxy requirements for using dashes or underscores?
Or are there official recommendations or even technical restrictions?
Is there a recommendation in general?