AWS EC2 Ubuntu 19. Setting up multiple tinyproxy servers - amazon-web-services

So I'm trying to set up multiple proxy servers through tinyproxy with ubuntu on AWS. Is there a way to setup it way quicker without having to connect to each instance 1 by 1 and download the packages then setup the server? Thanks!

Seems like you are trying to find a way to run batch commands on multiple instances to provision them.
You can look into SSM Run Command to accomplish this. This will allow you to run Ansible playbooks, Shell commands, etc. on multiple instances based on tags / resource groups / manual selection.
Further reading from AWS regarding Run Command

Related

Remote update ec2 instance with docker image

I have a release of my project. I build a docker image and deploy it on an ec2 instance.
Later, when I have a new release, I would like update the docker on ec2 remotely (without accessing the machine, just executing some service).
Is there a way how to do it without ECS and ElasticBeanstalk?
If it's not possible can I somehow re-run the cfn-init script?
My Research
https://aws.amazon.com/blogs/aws/new-ec2-run-command-remote-instance-management-at-scale/
You can manage your instances remotely (i.e. make changes without manually SSHing into the instance and typing commands) by using any of the many system management services out there. AWS offers Simple Systems Manager (SSM) of which the Run Command you linked is part. AWS also offers the OpsWorks service which uses Chef. You also have other products like Ansible and SaltStack, and you can optionally integrate the use of those services with the AWS SSM service.

Powershell Automation in ec2

We are trying to automate running of multiple powershell scripts in AWS EC2 instance. Any suggestion how this can be done. These execution has to be sequential.
In order to configure state on a fresh EC2 instance, you can use 'User Data' in order to:
a. Fully provision and configure state using powershell, see:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-metadata.html#instancedata-add-user-data
b. Install an agent for a configuration management tool such as Puppet, Chef, Ansible (as mentioned in the comment above). An example of provisioning stock Window's AMI's can be followed here: http://blog.rolpdog.com/2015/09/manage-stock-windows-amis-with-ansible.html
If you wish to trigger scripts on an existing Amazon EC2 instance (or a whole fleet of instances), also consider Running PowerShell Commands or Scripts with Amazon EC2 Run Command.

How can i synchronize server config, program code in load balanced environment in AWS?

If i want to use AWS Elastic Load Balancing for hosting multiple instance in amazon web services, there are several questions i don't understand how it works:
1) how can i synchronize files (server config) between multiple instances? <br>
2) how can i synchronize files (program code) between multiple instances? <br>
3) how can i run a ssh command across all the instances at a time?
Anyone know how to do that?
In a Load Balanced environment (and this applies to AWS and any other), you'll want to develop and/or use a system that will update/replace your servers for your automatically. Don't try to do this manually, one-by-one.
Updating server configuration and program code can be done using configuration management tools. Some include:
Puppet
Ansible
Chef
Other options are to pre-make AMI images that you will use in your Auto Scaling groups. When you want to update the server config or update the program code, you can update a template EC2 instance and produce a new AMI image to use in your Auto Scaling groups.
Another option is to use something like Elastic Beanstalk. Amazon EB will manage the server configuration and application versioning and updates for you.
Finally, any combination of the above can be used too.
For your question 3, you cannot SSH across all instances at a time. The best you can probably do is have a local script that SSH's into each instance one-at-a-time and runs a remote script server-side.

Finding the services running on multiple aws ec2 instances

Is there a command in the AWS cli to get a list of services running on my ec2 instances?
Normally I log into each ec2 instance individually, and check using Linux commands such as "netstat" or "ps -eaf".
There are around 400 instances, so if I do this manually it takes quite a lot of time. If any AWS commands are there to find the services running without actually logging into the instance, it would be great.
Thanks in advance.
The AWS Command Line Interface is a tool to manage your AWS services. You cannot use AWS-CLI to manage OS-level service. With AWS-CLI, you can control multiple AWS services from the command line and automate them through scripts.
Hope it helps :-)
You might have some luck with EC2 Run Command. From their docs:
Run Command provides a simple way of automating common administrative tasks
like executing Shell scripts and commands on Linux [...]
Run Command allows you to execute these commands across multiple
instances and provides visibility into the results

Automating Git pull process on a ec2 ubuntu instances

I am running a couple of ubuntu ec2 instances, I want to run an automation script which will pull the code from Github whenever a new instance is booted from the AMI. The thing is presently I am sshing to the server and run the command git pull origin master and it will ask for password key.
How do I automate this process? So after booting the new instance from a AMI this script should:
Run
Pull the code and also the submodule
Create couple of files and configure it
Please help me to achieve it.
Thanks
This will probably take some time and configuring, but this might set you on the right path.
First, setup your ssh keys, so that you can automatically pull from a repo, without a password. Outlined here: https://help.github.com/articles/generating-ssh-keys
Next, create a startup script to issue the 'pull' command from Github. Here: https://help.ubuntu.com/community/UbuntuBootupHowto
Then save your AMI, When you start a new EC2 AMI, the script should run, pulling in your Github changes.
Also to note, make sure gits remote path is using SSH, if it is HTTPS, it will ALWAYS ask for a password.
Your best best would be to utilize the fact the Ubuntu utilizes CloudInit within its canonical image.
Using CloudInit, you can pass scripts (i.e. shell scripts) to execute at various start up stages as EC2 user-data.
It would be very easy for your to make your GIT command line sequence execute from such a script. He is link to documentation, which includes examples.
https://help.ubuntu.com/community/CloudInit
Create a user-password access to your ubuntu instance. Replicate this particular instance if you need multiple. Now you are free of the key access. If you need to automate a process in that instance cron it or send the script via ssh to that instance and let the cron to find and run it.