Skip to content

Instantly share code, notes, and snippets.

@srgvg
Created August 5, 2016 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srgvg/bbc05198f033337cbb4b599c13839092 to your computer and use it in GitHub Desktop.
Save srgvg/bbc05198f033337cbb4b599c13839092 to your computer and use it in GitHub Desktop.
0
1
2
3
4
5
6
7
8
9
- hosts: all
gather_facts: false
#serial: 1
# serial 1 is needed to enforce is deterministic order in the grouped by group, to allow to expect the first node to be the master
# see https://github.com/ansible/ansible/issues/16933
tasks:
- group_by:
key: foobar
- hosts: all
gather_facts: false
tasks:
- debug:
var: groups.foobar
run_once: yes
serge ~/tmp/issues16933 ansible-playbook -i hosts play.yml
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [0]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [1]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [2]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [3]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [4]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [5]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [6]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [7]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [8]
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [9]
PLAY [all] *********************************************************************
TASK [debug] *******************************************************************
ok: [0] => {
"groups.foobar": [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
]
}
PLAY RECAP *********************************************************************
0 : ok=2 changed=0 unreachable=0 failed=0
1 : ok=1 changed=0 unreachable=0 failed=0
2 : ok=1 changed=0 unreachable=0 failed=0
3 : ok=1 changed=0 unreachable=0 failed=0
4 : ok=1 changed=0 unreachable=0 failed=0
5 : ok=1 changed=0 unreachable=0 failed=0
6 : ok=1 changed=0 unreachable=0 failed=0
7 : ok=1 changed=0 unreachable=0 failed=0
8 : ok=1 changed=0 unreachable=0 failed=0
9 : ok=1 changed=0 unreachable=0 failed=0
serge ~/tmp/issues16933 ansible-playbook -i hosts play.yml
PLAY [all] *********************************************************************
TASK [group_by] ****************************************************************
ok: [0]
ok: [3]
ok: [1]
ok: [2]
ok: [4]
ok: [5]
ok: [6]
ok: [7]
ok: [8]
ok: [9]
PLAY [all] *********************************************************************
TASK [debug] *******************************************************************
ok: [0] => {
"groups.foobar": [
"0",
"3",
"1",
"2",
"4",
"5",
"6",
"7",
"8",
"9"
]
}
PLAY RECAP *********************************************************************
0 : ok=2 changed=0 unreachable=0 failed=0
1 : ok=1 changed=0 unreachable=0 failed=0
2 : ok=1 changed=0 unreachable=0 failed=0
3 : ok=1 changed=0 unreachable=0 failed=0
4 : ok=1 changed=0 unreachable=0 failed=0
5 : ok=1 changed=0 unreachable=0 failed=0
6 : ok=1 changed=0 unreachable=0 failed=0
7 : ok=1 changed=0 unreachable=0 failed=0
8 : ok=1 changed=0 unreachable=0 failed=0
9 : ok=1 changed=0 unreachable=0 failed=0
ansible-playbook -i hosts play.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment