Rick Elrod 2 weeks ago committed by GitHub
commit b544852995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,8 @@
[proxies.hosts]
local001 = {}
[proxies.vars]
ansible_connection = "local"
[web]
children = ["proxies"]

@ -0,0 +1,5 @@
@all:
|--@ungrouped:
|--@web:
| |--@proxies:
| | |--local001

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eux
# Virtualenv without toml, to ensure the toml plugin throws properly.
source virtualenv-isolated.sh
# And install enough deps in the venv to run ansible...
pip install --upgrade pip
pip install -r "$OUTPUT_DIR/../../../../requirements.txt" -c "$OUTPUT_DIR/../../../lib/ansible_test/_data/requirements/constraints.txt" --disable-pip-version-check
# This should never be installed in the isolated venv, but just to be safe...
pip list | grep '^toml\W' && pip uninstall -y toml
missing_toml="$(ansible -i test1.toml -m ping all -vvv 2>&1)"
grep -q "Failed to parse.*" <<< "$missing_toml"
grep -q ".*TOML inventory plugin requires.*" <<< "$missing_toml"
grep -q "python \"toml\" library" <<< "$missing_toml"
# `deactivate` fails but would probably break ansible-test --venv anyway
# that is why this is in its own script that runs in a subshell.

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -eux
# Virtualenv without toml
source virtualenv-isolated.sh
# And install enough deps in the venv to run ansible...
pip install --upgrade pip
pip install -r "$OUTPUT_DIR/../../../../requirements.txt" -c "$OUTPUT_DIR/../../../lib/ansible_test/_data/requirements/constraints.txt" --disable-pip-version-check
# This should never be installed in the isolated venv, but just to be safe...
pip list | grep '^toml\W' && pip uninstall -y toml
# And install an old toml
pip install 'toml<0.10'
adhoc="$(ansible -i test1.toml -m ping --connection=local -e ansible_python_interpreter="{{ ansible_playbook_python }}" all -v)"
for i in $(seq -f '%03g' 1 4); do
grep -qE "local${i} \| SUCCESS.*\"ping\": \"pong\"" <<< "$adhoc"
done
ansible_inventory="$(ansible-inventory -i test1.toml --list)"
grep -q "\"local004\": {" <<< "$ansible_inventory"
ansible_inventory_toml="$(ansible-inventory -i test1.toml --list --toml)"
grep -q "\[mygroup.hosts.local001\]" <<< "$ansible_inventory_toml"
grep -q "ansible_connection = \"local\"" <<< "$ansible_inventory_toml"
# `deactivate` fails but would probably break ansible-test --venv anyway
# that is why this is in its own script that runs in a subshell.

@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -eux
source virtualenv.sh
pip install toml
export ANSIBLE_INVENTORY_ENABLED=toml
# A few things to make it easier to grep against adhoc
export ANSIBLE_LOAD_CALLBACK_PLUGINS=True
export ANSIBLE_STDOUT_CALLBACK=oneline
adhoc="$(ansible -i test1.toml -m ping --connection=local -e ansible_python_interpreter="{{ ansible_playbook_python }}" all -v)"
for i in $(seq -f '%03g' 1 4); do
grep -qE "local${i} \| SUCCESS.*\"ping\": \"pong\"" <<< "$adhoc"
done
bad_ext="$(ansible -i foo.nottoml -m ping all -vvv 2>&1)"
grep -q "toml declined parsing" <<< "$bad_ext"
doesnotexist="$(ansible -i doesnotexist.toml -m ping all -vvv 2>&1)"
grep -q "toml declined parsing" <<< "$doesnotexist"
empty="$(ansible -i empty.toml -m ping all -vvv 2>&1)"
grep -q "Failed to parse.*" <<< "$empty"
grep -q "Parsed empty TOML file" <<< "$empty"
plugin="$(ansible -i plugin.toml -m ping all -vvv 2>&1)"
grep -q "Failed to parse.*" <<< "$plugin"
grep -q "Plugin configuration TOML file" <<< "$plugin"
grep -q "not TOML inventory" <<< "$plugin"
malformed="$(ansible -i malformed.toml -m ping all -vvv 2>&1)"
grep -q "Failed to parse.*" <<< "$malformed"
grep -q "name found without" <<< "$malformed"
invalid_group="$(ansible -i invalid_group.toml -m ping all -vvv 2>&1)"
grep -q "Skipping 'invalid_group'" <<< "$invalid_group"
unexp_vars="$(ansible -i invalid_group_vars.toml -m ping all -vvv 2>&1)"
grep -q "Invalid \"vars\" entry for \"mygroup\"" <<< "$unexp_vars"
unexp_children="$(ansible -i invalid_group_children.toml -m ping all -vvv 2>&1)"
grep -q "Invalid \"children\" entry for \"mygroup\"" <<< "$unexp_children"
unexp_key="$(ansible -i invalid_group_key.toml -m ping all -vvv 2>&1)"
grep -q "Skipping unexpected key \"something\"" <<< "$unexp_key"
invalid_hosts="$(ansible -i invalid_group_hosts.toml -m ping all -vvv 2>&1)"
grep -q "Invalid \"hosts\" entry for \"mygroup\" group" <<< "$invalid_hosts"
ansible-inventory -i children.toml --graph 2>&1 | diff -u - children_graph.txt
# needs #74234
bash missing_toml_venv.sh
bash old_toml_venv.sh

@ -0,0 +1,8 @@
[mygroup.vars]
ansible_connection = "local"
[mygroup.hosts]
local001 = {}
local002 = {}
local003 = {}
local004 = {}
Loading…
Cancel
Save