I’m having trouble figuring out the “Ansible way” of handling groups of servers with overlapping roles. By overlapping I mean that a playbook for a type of application server (e.g. haproxy) will deploy to servers in two different cloud environments, and each cloud environment has its own set of “common” configuration tasks. So each server gets one of two different common setup roles, plus one of N application roles.
/inventory/production:
[hap-a]
1.2.3.4 etc.
[hap-b]
2.3.4.5 etc.
[cloud1:children]
[hap-a]
[etc]
[cloud2:children]
[hap-b]
[etc]
/playbook.yml:
- name: HAProxy
hosts: - hap-a
- hap-b
user: somebody
sudo: yes
roles:
-
{ role: common-?, tags: [ ‘common’ ] }
-
{ role: haproxy, tags: [ ‘haproxy’ ] }
My problem is that there need to be two “common” roles, one for cloud1 and one for cloud2. What’s the latest “best practice” for this? I’d like to avoid using “limit” in the command line so that I don’t have to execute the same playbook twice with different arguments. Thanks.