I'm setting up a Github master/slave configuration via Ansible role.I set up my github inventory file looks like this
[github1]
github1.domain.com
[github2]
github2.domain.com
[github3]
github3.domain.com
(more node host groups)
[github1:vars]
master=github1
slaves=['github2', 'github3']
(more vars similar to above, denoting master and slaves of other nodes)
I run my playbook this way
$ ansible-playbook inventory/github github-install.yml -l github1
and my playbook looks like
---
- hosts: github
vars:
upgrade_master_only: no
upgrade_slaves_only: on
# I know script from this point on doesn't work, this is just pseudo-code to convey the idea
tasks:
group_by:
key: gh_{{ master }}
key: gh_{{ slaves }}
# Upgrade the master node, unless user elects to only upgrade slaves
- hosts: gh_master
roles:
- {role: github-master, when: not upgrade_slaves_only }
# Upgrade all slave nodes, unless user elects to only upgrade the master
- hosts: gh_slaves
roles:
- {role: github-slaves, when: not upgrade_master_only }
My question is, how can I make the group_by work to give me a group that contains the github1 master, and another group that contains the github1 slaves?
I hope that makes sense.