| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
set -eux |
| 4 |
|
| 5 |
export ANSIBLE_ROLES_PATH=./roles |
| 6 |
export ANSIBLE_GATHERING=explicit |
| 7 |
|
| 8 |
function gen_task_files() { |
| 9 |
for i in $(printf "%03d " {1..39}); do |
| 10 |
echo -e "- name: Hello Message\n debug:\n msg: Task file ${i}" > "tasks/hello/tasks-file-${i}.yml" |
| 11 |
done |
| 12 |
} |
| 13 |
|
| 14 |
## Adhoc |
| 15 |
|
| 16 |
ansible -m include_role -a name=role1 localhost |
| 17 |
|
| 18 |
## Import (static) |
| 19 |
|
| 20 |
# Playbook |
| 21 |
ansible-playbook playbook/test_import_playbook.yml -i inventory "$@" |
| 22 |
|
| 23 |
ANSIBLE_STRATEGY='linear' ansible-playbook playbook/test_import_playbook_tags.yml -i inventory "$@" --tags canary1,canary22,validate --skip-tags skipme |
| 24 |
|
| 25 |
# Tasks |
| 26 |
ANSIBLE_STRATEGY='linear' ansible-playbook tasks/test_import_tasks.yml -i inventory "$@" |
| 27 |
ANSIBLE_STRATEGY='free' ansible-playbook tasks/test_import_tasks.yml -i inventory "$@" |
| 28 |
ANSIBLE_STRATEGY='free' ansible-playbook tasks/test_import_tasks_tags.yml -i inventory "$@" --tags tasks1,canary1,validate |
| 29 |
|
| 30 |
# Role |
| 31 |
ANSIBLE_STRATEGY='linear' ansible-playbook role/test_import_role.yml -i inventory "$@" |
| 32 |
ANSIBLE_STRATEGY='free' ansible-playbook role/test_import_role.yml -i inventory "$@" |
| 33 |
|
| 34 |
|
| 35 |
## Include (dynamic) |
| 36 |
|
| 37 |
# Tasks |
| 38 |
ANSIBLE_STRATEGY='linear' ansible-playbook tasks/test_include_tasks.yml -i inventory "$@" |
| 39 |
ANSIBLE_STRATEGY='free' ansible-playbook tasks/test_include_tasks.yml -i inventory "$@" |
| 40 |
ANSIBLE_STRATEGY='free' ansible-playbook tasks/test_include_tasks_tags.yml -i inventory "$@" --tags tasks1,canary1,validate |
| 41 |
|
| 42 |
# Role |
| 43 |
ANSIBLE_STRATEGY='linear' ansible-playbook role/test_include_role.yml -i inventory "$@" |
| 44 |
ANSIBLE_STRATEGY='free' ansible-playbook role/test_include_role.yml -i inventory "$@" |
| 45 |
|
| 46 |
# https://github.com/ansible/ansible/issues/68515 |
| 47 |
ansible-playbook -v role/test_include_role_vars_from.yml 2>&1 | tee test_include_role_vars_from.out |
| 48 |
test "$(grep -E -c 'Expected a string for vars_from but got' test_include_role_vars_from.out)" = 1 |
| 49 |
|
| 50 |
## Max Recursion Depth |
| 51 |
# https://github.com/ansible/ansible/issues/23609 |
| 52 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_role_recursion.yml -i inventory "$@" |
| 53 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_role_recursion_fqcn.yml -i inventory "$@" |
| 54 |
|
| 55 |
## Nested tasks |
| 56 |
# https://github.com/ansible/ansible/issues/34782 |
| 57 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_nested_tasks.yml -i inventory "$@" |
| 58 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_nested_tasks_fqcn.yml -i inventory "$@" |
| 59 |
ANSIBLE_STRATEGY='free' ansible-playbook test_nested_tasks.yml -i inventory "$@" |
| 60 |
ANSIBLE_STRATEGY='free' ansible-playbook test_nested_tasks_fqcn.yml -i inventory "$@" |
| 61 |
|
| 62 |
## Tons of top level include_tasks |
| 63 |
# https://github.com/ansible/ansible/issues/36053 |
| 64 |
# Fixed by https://github.com/ansible/ansible/pull/36075 |
| 65 |
gen_task_files |
| 66 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_copious_include_tasks.yml -i inventory "$@" |
| 67 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_copious_include_tasks_fqcn.yml -i inventory "$@" |
| 68 |
ANSIBLE_STRATEGY='free' ansible-playbook test_copious_include_tasks.yml -i inventory "$@" |
| 69 |
ANSIBLE_STRATEGY='free' ansible-playbook test_copious_include_tasks_fqcn.yml -i inventory "$@" |
| 70 |
rm -f tasks/hello/*.yml |
| 71 |
|
| 72 |
# Included tasks should inherit attrs from non-dynamic blocks in parent chain |
| 73 |
# https://github.com/ansible/ansible/pull/38827 |
| 74 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_grandparent_inheritance.yml -i inventory "$@" |
| 75 |
ANSIBLE_STRATEGY='linear' ansible-playbook test_grandparent_inheritance_fqcn.yml -i inventory "$@" |
| 76 |
|
| 77 |
# undefined_var |
| 78 |
ANSIBLE_STRATEGY='linear' ansible-playbook undefined_var/playbook.yml -i inventory "$@" |
| 79 |
ANSIBLE_STRATEGY='free' ansible-playbook undefined_var/playbook.yml -i inventory "$@" |
| 80 |
|
| 81 |
# include_ + apply (explicit inheritance) |
| 82 |
ANSIBLE_STRATEGY='linear' ansible-playbook apply/include_apply.yml -i inventory "$@" --tags foo |
| 83 |
set +e |
| 84 |
OUT=$(ANSIBLE_STRATEGY='linear' ansible-playbook apply/import_apply.yml -i inventory "$@" --tags foo 2>&1 | grep 'Invalid options for import_tasks: apply') |
| 85 |
set -e |
| 86 |
if [[ -z "$OUT" ]]; then |
| 87 |
echo "apply on import_tasks did not cause error" |
| 88 |
exit 1 |
| 89 |
fi |
| 90 |
|
| 91 |
ANSIBLE_STRATEGY='linear' ANSIBLE_PLAYBOOK_VARS_ROOT=all ansible-playbook apply/include_apply_65710.yml -i inventory "$@" |
| 92 |
ANSIBLE_STRATEGY='free' ANSIBLE_PLAYBOOK_VARS_ROOT=all ansible-playbook apply/include_apply_65710.yml -i inventory "$@" |
| 93 |
|
| 94 |
# Test that duplicate items in loop are not deduped |
| 95 |
ANSIBLE_STRATEGY='linear' ansible-playbook tasks/test_include_dupe_loop.yml -i inventory "$@" | tee test_include_dupe_loop.out |
| 96 |
test "$(grep -c '"item=foo"' test_include_dupe_loop.out)" = 3 |
| 97 |
ANSIBLE_STRATEGY='free' ansible-playbook tasks/test_include_dupe_loop.yml -i inventory "$@" | tee test_include_dupe_loop.out |
| 98 |
test "$(grep -c '"item=foo"' test_include_dupe_loop.out)" = 3 |
| 99 |
|
| 100 |
ansible-playbook public_exposure/playbook.yml -i inventory "$@" |
| 101 |
ansible-playbook public_exposure/no_bleeding.yml -i inventory "$@" |
| 102 |
ansible-playbook public_exposure/no_overwrite_roles.yml -i inventory "$@" |
| 103 |
|
| 104 |
# https://github.com/ansible/ansible/pull/48068 |
| 105 |
ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook run_once/playbook.yml "$@" |
| 106 |
|
| 107 |
# https://github.com/ansible/ansible/issues/48936 |
| 108 |
ansible-playbook -v handler_addressing/playbook.yml 2>&1 | tee test_handler_addressing.out |
| 109 |
test "$(grep -E -c 'include handler task|The requested handler '"'"'do_import'"'"' was not found' test_handler_addressing.out)" = 2 |
| 110 |
|
| 111 |
# https://github.com/ansible/ansible/issues/49969 |
| 112 |
ansible-playbook -v parent_templating/playbook.yml 2>&1 | tee test_parent_templating.out |
| 113 |
test "$(grep -E -c 'Templating the path of the parent include_tasks failed.' test_parent_templating.out)" = 0 |
| 114 |
|
| 115 |
# https://github.com/ansible/ansible/issues/54618 |
| 116 |
ansible-playbook test_loop_var_bleed.yaml "$@" |
| 117 |
|
| 118 |
# https://github.com/ansible/ansible/issues/56580 |
| 119 |
ansible-playbook valid_include_keywords/playbook.yml "$@" |
| 120 |
|
| 121 |
# https://github.com/ansible/ansible/issues/64902 |
| 122 |
ansible-playbook tasks/test_allow_single_role_dup.yml 2>&1 | tee test_allow_single_role_dup.out |
| 123 |
test "$(grep -c 'ok=3' test_allow_single_role_dup.out)" = 1 |
| 124 |
|
| 125 |
# Test allow_duplicate with include_role and import_role |
| 126 |
test "$(ansible-playbook tasks/test_dynamic_allow_dup.yml --tags include | grep -c 'Tasks file inside role')" = 2 |
| 127 |
test "$(ansible-playbook tasks/test_dynamic_allow_dup.yml --tags import | grep -c 'Tasks file inside role')" = 2 |
| 128 |
|
| 129 |
# test templating public, allow_duplicates, and rolespec_validate |
| 130 |
ansible-playbook tasks/test_templating_IncludeRole_FA.yml 2>&1 | tee IncludeRole_FA_template.out |
| 131 |
test "$(grep -c 'ok=6' IncludeRole_FA_template.out)" = 1 |
| 132 |
test "$(grep -c 'failed=0' IncludeRole_FA_template.out)" = 1 |
| 133 |
|
| 134 |
# https://github.com/ansible/ansible/issues/66764 |
| 135 |
ANSIBLE_HOST_PATTERN_MISMATCH=error ansible-playbook empty_group_warning/playbook.yml |
| 136 |
|
| 137 |
ansible-playbook test_include_loop.yml "$@" |
| 138 |
ansible-playbook test_include_loop_fqcn.yml "$@" |
| 139 |
|
| 140 |
ansible-playbook include_role_omit/playbook.yml "$@" |
| 141 |
|
| 142 |
# Test templating import_playbook, import_tasks, and import_role files |
| 143 |
ansible-playbook playbook/test_templated_filenames.yml -e "pb=validate_templated_playbook.yml tasks=validate_templated_tasks.yml tasks_from=templated.yml" "$@" | tee out.txt |
| 144 |
cat out.txt |
| 145 |
test "$(grep out.txt -ce 'In imported playbook')" = 2 |
| 146 |
test "$(grep out.txt -ce 'In imported tasks')" = 3 |
| 147 |
test "$(grep out.txt -ce 'In imported role')" = 3 |
| 148 |
|
| 149 |
# https://github.com/ansible/ansible/issues/73657 |
| 150 |
ansible-playbook issue73657.yml 2>&1 | tee issue73657.out |
| 151 |
test "$(grep -c 'SHOULD_NOT_EXECUTE' issue73657.out)" = 0 |
| 152 |
|
| 153 |
# https://github.com/ansible/ansible/issues/83874 |
| 154 |
ansible-playbook test_null_include_filename.yml 2>&1 | tee test_null_include_filename.out |
| 155 |
test "$(grep -c 'No file specified for ansible.builtin.include_tasks' test_null_include_filename.out)" = 1 |
| 156 |
test "$(grep -c '.*/include_import/null_filename/tasks.yml:4:3.*' test_null_include_filename.out)" = 1 |
| 157 |
test "$(grep -c '\- name: invalid include_task definition' test_null_include_filename.out)" = 1 |
| 158 |
|
| 159 |
# https://github.com/ansible/ansible/issues/69882 |
| 160 |
set +e |
| 161 |
ansible-playbook test_nested_non_existent_tasks.yml 2>&1 | tee test_nested_non_existent_tasks.out |
| 162 |
set -e |
| 163 |
test "$(grep -c 'Could not find or access' test_nested_non_existent_tasks.out)" = 2 |