Ansible - null variables

Let's say you are using the vars plugin to create variables. Notice in this example that var2 contains null and var3 contains no value.

vars:
  var1: "Hello World"
  var2: null
  var3:

 

The debug module can be used to print the value of each variable.

- name: output the 'var1' variable
  debug:
    var: var1

- name: output the 'var2' variable
  debug:
    var: var2

- name: output the 'var3' variable
  debug:
    var: var3

 

Something like this should be returned. Notice that both var2 and var3 contain no value.

TASK [output the 'var1' variable]
ok: [server1.example.com] => {
    "var1": "Hello World"
}

TASK [output the 'var2' variable]
ok: [server1.example.com] => {
    "var2": ""
}

TASK [output the 'var3' variable]
ok: [server1.example.com] => {
    "var3": ""
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 9d758 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |