Debian Codegraph @

test/integration/targets/deprecations/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux -o pipefail
4
5 export ANSIBLE_DEPRECATION_WARNINGS=False
6
7 ansible-playbook deprecated.yml -i ../../inventory "${@}" 2>&1 | tee disabled.txt
8
9 grep "This is a warning" disabled.txt # should be visible
10
11 if grep "DEPRECATION" disabled.txt; then
12 echo "ERROR: deprecation warnings should not be visible"
13 exit 1
14 fi
15
16 export ANSIBLE_DEPRECATION_WARNINGS=True
17
18 ansible-playbook deprecated.yml -i ../../inventory "${@}"
19
20 ### check general config
21
22 # check for entry key valid, no deprecation
23 [ "$(ANSIBLE_CONFIG='entry_key_not_deprecated.cfg' ansible -m meta -a 'noop' localhost 2>&1 | grep -c 'DEPRECATION')" -eq "0" ]
24
25 # check for entry key deprecation including the name of the option, must be defined to trigger
26 [ "$(ANSIBLE_CONFIG='entry_key_deprecated.cfg' ansible -m meta -a 'noop' localhost 2>&1 | grep -c "\[DEPRECATION WARNING\]: \[testing\]deprecated option.")" -eq "1" ]
27
28 # DTFIX: fix issue with x2 deprecation and wrong pllugin attribution
29 # check for deprecation of entry itself, must be consumed to trigger
30 [ "$(ANSIBLE_TEST_ENTRY2=1 ansible -m debug -a 'msg={{q("config", "_Z_TEST_ENTRY_2")}}' localhost 2>&1 | grep -c 'DEPRECATION')" -eq "2" ]
31
32 # check for entry deprecation, just need key defined to trigger
33 [ "$(ANSIBLE_CONFIG='entry_key_deprecated2.cfg' ansible -m meta -a 'noop' localhost 2>&1 | grep -c 'DEPRECATION')" -eq "1" ]
34
35
36 ### check plugin config
37
38 # force use of the test plugin
39 export ANSIBLE_CACHE_PLUGIN_CONNECTION=/var/tmp
40 export ANSIBLE_CACHE_PLUGIN=notjsonfile
41
42 # check for plugin(s) config option and setting non deprecation
43 [ "$(ANSIBLE_CACHE_PLUGIN_TIMEOUT=1 ansible -m meta -a 'noop' localhost --playbook-dir ./ 2>&1 | grep -c 'DEPRECATION')" -eq "0" ]
44
45 # check for plugin(s) config option setting deprecation
46 [ "$(ANSIBLE_NOTJSON_CACHE_PLUGIN_TIMEOUT=1 ansible -m meta -a 'noop' localhost --playbook-dir ./ 2>&1 | grep -c 'DEPRECATION')" -eq "1" ]
47
48 # check for plugin(s) config option deprecation
49 [ "$(ANSIBLE_NOTJSON_CACHE_PLUGIN_REMOVEME=1 ansible -m meta -a 'noop' localhost --playbook-dir ./ 2>&1 | grep -c 'DEPRECATION')" -eq "1" ]
50
51 # check for the module deprecation
52 [ "$(ansible-doc willremove --playbook-dir ./ | grep -c 'DEPRECATED')" -eq "1" ]
53
54 # check for the module option deprecation
55 [ "$(ansible-doc removeoption --playbook-dir ./ | grep -c 'deprecated:')" -eq "1" ]
56
57 # check for plugin deprecation
58 [ "$(ansible-doc -t cache notjsonfile --playbook-dir ./ | grep -c 'DEPRECATED:')" -eq "1" ]
59
60 # Injection default is deprecated
61 [ "$(ANSIBLE_INJECT_FACT_VARS=1 ansible-playbook injectfacts.yml 2>&1 | grep -c 'INJECT_FACTS_AS_VARS')" -eq "0" ]
62
63 # Injection default is deprecated but not ansible_local
64 [ "$(ansible-playbook injectfacts.yml --tags alocal 2>&1 | grep -c 'INJECT_FACTS_AS_VARS')" -eq "0" ]