diff options
Diffstat (limited to 'test/integration/targets/lookup_inventory_hostnames')
4 files changed, 47 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_inventory_hostnames/aliases b/test/integration/targets/lookup_inventory_hostnames/aliases new file mode 100644 index 0000000..3005e4b --- /dev/null +++ b/test/integration/targets/lookup_inventory_hostnames/aliases @@ -0,0 +1 @@ +shippable/posix/group4 diff --git a/test/integration/targets/lookup_inventory_hostnames/inventory b/test/integration/targets/lookup_inventory_hostnames/inventory new file mode 100644 index 0000000..ca7234f --- /dev/null +++ b/test/integration/targets/lookup_inventory_hostnames/inventory @@ -0,0 +1,18 @@ +nogroup01 +nogroup02 +nogroup03 + +[group01] +test01 +test05 +test03 +test02 +test04 + +[group02] +test03 +test04 +test200 +test201 +test203 +test204 diff --git a/test/integration/targets/lookup_inventory_hostnames/main.yml b/test/integration/targets/lookup_inventory_hostnames/main.yml new file mode 100644 index 0000000..4b822e3 --- /dev/null +++ b/test/integration/targets/lookup_inventory_hostnames/main.yml @@ -0,0 +1,23 @@ +--- +- hosts: localhost + gather_facts: no + tasks: + - set_fact: + hosts_a: "{{ lookup('inventory_hostnames', 'group01', wantlist=true) }}" + hosts_b: "{{ groups['group01'] }}" + exclude: "{{ lookup('inventory_hostnames', 'group01:!test03', wantlist=true) }}" + intersect: "{{ lookup('inventory_hostnames', 'group01:&group02', wantlist=true) }}" + nogroup: "{{ lookup('inventory_hostnames', 'nogroup01', wantlist=true) }}" + doesnotexist: "{{ lookup('inventory_hostnames', 'doesnotexist', wantlist=true) }}" + all: "{{ lookup('inventory_hostnames', 'all', wantlist=true) }}" + from_patterns: "{{ lookup('inventory_hostnames', 't?s?03', wantlist=True) }}" + + - assert: + that: + - hosts_a == hosts_b + - "'test03' not in exclude" + - intersect == ['test03', 'test04'] + - nogroup == ['nogroup01'] + - doesnotexist == [] + - all|length == 12 + - from_patterns == ['test03'] diff --git a/test/integration/targets/lookup_inventory_hostnames/runme.sh b/test/integration/targets/lookup_inventory_hostnames/runme.sh new file mode 100755 index 0000000..449c66b --- /dev/null +++ b/test/integration/targets/lookup_inventory_hostnames/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook main.yml -i inventory "$@" |