How to gather information of all the EC2 volumes using ansible? - amazon-ec2

I am new to ansible and trying to figure out some solutions. Can someone help me with :
Getting all detailed info about all the running instances of EC2
and find out all security groups and the policies attached.
Segregate based on vpcs.
I am assuming that this can be achieved by writing playbook. Any help will be appreciated. Thanks.

Use the EC2 dynamic inventory http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script

Ansible ec2 cloud module will help you to manage AWS platform. To get information about all the instances you can use ec2_remote_facts. To go to advance level I will also recommend to read about AWS dynamic inventory.

Related

Run deck Automation script

I need a help, I am trying to write bash/shell script which will be placed in Rundeck tool. As my org has more than 10,000 severs Ec2. This is what I am expecting.
script to login into Ec2.
show output of df -h,lsblk & Java version.
Please anyone help me with the script.
You need to configure the EC2 nodes on Rundeck using a model source. To avoid configuring each EC2 node you can use the EC2 Model Source Plugin, take a look at this (check this to learn how to install plugins on Rundeck), after that you can create a job with an inline script step using a node filter pointing to your ec2 nodes.

How do deploy a virtual machine using Ansible?

I’m new to Ansible. I can create one VM using Ansible. I’d like to deploy multiple VMs at one go. I’d appreciate any references or guidelines to accomplish this.
Take a look through the cloud modules.
Which module applies to you depends on your infrastructure provider (i.e. vsphere, aws, gcp, libvirt, etc)
For example:
virt for libvirt
cloudformation for aws
vsphere_guest for vsphere
azure_rm_deployment for azure
...and many more
There are also tons of community developed roles at ansible-galaxy if the above don't quite meet your use case.

OpenStack VM creating Using Alerts from Splunk

As per my understanding, in AWS, we can combine AWS CloudWatch and AWS Elastic Beanstalk for the automation of VM creation. For example, We can configure CloudWatch to trigger an alert for certain condition and depending on that we can create/alter a VM. Is there a way to do the same with OpenStack using Terraform scripts?
Currently, we are creating and managing OpenStack VM's using terraform and ansible scripts. We have Splunk for dashboard and alerts. Is there a way to execute terraform scripts for VM's as we get an alert from Splunk? Please correct me if my understanding is wrong.
Is there a way to execute terraform scripts for VM's as we get an alert from Splunk?
AWX (or its Tower friend) will trivially(?) do that, via /api/v2/job_templates/{id}/launch/, or if there needs to be some API massaging (either to keep the credentials out of Splunk or to reshape the webhook payload) then I would guess a lambda function could do that
I would guess that if you are using terraform to drive ansible (instead of the other way around) then you could use Atlantis or TerraHub in roughly the same manner

Register consul node_meta from ec2 tags

On each of our EC2 instances, we define two tags (Name and Cluster). Is it possible to populate the node_meta of a consul agent running on the instance from the values of these tags?
In the absence of any other obvious way to do this, I've written the following Python script to interrogate EC2 metadata and output a consul config file.
https://github.com/crooks/make_consul_config
The lack of any way to do this from within consul, (despite the capability to read tags for auto-joining), leads me to wonder if there's a good reason for not doing it. Opinions will be very gratefully received.

How to debug java code in AWS cluster

We are working on Apache storm with kafka in AWS cluster.
As a developer i want to have a local environment setup to debug the code.
But i checked the prerequisites of Horton sandbox,it requires above 8GB RAM.So we thought to have debugging environment using AWS itself.
Let me know how to do debugging in AWS ot is there any best way to have sandbox with less ram or any another best procedure to follow.
Thanks for your help in advance.
Use Vagrant to manage your EC2 instances, so you can always get the nominated environment for developing
Here is the open source code:
https://github.com/mitchellh/vagrant-aws
The README gives the detail on how to set it with Vagrant.

Resources