github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.28k stars 4.25k forks source link

Support Ansible YAML #3114

Closed langston-barrett closed 6 years ago

langston-barrett commented 8 years ago

Since linguist supports Salt and Puppet YAML flavors, I think Ansible fits right in!

pchaigno commented 8 years ago

I took a stab at it some time ago but it's quite difficult to distinguish Ansible YAML files from ordinary YAML files with a good accuracy. This is mostly because Ansible uses the exact same file extension as ordinary YAML files :/

techdad commented 8 years ago

Even if detection is not great, just having "Ansible" as a defined "language" would allow for setting it as a manual override...

Alhadis commented 8 years ago

That may be true, but when you consider how many YAML files there are already on GitHub, and how many of them might risk misclassification as Ansible YAML, it doesn't become worth the risk. Particularly since the vast majority of users are unaware overrides even exist.

techdad commented 8 years ago

Hmm, that is a fair point. Time to log an issue to Ansible to start making playbooks and roles distinguishable somehow :)

Alhadis commented 8 years ago

How does Ansible YAML differ from normal YAML?

I'm entirely unfamiliar with the former; I keep hearing the name dropped, but have never really understood what it is...

CafeLungo commented 7 years ago

Not sure if it's related or relevant to this discussion, but our ansible projects seem to be getting identified as Erlang all of a sudden. I think they were seen as bash/shell projects before. Very strange.

ilyasotkov commented 6 years ago

@Alhadis Ansible is YAML where string values go through Jinja2 template engine. I would describe it as a Turing-complete YAML-based procedural scripting language.

It would be nice to have this implemented.

lildude commented 6 years ago

According to the Ansible documentation "Ansible YAML" is standard YAML...

From http://docs.ansible.com/ansible/latest/playbooks_intro.html#playbook-language-example:

Playbooks are expressed in YAML format (see YAML Syntax) and have a minimum of syntax, which intentionally tries to not be a programming language or script, but rather a model of a configuration or a process.

From http://docs.ansible.com/ansible/latest/YAMLSyntax.html:

We use YAML because it is easier for humans to read and write than other common data formats like XML or JSON. Further, there are libraries available in most programming languages for working with YAML.

The only deviation from standard YAML that I can see is optional the use of {{ }} within values, which won't necessarily happen in all Ansible files, and if you do use it, it still needs to be quoted so is still valid standard YAML.

A combination of the facts that...

... I'm inclined to say we can't implement "Ansible YAML" as its own language.

With all this in mind, I'm going to close this issue. If at some point in the future Ansible's YAML deviates from standard YAML sufficiently to differentiate it from standard YAML, I'm happy to accept a PR that implements unique "Ansible YAML".