Pass parameters to the YML file, ansible playbook command



passes the parameter

from the command line

defines the command line variable

in the release.yml file, hosts and user are defined as variables that need to be passed from the command line.

  • hosts: ‘{{host}}
    remote_user:’ {{user}}

    the tasks:

    • USES the command line variable

to pass value on the command line:

 ansible-playbook e33_var_in_command.yml --extra-vars "hosts=web user=root" 


parameter can also be passed in json format:

ansible-playbook e33_var_in_command.yml --extra-vars "{'hosts':'vm-rhel7-1', 'user':'root'}" 

can also put parameters in the file:

ansible-playbook e33_var_in_command.yml --extra-vars "@vars.json"

Read More: