-
Notifications
You must be signed in to change notification settings - Fork 3
/
aws.ec2_show.yaml
53 lines (49 loc) · 1.61 KB
/
aws.ec2_show.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- name: Show AWS EC2 Resources
hosts: localhost
gather_facts: yes
vars:
show_states: running
ec2_filters:
# "tag:project": "{{ project | default( omit ) }}"
instance-state-name: "{{ show_states | default( omit ) }}"
vars_files:
roles:
- aws_ec2_show
tasks:
- name: Show project ({{ project }})
ansible.builtin.debug:
msg: |
project: {{ project }}
- name: Get All AWS EC2 Instances
delegate_to: localhost
amazon.aws.ec2_instance_info:
# filters: {} # all EC2 instances in a region
# filters: # all EC2 instances in a tagged project
# "tag:project": "{{ project }}"
filters: # all EC2 instances in a tagged project
"tag:project": "{{ project }}"
instance-state-name: ["running"] # [ "shutting-down", "stopping", "stopped" ]
# key-name: "{{ project }}"
# vpc-id: "{{ vpc.vpcs[0].vpc_id }}"
register: ec2
- name: Show AWS EC2 Instances Table
delegate_to: localhost
when: ec2 is defined and ec2.instances is defined and ec2.instances | count > 0
vars:
head: [
# "image_id",
# "instance_id",
"instance_type",
"key_name",
"private_ip_address",
"public_ip_address",
# "security_groups",
# "state",
]
hide: [] # hide these attribute
maxw: 40 # maximum width of any column
rows: "{{ ec2.instances | flatten }}"
temp: "{{ lookup('template', 'list_of_dicts.j2') }}"
ansible.builtin.debug:
msg: "{{ temp }}"