Hi,
Yes.
You can do ansible-playbook -e @parameters.yml, where variables will be loaded on the command line.
Alternatively, and this is the original way, you could do -e “servers=all”.
The other thing to look into is “–limit”, where you just keep the server value as what you have, and “–limit” selects a subset of the original, for example
ansible-playbook foo.yml --limit boston
If foo.yml originally targetted “all webservers”, this would only target webservers that were also in the group “boston”
In what you have based above, one minor syntax tweak. You should have:
hosts: “{{ servers }}”
As otherwise YAML will see the “{” and suspect you are starting a hash value.
Hi Michael,
Thank you for your reply. I tried:
hosts: ‘{{servers}}’
It works too. Is there any difference between using single or double quote?
Not in that case, the yaml parser doesn’t treat them differently.
There’s no difference.
–Michael