You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/inventory_limit/runme.sh

32 lines
1.3 KiB
Bash

#!/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