How to undefine a variable?

Help pls. I like to undefine a variable in a task.

Setting the variable value to None could be one of the ways. You can try registering a variable value to ‘None’ while running the task .

  • name: Register the value of FOO
    shell: echo VALUE
    register: FOO

  • name: Set the FOO variable value from stdout
    set_fact:
    FOO: “{{FOO.stdout}}”

Now when you access the variable FOO you will get the value None .

Thanks for the hint. Unfortunately the variable is defined by CLI with extra_vars option and set_fact is not effective to it. I think the real solution is to have set_global module, but not existing yet.