Skip to content

Commit

Permalink
add detailed AWS report
Browse files Browse the repository at this point in the history
  • Loading branch information
adworjan committed Nov 10, 2023
1 parent 4f4d021 commit 29416a6
Show file tree
Hide file tree
Showing 20 changed files with 940 additions and 11 deletions.
18 changes: 18 additions & 0 deletions .ansible-sign/sha256sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ a9ba8167093814d5863fdd533c87d9a447418d15e03ccbf3d0d38992f56a3b2e addvmtoad.yml
334e2ea382939e200bdb588389bd93be4378b5e800a5ab25352a83c202ba4063 aws_parking_schedule.yml
015f24b8ce1526d6c238368d441d27e21ba69c31f40ed754a36b48ff0a17bc48 aws_parking_start.yml
b0b35c8cf39a7dfdb0692c8fc796dda38fdf448793d83e2503104b423a437007 aws_parking_stop.yml
8b8c3e48b0872ca247149870922aefd6c4b346b9fd5c24fff9a00d20df199f3c buildawsdetailedreport.yml
ca9718833f5c907ce6c9a3f19a4c3f349f5ed9152b489d94181c854aa7bcb2be buildlinuxreport.yml
6c6af63ec5f37ca46646e3d8e341153c62bd2277ce3eef1077e6083948adc6f0 buildwindowsreport.yml
3dbc6c472c4a6483f0bd44ee864f515e8f5aa28637e572aea60faf3dac6c6430 certificatereport.yml
Expand Down Expand Up @@ -126,7 +127,24 @@ f4b1e0d3ad05569a8b8ffc761a51ebb313f854e65883ad208e5ad77dab7d7c05 rhv_snapshot_p
d2214c71dbbaa463d8c81cbb91a881ea1e773b5ba57b8e8d2b309cf8a4d313a5 roles/aws_opt_in_start/tasks/main.yml
40b7eadb6b46de6e6571b2620be4624d2aee16ae209d0f67116a033c31cbf834 roles/aws_opt_in_stop/defaults/main.yml
fb0accc3dc53f4a533ca517de57c71ebf8752e04e3be6bf23096ec36e06bd5ad roles/aws_opt_in_stop/tasks/main.yml
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 roles/aws_retrieve_info/defaults/main.yml
a426eb8fbffc99ade4cdce996e6c18d2cec0572632ea5ec3be9cf4af9d03831b roles/aws_retrieve_info/tasks/main.yml
35ee51d3c5f69d4b6c2378de483a5b8102774b13886821296c777b5f066d07c1 roles/aws_retrieve_info/tasks/retrieve_info.yml
6c8b0dca0627067f90cf42f2eb4909022d5460bb7326949d98ce33c0232844b3 roles/aws_schedule_parking/tasks/main.yml
030b09eb3b997831369b4928ba145b5e5530999259ae60fc613e8ac17d92a812 roles/build_report_aws/README.md
85a58f5ab2fe784d4da58faa8e806d596b715dd2e956e5d24c1880bcbcbd3825 roles/build_report_aws/defaults/main.yml
4524385a1dc3d49e61a7ddb824fc73da2feafe9547a3c9a29f95de7d1c757874 roles/build_report_aws/files/aws.png
3baeb2c8ea0e5eedc04bc20c82f1b59c46e469139e6f0ba68831920dc0639d63 roles/build_report_aws/files/css/azure.css
131169581a08c7ac015462841a248157b7563e5b8c933d77fd41761188fa26e7 roles/build_report_aws/files/redhat-ansible-logo.svg
2bfe24d4f6ca202fec0c7218897bda32340ec0cfd52329d5e37297a200ca781b roles/build_report_aws/files/webpage_logo.png
8656f39933ecb711379e46f4add535d86f1b244a741f6772282523502aec253b roles/build_report_aws/meta/main.yml
6d5f8dbca37e1936b3a6ed313c594998274734355f6f7e1408d7c625cc952282 roles/build_report_aws/tasks/main.yml
bef25e2f63c4302c0bb788e1df4fd2c6942cf73511f8e194c6389b714131cc29 roles/build_report_aws/templates/ansible.j2
b8f511d60bc79650d4810b554f2902544c3f06061f42dc30e1ea49c624f5ce95 roles/build_report_aws/templates/fullreport.j2
9f323ad6ccd1e98424e82df19fc8f1a23fba135d560fa40e00e2da2be6ef8d7e roles/build_report_aws/templates/header.j2
d0e5733cc08cb2a54641fd2776477dc5b5c3ea969207e3f8985701ee9cb25087 roles/build_report_aws/templates/report.j2
6dd97b061c6e99597d170dfa49068192e29194d15b494f82c8959d81458f5539 roles/build_report_aws/templates/vpc.j2
06867d265474dce008de42804b05715a89a84a2ee90daefedc7fe16dc6dc9a8e roles/build_report_aws/vars/main.yml
c73129af3c33f30d38a2b559a156c6d82e91ed1a949cf8d16731ddab01002d98 roles/shadowman_aap_metrics/tasks/main.yml
dbf5388b362d3066031beeab1a10564fdffd6fc94b3673be4b5061c667445123 roles/shadowman_aap_metrics_api/tasks/main.yml
72ee574a67406e3fbfdf055736be4cc0e94a2453340a3dded5205e7599a50586 roles/shadowman_active_directory/tasks/main.yml
Expand Down
22 changes: 11 additions & 11 deletions .ansible-sign/sha256sum.txt.sig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-----BEGIN PGP SIGNATURE-----

