Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/node_query_instance_ec2/play.yaml

raw
1 - hosts: localhost
2 gather_facts: true
3
4 roles:
5 - role: setup_node_query
6 - role: setup_ec2_facts
7 - role: setup_ec2_instance_env
8
9 module_defaults:
10 group/aws:
11 access_key: "{{ aws_access_key }}"
12 secret_key: "{{ aws_secret_key }}"
13 session_token: "{{ security_token | default(omit) }}"
14 region: "{{ aws_region }}"
15
16 vars:
17 ec2_instance_buckets:
18 name: "instance-{{ resource_prefix }}"
19 tags:
20 resource_prefix: "{{ resource_prefix }}"
21 ec2_instance_facts:
22 device_type: "EC2"
23 infra_bucket: "Compute"
24 infra_type: "PublicCloud"
25
26 tasks:
27 - block:
28 # EC2 Instances
29 - name: Create a simple ec2_instance
30 amazon.aws.ec2_instance:
31 state: running
32 name: "{{ ec2_instance_buckets.name }}"
33 instance_type: t3.nano
34 image_id: "{{ ec2_ami_id }}"
35 tags: "{{ ec2_instance_buckets.tags }}"
36 security_group: "{{ security_group_name_1 }}"
37 vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
38 wait: false
39 register: result
40
41 - name: List instances by name
42 amazon.aws.ec2_instance_info:
43 instance_ids: "{{ result.instance_ids }}"
44 register: _instances
45
46 - name: Run jq query on result data
47 ansible.builtin.set_fact:
48 node_count: "{{ _instances | to_json | aws_jq(event_node_queries.ec2_instance_info) }}"
49
50 - name: Validate result is as expected
51 ansible.builtin.assert:
52 that:
53 - node_count == expected_result
54 vars:
55 expected_result:
56 - name: "{{ ec2_instance_buckets.name }}"
57 canonical_facts:
58 id: "{{ _instances.instances.0.instance_id }}"
59 status: "{{ _instances.instances.0.state.name }}"
60 tags: "{{ _instances.instances.0.tags }}"
61 facts: "{{ ec2_instance_facts }}"
62