ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    YAML terminology and Ansible

    Training
    yaml ansible
    9
    20
    2.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by

      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.

      DustinB3403D 1 Reply Last reply Reply Quote 2
      • DustinB3403D
        DustinB3403 @JaredBusch
        last edited by

        @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.

        1 Reply Last reply Reply Quote 1
        • F
          flaxking
          last edited by

          Speaking to just the YAML side of things and not Ansible, you've got it pretty good, just a few minor clarifications:

          1. a. hosts is a key within a dictionary, not a dictionary itself, looks like they might have just been a typo

          2. 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.

          EddieJenningsE 1 Reply Last reply Reply Quote 1
          • scottalanmillerS
            scottalanmiller
            last edited by

            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.

            EddieJenningsE 1 Reply Last reply Reply Quote 1
            • EddieJenningsE
              EddieJennings @flaxking
              last edited by

              @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:

              1. 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?

              1. 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.

              1 Reply Last reply Reply Quote 0
              • EddieJenningsE
                EddieJennings @scottalanmiller
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • ObsolesceO
                  Obsolesce @marcinozga
                  last edited by

                  @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.

                  1 Reply Last reply Reply Quote 0
                  • 1
                    1337
                    last edited by 1337

                    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.

                    ObsolesceO 1 Reply Last reply Reply Quote 1
                    • stacksofplatesS
                      stacksofplates @marcinozga
                      last edited by

                      @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

                      1 Reply Last reply Reply Quote 0
                      • ObsolesceO
                        Obsolesce @1337
                        last edited by

                        @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?

                        1 1 Reply Last reply Reply Quote 0
                        • 1
                          1337 @Obsolesce
                          last edited by 1337

                          @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.

                          ObsolesceO 2 Replies Last reply Reply Quote 0
                          • ObsolesceO
                            Obsolesce @1337
                            last edited by Obsolesce

                            @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....
                            e991ea0c-421a-4e20-954a-836f477fe674-image.png

                            1 Reply Last reply Reply Quote 0
                            • ObsolesceO
                              Obsolesce @1337
                              last edited by Obsolesce

                              @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.

                              1 1 Reply Last reply Reply Quote 0
                              • 1
                                1337 @Obsolesce
                                last edited by

                                @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

                                ObsolesceO 1 Reply Last reply Reply Quote 0
                                • ObsolesceO
                                  Obsolesce @1337
                                  last edited by

                                  @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_array

                                  The 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.

                                  1 1 Reply Last reply Reply Quote 0
                                  • 1
                                    1337 @Obsolesce
                                    last edited by 1337

                                    @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_array

                                    The 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.html

                                    So you'd call it dictionaries then. And lists.

                                    1 Reply Last reply Reply Quote 0
                                    • 1 / 1
                                    • First post
                                      Last post