Ansible: Variables

Table of contents

No heading

No headings in the article.

Just started learning about Ansible. Thought to share the knowledge by using this blog space :)

Ansible is an important configuration management tool. There are multiple ways of defining the variables in Ansible.

Different types of variables:

Command line variables: As the name suggests, these variables are defined in the command line while executing the ansible playbook. The variable defined at this stage has the highest precedence among other variables.

The command line variables are defined using the -e option while calling the playbook.

In the below demonstration, we are passing the value of the variable "name" in the command line which will be used in the playbook.

The firstblog.yml playbook will get the value of the name from the command line.

Run the command "ansible-playbook firstblog.yml -e name=SAHIL"

Successful !! The variable value has been read from the command line.

Will continue ....