iQGzBAABCAAdFiEE/bJvyFHKKJdaZDOLTiIiIXrUDNEFAmVOO3wACgkQTiIiIXrU
DNFmoAwAsb07t94Myf7VQUusaHl4zIrpghkuW47NqAvY2PyWpelsqHEJMmIc4hmT
XUlMedLTLXb8IESGDpbt29se2rSOv5lTLoos9x7TQmdPHOypHASgr8NBamha30hN
taWbj6CTTBGeWA7ELwzzuj6i5UrcMS89+zvkaA8+aZmqHjZFyF0s4caioq9PW4L2
MhGxD7AiHq5ep1JvVNXEdHxr+PiYPIWzn+QrZYZV1tssyMYF2x6C6UlWjX7n9dsU
quwiiPrfur39xeYnZHWU+Ibc6lmtkBaLBUbZsfBElcizGu30MkKTUwjhLw8qdddy
kCA1+UOnhVrmZtAw0xAaZ80648mRbqPUyA+yqtuyA4PtY62cmw66Vjs+Ztze8fUu
GxOybkYo5LTic43nw5ysmoLicb30MU8sFjDgTlE8VVPMeWDF0NIlhF1F0t3x62ya
r/1egVfrAAjnDUlgfG19mErRE6/uXvTeXbzjqirwCLylVbDMZ8xCe3DN1CxFCZIE
2kvsYJN3
=JXrW
iQGzBAABCAAdFiEE/bJvyFHKKJdaZDOLTiIiIXrUDNEFAmVOUp0ACgkQTiIiIXrU
DNHqIwv+K7rY/7Kmz5Lzpn6nYZvFksE6/ozrTjdi6k6peuXux4Rl7lDomm7oyuZQ
QawrCE+qkRKVqHvgncHGI/iYJVZYpbgEd73yWqWRA8l+TkWS39LenHrxHXgBQ1n0
9a19Hy8+OUDNXAhbfOizNo/MV6XXeT4xF7vCJZqur6TPjIOBKDuHajoQrfsje1jD
2mMCT92RREybf4S9r9W7BU9v961mAkzfq9Z14BrxD+kgh4/M2pyXmmJ7oeBAJgt/
HDDda++yR6maBE685Lw40Q8zkPDnOveqUpFNyip1XpOgpsTyJqsLRBqB3PQ5ED+W
DT8Cy9e67S1VH0uTFIe7uT7xDVxbuRgFez9WVdGqTMTV2Ndn6pQc8Veeqe6y1OVc
8JVoDf6LIgqL+b+SkGAadXv2Ywt0A7Y8DDl2dJIED9C67mfF8serEDsBi/KhlW1H
Jmk/Yd/SyzvWCh1r/MGozpPhkewcKVHae5b8YpGliOcOW3hIQsgOCIyyogrzTTFr
pG2CzVxC
=Z/Kx
-----END PGP SIGNATURE-----
15 changes: 15 additions & 0 deletions buildawsdetailedreport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Create AWS Detailed Report
hosts: localhost
tasks:

