0

I am an ansible novice, kind of not quite understanding on the difference between with or without quotes for a value defined in an Ansible variable. Here is an example:

I can see for variable size, its value is "20G", which is going with double quote, interface type: "bridge" is the same. But for some other variables like target, its value is sda, why not "sda"? What is the difference on with or without quotes for the value defined by a variable?

devices:
      cpu:
        cores: 2
      memory: 4096
      storage:
        disks:
        - pool: local
          target: sda
          size: "20G"
          unit: 0
          boot: 1
      network:
        interfaces:
        - source:
            type: "bridge"
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • 4
    This is actually not an Ansible question per se, but rather a YAML question. And this have been answered before: [Do I need quotes for strings in YAML?](https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml) – β.εηοιτ.βε Sep 25 '20 at 19:42
  • 2
    This might be worth a read as well: [Learn yaml in y minutes](https://learnxinyminutes.com/docs/yaml/). Meanwhile there is a special case in ansible: when your string begins with jinja2 expansion marker (`{{`) you must quote it. But the error your get if you don't do it is fired by ansible itself, not the yaml parser. – Zeitounator Sep 25 '20 at 20:00
  • 1
    Another IMHO useful page about quoting in YAML (disclaimer: I'm the author): https://www.yaml.info/learn/quote.html – tinita Sep 26 '20 at 02:43
  • Thank you very much for the clarification, very helpful, all clear now. – Edison Wang Sep 28 '20 at 18:18

0 Answers0