ansible/test/integration/targets/limit_inventory/runme.sh
Matt Clay c45d193af4 Rename some integration tests.
This avoids confusion with tests named `inventory_*` which do not test inventory plugins.

Tests for inventory scripts are now prefixed with `script_inventory_`.
2020-02-14 13:34:26 -08:00

31 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -eux
trap 'echo "Host pattern limit test failed"' ERR
# https://github.com/ansible/ansible/issues/61964
# These tests should return all hosts
ansible -i hosts.yml all --limit ,, --list-hosts | tee out ; grep -q 'hosts (3)' out
ansible -i hosts.yml ,, --list-hosts | tee out ; grep -q 'hosts (3)' out
ansible -i hosts.yml , --list-hosts | tee out ; grep -q 'hosts (3)' out
ansible -i hosts.yml all --limit , --list-hosts | tee out ; grep -q 'hosts (3)' out
ansible -i hosts.yml all --limit '' --list-hosts | tee out ; grep -q 'hosts (3)' out
# Only one host
ansible -i hosts.yml all --limit ,,host1 --list-hosts | tee out ; grep -q 'hosts (1)' out
ansible -i hosts.yml ,,host1 --list-hosts | tee out ; grep -q 'hosts (1)' out
ansible -i hosts.yml all --limit host1,, --list-hosts | tee out ; grep -q 'hosts (1)' out
ansible -i hosts.yml host1,, --list-hosts | tee out ; grep -q 'hosts (1)' out
# Only two hosts
ansible -i hosts.yml all --limit host1,,host3 --list-hosts | tee out ; grep -q 'hosts (2)' out
ansible -i hosts.yml host1,,host3 --list-hosts | tee out ; grep -q 'hosts (2)' out
ansible -i hosts.yml all --limit 'host1, , ,host3' --list-hosts | tee out ; grep -q 'hosts (2)' out
ansible -i hosts.yml 'host1, , ,host3' --list-hosts | tee out ; grep -q 'hosts (2)' out