YAML terminology and Ansible
-
@scottalanmiller said in YAML terminology and Ansible:
Also, Eddie likes to teach and to teach you need to know what to call it. Referring to everything as "this bit here" doesn't work well for too long.
True. The "this bit here" test is a quick way to assess your actual understanding.
-
@marcinozga said in YAML terminology and Ansible:
And why would you care about terminology? Do you intend on teaching Ansible?
It's not just about Ansible, the same basic YAML is used to define YAML based CI/CD pipelines, and it's very helpful to know the proper terminology and syntax. There are may use cases besides Ansible playbooks.
Some of the basic syntax is similar in others such as JSON, as well as scripting languages. For example, maybe you're familiar with hash tables in PowerShell? It's all connected.
-
According to the YAML spec there is no such a thing as a dictionary. That is python terminology, not YAML. Every programming language calls it a different thing like a collection, map, associative array etc.
So if you want to be precise you should look at the YAML spec.
-
@marcinozga said in YAML terminology and Ansible:
And why would you care about terminology? Do you intend on teaching Ansible? It's the end result that matters, whether your playbook or role does what you want it to do, not whether you know the terminology or not. I've been using Ansible for some years, and honestly this is the first time I run into someone mentioning "dictionary".
I've been using it since around 1.8 and I'm not sure how you haven't heard the term dictionary.
They reference it in the YAML basics of their docs: https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
-
@Pete-S said in YAML terminology and Ansible:
According to the YAML spec there is no such a thing as a dictionary. That is python terminology, not YAML. Every programming language calls it a different thing like a collection, map, associative array etc.
So if you want to be precise you should look at the YAML spec.
We'll what do you know, right there in the 3rd paragraph of the YAML spec, they refer to it exactly as hashes/dictionaries....
Why bother to comment on something you know nothing about?
-
@Obsolesce said in YAML terminology and Ansible:
@Pete-S said in YAML terminology and Ansible:
According to the YAML spec there is no such a thing as a dictionary. That is python terminology, not YAML. Every programming language calls it a different thing like a collection, map, associative array etc.
So if you want to be precise you should look at the YAML spec.
We'll what do you know, right there in the 3rd paragraph of the YAML spec, they refer to it exactly as hashes/dictionaries....
Why bother to comment on something you know nothing about?
I comment because I know it's called a dictionary in Python and dictionary is not a universal name.
And YAML is programming language agnostic. Other than that it doesn't matter to me what anyone calls it.
3.1.1. Dump
Dumping native data structures to a character stream is done using the following three stages:
Representing Native Data Structures
YAML represents any native data structure using three node kinds: sequence - an ordered series of entries; mapping - an unordered association of unique keys to values; and scalar - any datum with opaque structure presentable as a series of Unicode characters. Combined, these primitives generate directed graph structures. These primitives were chosen because they are both powerful and familiar: the sequence corresponds to a Perl array and a Python list, the mapping corresponds to a Perl hash table and a Python dictionary. The scalar represents strings, integers, dates, and other atomic data types.
-
@Pete-S said in YAML terminology and Ansible:
@Obsolesce said in YAML terminology and Ansible:
@Pete-S said in YAML terminology and Ansible:
According to the YAML spec there is no such a thing as a dictionary. That is python terminology, not YAML. Every programming language calls it a different thing like a collection, map, associative array etc.
So if you want to be precise you should look at the YAML spec.
We'll what do you know, right there in the 3rd paragraph of the YAML spec, they refer to it exactly as hashes/dictionaries....
Why bother to comment on something you know nothing about?
I comment because I know it's called a dictionary in Python and dictionary is not a universal name.
And YAML is programming language agnostic. Other than that it doesn't matter to me what anyone calls it.
3.1.1. Dump
Dumping native data structures to a character stream is done using the following three stages:
Representing Native Data Structures
YAML represents any native data structure using three node kinds: sequence - an ordered series of entries; mapping - an unordered association of unique keys to values; and scalar - any datum with opaque structure presentable as a series of Unicode characters. Combined, these primitives generate directed graph structures. These primitives were chosen because they are both powerful and familiar: the sequence corresponds to a Perl array and a Python list, the mapping corresponds to a Perl hash table and a Python dictionary. The scalar represents strings, integers, dates, and other atomic data types.
3rd paragraph of the YAML spec, go to the introduction, 3rd paragraph down....
-
@Pete-S said in YAML terminology and Ansible:
Other than that it doesn't matter to me what anyone calls it.
You are 100% free to call it whatever you want. But a key/value pair is commonly referred to as a dictionary... or a hash table which is a dictionary data type. This isn't exclusive to Python in the least.
-
@Obsolesce said in YAML terminology and Ansible:
@Pete-S said in YAML terminology and Ansible:
Other than that it doesn't matter to me what anyone calls it.
You are 100% to call it whatever you want. But a key/value pair is commonly referred to as a dictionary... or a hash table which is a dictionary data type. This isn't exclusive to Python in the least.
"Commonly referred" depends on the programming language in question. For example in many other languages it's commonly called an array or collection and never a dictionary.
If you look at the part you quoted, YAML calls it mappings.
The proper computer science terminology would be associative array.
https://en.wikipedia.org/wiki/Associative_array -
@Pete-S said in YAML terminology and Ansible:
@Obsolesce said in YAML terminology and Ansible:
@Pete-S said in YAML terminology and Ansible:
Other than that it doesn't matter to me what anyone calls it.
You are 100% to call it whatever you want. But a key/value pair is commonly referred to as a dictionary... or a hash table which is a dictionary data type. This isn't exclusive to Python in the least.
"Commonly referred" depends on the programming language in question. For example in many other languages it's commonly called an array or collection and never a dictionary.
If you look at the part you quoted, YAML calls it mappings.
The proper computer science terminology would be associative array.
https://en.wikipedia.org/wiki/Associative_arrayThe best thing to do is to call it exactly what the language or software you are referring to calls it. If Ansible wants you to create what it has named in their documentation as a dictionary in YAML, that's what you refer to it as. Otherwise, someone who is familiar with Ansible and it's documentation won't know what the hell you are talking about if you call it your own thing.
-
@Obsolesce said in YAML terminology and Ansible:
@Pete-S said in YAML terminology and Ansible:
@Obsolesce said in YAML terminology and Ansible:
@Pete-S said in YAML terminology and Ansible:
Other than that it doesn't matter to me what anyone calls it.
You are 100% to call it whatever you want. But a key/value pair is commonly referred to as a dictionary... or a hash table which is a dictionary data type. This isn't exclusive to Python in the least.
"Commonly referred" depends on the programming language in question. For example in many other languages it's commonly called an array or collection and never a dictionary.
If you look at the part you quoted, YAML calls it mappings.
The proper computer science terminology would be associative array.
https://en.wikipedia.org/wiki/Associative_arrayThe best thing to do is to call it exactly what the language or software you are referring to calls it. If Ansible wants you to create what it has named in their documentation as a dictionary in YAML, that's what you refer to it as. Otherwise, someone who is familiar with Ansible and it's documentation won't know what the hell you are talking about if you call it your own thing.
I can agree with that point of view - YAML in the context of Ansible.
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.htmlSo you'd call it dictionaries then. And lists.