Thursday, March 9, 2023
HomeSoftware EngineeringFind out how to Cross Variables to Ansible Playbook CLI

Find out how to Cross Variables to Ansible Playbook CLI


If it is advisable go a variable to Ansible playbook, utilizing the command line, then you are able to do the next:

Choice 1 – Specifying command line arguments

ansible-playbook launch.yml --extra-vars "model=1.23.45 other_variable=foo"

N.B. --extra-vars specified variables will override any variables with the identical identify outlined contained in the playbook.

You may also learn up on Passing Variables On The Command Line (Wayback Machine hyperlink to take care of versioning)

Choice 2 – Specify a YML file

You may also specify a .yml file with the variables:

vars:
    my_version: "{{ model }}"
    my_other_variable: {{ other_variable }}

This may also be enhanced with setting variables:

vars:
    my_version: "{{ lookup('env', 'model') }}"
    my_other_variable: {{ lookup('env', 'other_variable') }}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments