How can I pass variable to ansible playbook in the command line?

后端 未结 10 1929
不知归路
不知归路 2021-01-29 21:57

I\'m new to ansible and wonder how to do so as the following didn\'t work

ansible-playbook -i \'10.0.0.1,\' yada-yada.yml --tags \'loaddata\' django_fixtures=\"t         


        
10条回答
  •  梦毁少年i
    2021-01-29 22:15

    ansible-playbook test.yml --extra-vars "arg1=${var1} arg2=${var2}"
    

    In the yml file you can use them like this

    ---
    arg1: "{{ var1 }}"
    arg2: "{{ var2 }}"
    

    Also, --extra-vars and -e are the same, you can use one of them.

提交回复
热议问题