Wednesday, March 8, 2023
HomeSoftware EngineeringThe right way to Go Variables to Ansible Playbook CLI

The right way to Go 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:

Possibility 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 as well learn up on Passing Variables On The Command Line (Wayback Machine hyperlink to keep up versioning)

Possibility 2 – Specify a YML file

You may as well specify a .yml file with the variables:

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

This can be enhanced with atmosphere variables:

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


Please enter your comment!
Please enter your name here

Most Popular

Recent Comments