extract: https://ansible-book.gitbooks.io/ansible-first-book/content/yong_ming_ling_xing_chuan_di_can_shu.html
= ansible-books.io/ansible-first-book/content/yong_ming_ling_xing_chuan_di_can_shu.html
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}} p>the tasks: p>
- …
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"
The
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"
div>