YAML terminology and Ansible
-
Any idiot can search Google and then copy and paste crap and actually make things at work. It does not mean they have a fucking clue what they’re actually doing.
-
@JaredBusch said in YAML terminology and Ansible:
Any idiot can search Google and then copy and paste crap and actually make things at work. It does not mean they have a fucking clue what they’re actually doing.
Also known as Script Kiddies.
People who find shit online and use it without taking the time to understand what it does and how it works.
-
Speaking to just the YAML side of things and not Ansible, you've got it pretty good, just a few minor clarifications:
-
a. hosts is a key within a dictionary, not a dictionary itself, looks like they might have just been a typo
-
c. I mean, you could think of that dictionary being named tasks, but getting technical, tasks is a key in a dictionary that has a dictionary as the value.
-
-
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.
-
@flaxking said in YAML terminology and Ansible:
Speaking to just the YAML side of things and not Ansible, you've got it pretty good, just a few minor clarifications:
- a. hosts is a key within a dictionary, not a dictionary itself, looks like they might have just been a typo
That makes sense. It wasn't a typo, and I thought it odd that hosts would be its own dictionary. In fact,
hosts: labservers
would be a key pair within the dictionary that begins with the first list item of- name: Have some fun with Ansible!
, correct?- c. I mean, you could think of that dictionary being named tasks, but getting technical, tasks is a key in a dictionary that has a dictionary as the value.
Yes, yes. And that goes along with the first point you mentioned. The key
tasks
has a value which is a list of dictionaries, each beginning with the name specified, whose keys and values define the module being used. -
@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.