Hi,
I have a simple playbook to install packages on my servers/virtual machines.
The package name to install is a variable, with prompt if needed.
As a default behaviour I want it to install the package on all servers, but I want to be able to override it if needed.
The problem I see (as an ansible beginner) is that I either have to set the hosts as a variable, with no default value possible and hence a systematic prompt or -e flag passed to the command, or hardcode the default value and edit the playbook when I want to install a package to a specific server only. I could also have 2 playbooks, one for installation on all servers, and one with a prompt for the hosts value.
None of those scenarios feel right. I’ve seen also that overriding the hosts value with the ansible-playbook is not seen as a good thing (https://github.com/ansible/ansible/issues/725 ). But wouldn’t default values for vars be the right solution in this case?
Thanks
Raph
PS: Of course, if you consider that a server should be reinstallable from scratch like it’s needed on EC2, this question doesn’t make sense. But from my understanding ansible doesn’t mean to limit itself to the cloud scenario.