There might be a better way to do this, but I’m unaware of it, so I’m asking the list. I have a playbook that has two parts to it:
- Pulls branch from git repo to the localhost (ie the Ansible server)
1a. compiles the code (it’s a PHAR file, so nothing too onerous) - Pushes the code to our external servers.
Part 1/1a has a hosts: entry of ‘localhost’ and part 2 has a hosts: entry for our external servers that are getting the updated code.
My question is, is there a way to abstract the second hosts: line so I can specify specific hosts/groups? IOW, if I set that hosts: line to ‘production’, is there a way to specify on the command line -i dbservers or other subset instead of manually editing that line every time?
Second question, if the above question is just wrong/bad/not sane, is there a better way to do this?