Replies: 11 comments 6 replies
-
Will both forms of the YAML extension, |
Beta Was this translation helpful? Give feedback.
-
The basic distinction is simpler, playbooks/task files are always lists, all other YAML files are mappings. |
Beta Was this translation helpful? Give feedback.
-
I'm 100% against file naming as the convention to detect a playbook. Ultimately this would cause yet another confusion, that will have blowback affects on core documentation that we are likely not willing to adopt. I can describe the minimal content to define a populated playbook.
or
With the above, the file is a YAML list, that has at least a Another alternative is an explicit pragma or modeline in the file. |
Beta Was this translation helpful? Give feedback.
-
I tend to agree with @sivel on this one. Moreover, I've become accustomed to maintaining a |
Beta Was this translation helpful? Give feedback.
-
I have been using |
Beta Was this translation helpful? Give feedback.
-
From extension point of view we rely on file.associations to enable either yaml extension or ansible extension and these associations doesn't guarantee that a document opened in VSCode is correctly identified with With double extension we can deterministically identify all the ansible documents and enable the ansible extension by adding the extension here. However I suggest we can add two more options to the poll which can represent all types of ansible files.
|
Beta Was this translation helpful? Give feedback.
-
@sivel Unfortunately VSCode doesn't have the capability to introspect the content of file and associate a language type (eg. ansible/YAML etc) to the opened document and that's why we have to rely on naming convention and file paths. Because of this issue most of the times ansible extension doesn’t work out of box and user have to add additional configurations to make it work. Double extension for ansible file will solve this issue easily. |
Beta Was this translation helpful? Give feedback.
-
@ssbarnea Is it possible to move this discussion to devtools repository as it affects multiple devtool projects |
Beta Was this translation helpful? Give feedback.
-
An issue with the multiple extensions is a possible conflict with collection playbooks, so if you go this route, please avoid 'playbook' and 'playbooks' as the 2nd extension, as that might end up using the wrong playbook on execution. |
Beta Was this translation helpful? Give feedback.
-
@bcoca We are sure we do not want to touch the last extension, as that must always be YAML or YML, in order to allow other editors to recognize the files. If we do anything, we would add something before it. We also identified a way to address this issue with vscode that might make the need for double extension almost obsolete, something that can be implemented in both ansible-lint and vscode. We created a task for it on ansible/vscode-ansible#582 and hopefully we should have a fix sooner. Take a look at that ticket and comment there if the proposed logic for language detection is flawed. |
Beta Was this translation helpful? Give feedback.
-
my point is with the 'before', the collection loading does not care if 'no extension' or yml or yaml are used, but the python importer (what the collection loading uses) DOES care that the .something. matches existing directories/files in the collection |
Beta Was this translation helpful? Give feedback.
-
The challange
Once recurring problem we had since Ansible was created was that tools, and sometimes people, might struggle to distinguish between a random YAML file and a playbook.
@cidrblock documented this problem few months ago, with examples of most common layouts and the their challenges. None of those layouts could be defined as optimal as all of them either did not work in all cases or required questionable alterations in configuration to make them work. To quote his conclusion:
As a directory might contain both types of files, it is impossible to reliably determine which ones are supposed to be playbooks and which ones are not.
Some people mentioned that a tool could look inside a YAML file and try to figure-out if that might be a playbook or not. That requires relatively complex and slow heuristics that can easily fail, especially if that playbook might contain typos or not being a valid YAML file just because of some mistakes introduces by the user. Effectively with an invalid file is not possible to make identification deterministic. Also some tools, editors or IDEs do not even have the ability to change file-type based on its content and they allow only the filename to be used for for determining it.
Finding a solution
We already considered the option of using a totally new file extension like
site.play
, but we decided to avoid this because it would be intrusive and will prevent editors from recognizing these files as YAML files.So the next possible solution was to use a double extension, like
site.playbook.yaml
in order to keep it still YAML while being able to determine that the file is a playbook and not something else.The best thing about using a double extension is that we can start using it right away without breaking any tool.
Deciding which double extension to use
We only need to decide which double extension we want to agree on setting as standard, so we can define the right file association patterns for it in tools that need to identify playbooks.
Take a moment and pick your favourite option from the list below, consider implications of having a little bit longer playbooks filenames.
16 votes ·
Beta Was this translation helpful? Give feedback.
All reactions