Bootstrap FreeKB - Ansible - Getting Started with variables
Ansible - Getting Started with variables

Updated:   |  Ansible articles

Following are the differet ways that variables can be set in Ansible. This list is in the order of precedence, where the option higher in the list takes precedence over options lower in the list.


Precedence

Let's say you have a variable defined twice. For example, let's say the foo variable is defined in the vars plugin and contains a value of Hello.

---
- hosts: all
  vars:
    foo: "Hello"

 

Let's also say that the --extra-vars command line option is being used to set the foo variable to contain a value of World.

ansible-playbook example.yml --extra-vars "foo=World"

 

In this scenario, the foo variable would contain a value of World, because the --extra-vars command line option takes precedence over the vars plugin.

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


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