mirror of https://github.com/ansible/ansible.git
preserve same order as inventory manager when using host lookup (#57769)
* 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
(cherry picked from commit afb5e02c19
)
* changelog
pull/57968/head
parent
64a83a031a
commit
01386cca4a
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- inventory_hostnames lookup - use the same order for the returned hosts as the inventory manager
|
@ -0,0 +1 @@
|
||||
shippable/posix/group2
|
@ -0,0 +1,6 @@
|
||||
[group01]
|
||||
test01
|
||||
test05
|
||||
test03
|
||||
test02
|
||||
test04
|
@ -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
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook main.yml -i inventory -e "$@"
|
Loading…
Reference in New Issue