- name: Gather AWS Detailed info
ansible.builtin.include_role:
name: aws_retrieve_info

- name: Build the report
ansible.builtin.include_role:
name: build_report_aws
apply:
delegate_to: report.shadowman.dev
run_once: true
Empty file.
21 changes: 21 additions & 0 deletions roles/aws_retrieve_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Loop over all ec2 regions
ansible.builtin.include_tasks:
file: retrieve_info.yml
loop: "{{ ec2_regions }}"

- name: Grab boto version
ansible.builtin.pip:
name: boto3
register: register_boto3_version
check_mode: true

- name: Grab information about AWS user
amazon.aws.aws_caller_info:
register: whoami

- name: Save username of AWS user and boto3 version
ansible.builtin.set_fact:
aws_user: '{{ whoami.arn.split("/")[-1] }}'
boto3_version: >-
{{ lookup('pipe', ansible_playbook_python ~ ' -c "import boto3; print(boto3.__version__)"') | default('unknown') }}
30 changes: 30 additions & 0 deletions roles/aws_retrieve_info/tasks/retrieve_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- name: Retrieve vpc information for {{ item }}
amazon.aws.ec2_vpc_net_info:
region: "{{ item }}"
register: vpc_info
delegate_to: localhost

- name: Retrieve info for ec2 instances
amazon.aws.ec2_instance_info:
region: "{{ item }}"
register: ec2_instance_info
delegate_to: localhost

- name: Retrieve information about Internet Gateways IGWs
amazon.aws.ec2_vpc_igw_info:
region: "{{ item }}"
register: igw_info
delegate_to: localhost

# Dashes are not allowed as Ansible var names so we use underscores _
- name: Set facts all info for {{ item }}
ansible.builtin.set_fact:
'{{ item|replace("-", "_") }}':
vpc_info: '{{ vpc_info }}'
ec2_instance_info: '{{ ec2_instance_info }}'
igw_info: '{{ igw_info }}'

- name: Set facts all info for {{ item }}

Check failure on line 28 in roles/aws_retrieve_info/tasks/retrieve_info.yml

View workflow job for this annotation

GitHub Actions / build

jinja[spacing]

Jinja2 spacing could be improved: {{ all_ec2_regions | default ([]) + [{ item | replace('-','_'): hostvars\[inventory_hostname]\[item | replace('-','_')]}] }} -> {{ all_ec2_regions | default([]) + [{item | replace('-', '_'): hostvars\[inventory_hostname]\[item | replace('-', '_')]}] }}
ansible.builtin.set_fact:
all_ec2_regions: "{{ all_ec2_regions | default ([]) + [{ item | replace('-','_'): hostvars[inventory_hostname][item | replace('-','_')]}] }}"
57 changes: 57 additions & 0 deletions roles/build_report_aws/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
build_report_azure
========

Installs Apache and creates a report based on facts from Azure.

Requirements
------------

Must deploy to Apache server

Role Variables / Configuration
--------------

N/A

Dependencies
------------

N/A

Example Playbook
----------------

The role can be used to create an html report on Azure statistics onto an apache server.


```
---
- name: Create Cloud Report
hosts: localhost
tasks:
- name: Get list of all regions
azure.azcollection.azure_rm_resource_info:
url: "/locations"
api_version: "2020-01-01"
register: all_regions
- name: Get all networks
azure.azcollection.azure_rm_virtualnetwork_info:
register: azure_networks
- name: Get all vms
azure.azcollection.azure_rm_virtualmachine_info:
register: azure_vms
- name: Get facts for network interfaces
azure.azcollection.azure_rm_networkinterface_info:
register: network_interfaces
- name: Build the report
ansible.builtin.include_role:
name: shadowman.reports.build_report_azure
apply:
delegate_to: report.shadowman.dev
run_once: true
```
2 changes: 2 additions & 0 deletions roles/build_report_aws/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
usesingletemplate: false
Binary file added roles/build_report_aws/files/aws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 29416a6

Please sign in to comment.