-
-
Save richard-scott/0e12d7b109422bc6b30005a675017b11 to your computer and use it in GitHub Desktop.
ansible - example of dynamic even/odd groups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requirement | |
# given 2 groups (A and B), target 50% of each for code deploy | |
- hosts: localhost | |
tasks: | |
# this might need to be group_by or add_host | |
- set_fact: | |
even: "{{ groups['groupA'][::2] | union(groups['groupB'][::2] }}" | |
odd: "{{ groups['groupA'][1::2] | union(groups['groupB'][1::2] }}" | |
- hosts: even | |
roles: | |
- deploy something | |
- hosts: odd | |
roles: | |
- deploy something | |
# it may also be possible to do | |
#- hosts: even;odd | |
# serial: 50% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment