DEPLOYING A PLAY APPLICATION(SCALA) WITH ANSIBLE ON AWS

Sugandha Arora
Knoldus - Technical Insights
2 min readOct 12, 2018

In this blog, I will be demonstrating how to create an AWS instance and how to deploy your play application on that AWS instance using Ansible.

First let’s see how to make an AWS instance:-

  1. Login to AWS console
  2. Click on launch instance on top and select the free instance
  3. Select the machine which you want to set up.
  4. Click on Configure Instance Details -> Select the number of instances -> Click Add Storage ->Add tags ->Next configure Security group
  5. Here we have to add a rule as our play application works on 9000 port
  6. Click on Add Rule ->Select Type =Custom TCP Port, Port Range=9000, Source= Anywhere and click Review and launch.
  7. Here you will get a key pair to log in to your machine. Download it so that in future you can use it.
  8. Now make an ssh connection with your machine

Command ssh -i abc.pem ec2-user@IP

Here abc.pem is the key which you have Downloaded and IP is the IP of your machine.

Now open your terminal and write command to create an executable file.

Command sbt dist

This command will create a zip file in ./target/universal/ folder

Now let’s see the script that we will write to deploy the application on AWS.

Here I have used the

stat module:- to see whether the file exists or not and store the result in variable stat_result which I have used in the next task.

If the file is found then I skip the task else I have used

unarchive module:- to copy and extract the zip file in target destination.

Now to deploy play website I have used

action plugin: which is used to run my desired task in the background.

Async:is used to asynchronous complete the task.

polling:- is in how much time should I poll to see whether the task is completed or not.

Now we can run our application on IP:9000 port.

Originally published at blog.knoldus.com on October 12, 2018.

--

--