Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/inventory_aws_ec2/runme.sh

raw
1 #!/usr/bin/env bash
2
3 # generate inventory with access_key provided through a templated variable
4 ansible-playbook playbooks/create_environment_script.yml "$@"
5 source access_key.sh
6
7 set -eux
8
9 function cleanup() {
10 set +x
11 source access_key.sh
12 set -x
13 ansible-playbook playbooks/manage_ec2_instances.yml -e "task=tear_down" -e "teardown_route53=true" "$@"
14 exit 1
15 }
16
17 ln -s "$(pwd)/../" playbooks/roles
18
19 trap 'cleanup "${@}"' ERR
20
21 # ensure test config is empty
22 ansible-playbook playbooks/empty_inventory_config.yml "$@"
23
24 export ANSIBLE_INVENTORY_ENABLED="amazon.aws.aws_ec2"
25
26 # test with default inventory file
27 ansible-playbook playbooks/test_invalid_aws_ec2_inventory_config.yml "$@"
28
29 export ANSIBLE_INVENTORY=test.aws_ec2.yml
30
31 # test empty inventory config
32 ansible-playbook playbooks/test_invalid_aws_ec2_inventory_config.yml "$@"
33
34 # create minimal config for tests
35 ansible-playbook playbooks/manage_ec2_instances.yml -e "task=setup" "$@"
36
37 # generate inventory config and test using it
38 ansible-playbook playbooks/create_inventory_config.yml "$@"
39 ansible-playbook playbooks/test_populating_inventory.yml "$@"
40
41 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_template.yml.j2'" "$@"
42 ansible-playbook playbooks/test_populating_inventory.yml "$@"
43
44 # generate inventory config with constructed features and test using it
45 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_constructed.yml.j2'" "$@"
46 ansible-playbook playbooks/test_populating_inventory_with_constructed.yml "$@"
47 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_concatenation.yml.j2'" "$@"
48 ansible-playbook playbooks/test_populating_inventory_with_concatenation.yml "$@"
49 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_literal_string.yml.j2'" "$@"
50 ansible-playbook playbooks/test_populating_inventory_with_literal_string.yml "$@"
51 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostnames_using_tags_classic.yml.j2'" "$@"
52 ansible-playbook playbooks/test_populating_inventory_with_hostnames_using_tags_classic.yml "$@"
53 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostnames_using_tags.yml.j2'" "$@"
54 ansible-playbook playbooks/test_populating_inventory_with_hostnames_using_tags.yml "$@"
55
56 # generate inventory config with hostvars_prefix
57 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostvars_prefix_suffix.yml.j2'" -e "hostvars_prefix='aws_ec2_'" "$@"
58 ansible-playbook playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml -e "hostvars_prefix='aws_ec2_'" "$@"
59 # generate inventory config with hostvars_suffix
60 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostvars_prefix_suffix.yml.j2'" -e "hostvars_suffix='_aws_ec2'" "$@"
61 ansible-playbook playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml -e "hostvars_suffix='_aws_ec2'" "$@"
62 # generate inventory config with hostvars_prefix and hostvars_suffix
63 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostvars_prefix_suffix.yml.j2'" -e "hostvars_prefix='aws_'" -e "hostvars_suffix='_ec2'" "$@"
64 ansible-playbook playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml -e "hostvars_prefix='aws_'" -e "hostvars_suffix='_ec2'" "$@"
65
66 # generate inventory config with includes_entries_matching and prepare the tests
67 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_include_or_exclude_filters.yml.j2'" "$@"
68 ansible-playbook playbooks/test_populating_inventory_with_include_or_exclude_filters.yml "$@"
69
70 # generate inventory config with caching and test using it
71 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_use_contrib_script_keys.yml.j2'" "$@"
72 ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS=never ansible-playbook playbooks/test_populating_inventory_with_use_contrib_script_keys.yml "$@"
73
74 # generate inventory config with caching and test using it
75 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_cache.yml.j2'" "$@"
76 ansible-playbook playbooks/populate_cache.yml "$@"
77 ansible-playbook playbooks/test_inventory_cache.yml "$@"
78
79 # generate inventory config with ssm inventory information
80 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_ssm.yml.j2'" "$@"
81 ansible-playbook playbooks/test_inventory_ssm.yml "$@"
82
83 # generate inventory config with hostnames containing multiple tags and jinja2 filters (allow_duplicated_hosts=False)
84 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostnames_with_jinja2_filters.yml.j2'" -e "search_multiple_tags=true" "$@"
85 ansible-playbook playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml -e "search_multiple_tags=true" "$@"
86
87 # generate inventory config with hostnames containing multiple tags and jinja2 filters (allow_duplicated_hosts=True)
88 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostnames_with_jinja2_filters.yml.j2'" -e "allow_duplicated_hosts=true" -e "search_multiple_tags=true" "$@"
89 ansible-playbook playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml -e "allow_duplicated_hosts=true" -e "search_multiple_tags=true" "$@"
90
91 # generate inventory config with hostnames containing single tag and jinja2 filters
92 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_hostnames_with_jinja2_filters.yml.j2'" "$@"
93 ansible-playbook playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml "$@"
94
95 # generate inventory config with route53 enabled
96 ansible-playbook playbooks/test_populating_inventory_with_route53.yml "$@"
97 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_route53.yml.j2'" "$@"
98 ansible-playbook playbooks/test_inventory_route53.yml "$@"
99 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_route53.yml.j2'" -e "route53_excluded_zone=true" "$@"
100 ansible-playbook playbooks/test_inventory_route53.yml -e "match_route53_hostname=false" "$@"
101 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_route53.yml.j2'" -e "route53_hostname=.ansible.test.org" "$@"
102 ansible-playbook playbooks/test_inventory_route53.yml -e "match_route53_hostname=false" "$@"
103 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_route53.yml.j2'" -e "route53_hostname=.ansible.test" "$@"
104 ansible-playbook playbooks/test_inventory_route53.yml "$@"
105 ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_route53.yml.j2'" -e "allow_duplicated_hosts=true" "$@"
106 ansible-playbook playbooks/test_inventory_route53.yml -e "allow_duplicated_hosts=true" "$@"
107
108 # remove inventory cache
109 rm -r aws_ec2_cache_dir/
110
111 # cleanup inventory config
112 ansible-playbook playbooks/empty_inventory_config.yml "$@"
113
114 # cleanup testing environment
115 ansible-playbook playbooks/manage_ec2_instances.yml -e "task=tear_down" -e "teardown_route53=true" "$@"