From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Using multi-valued variables

Using multi-valued variables

In this video, I'll tell you about multivalued variables, or array and dictionary, because that is what you use to create multivalued variables. Multivalued variables can be used in playbooks. You can also see them in outputs, such as Ansible Facts. And when using a multivalued variable, it can be written in two ways. It can be written as an array or a list and it can also be written as a dictionary or a hash. Now let's make sure you understand the terminology. Array and list is the same. Dictionary and hash is the same. The documentation is not consequent in the way how this terminology is used. You should just remember both are the same. An array is a list of items and that is useful if you want to install multiple things, if if you want to refer to multiple files and so on. A dictionary is just a collection of key-value pairs. And they have their own specific use cases. Dictionaries are used to lot-enhancable facts, a collection of key-value pairs. Just imagine all the key-value…

Contents