The best way to Cross Variables to Ansible Playbook CLI

If that you must 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.

It’s also possible to learn up on Passing Variables On The Command Line (Wayback Machine hyperlink to take care of versioning)

Choice 2 – Specify a YML file

It’s also possible to specify a .yml file with the variables:

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

This will also be enhanced with atmosphere variables:

    my_version: "{{ lookup('env', 'model') }}"
    my_other_variable: {{ lookup('env', 'other_variable') }}
See also  Loft Kubernetes Namespaces with Lukas Gentele

Leave a Reply