preserve same order as inventory manager when using host lookup (#55331)

* preserve same order as inventory manager when using inventory_hostnames lookup

add a test

* move generic code
This commit is contained in:
Sloane Hertel
2019-04-18 15:54:03 -04:00
committed by Brian Coca
parent 0330ea616e
commit afb5e02c19
7 changed files with 37 additions and 3 deletions

View File

@@ -0,0 +1 @@
shippable/posix/group2

View File

@@ -0,0 +1,6 @@
[group01]
test01
test05
test03
test02
test04

View File

@@ -0,0 +1,13 @@
---
- hosts: localhost
gather_facts: no
tasks:
- set_fact:
hosts_a: "{{ lookup('inventory_hostnames', 'group01', wantlist=true) }}"
- set_fact:
hosts_b: "{{ groups['group01'] }}"
- assert:
that:
- hosts_a == hosts_b

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -eux
ansible-playbook main.yml -i inventory -e "$@"