How to programmatically run ansible playbook using aws_ssm connection plugin in python - plugins

There are multiple examples to run ansible playbook using PlaybookExecutor using SSH connection. But I'm unable to find any example that uses aws_ssm connection plugin to run ansible playbook. Can anyone provide an example of it?

Related

Azure Pipelines local PostgreSQL server on agent

I've started using Azure Pipelines, and my django application runs tests which require a local PostgreSQL server.
I'm pretty stumped as I cannot find any information in the MS documentation for how to change the agents configuration to include a local PostgreSQL server.
It seems like a very simple thing to do but I cannot seem to find the relevant documentation. Looking at the agent pool information it lists MySQL as being installed locally.
How can I include a local PostgreSQL server in the configuration of the agent that will build my application and run tests?
Some options:
Create a Docker container with your testing prerequisites in it, and then run your tests in the container
Create your own self-hosted agent and install whatever software you need on it, and then use that instead of the Microsoft-hosted agents.

wildfly10 add module using HTTP managment API

Is it possible to add module using wildfly HTTP management API?
I'm trying to recreate CLI command:
module add --name=com.oracle.jdbc --resources=/home/xyz/com/oracle/jdbc/main/ojdbc-7.jar
Unfortunately it's not. The module command only works on CLI and it only works if you're running the command from same server/workstation that WildFly is located on. It copies the file itself and writes the module.xml.

swift Perfect server deployment in Amazon AWS Buildpack

Am trying to deploy my web service written in swift, I don't see the web-root folder and not sure where to create the folder. Anybody have tried, please help me to copy the source code and start the server.
so, can you tell me what you have done so far, in relation to getting the AWS instance up and running ? Did you use the AWS instructions from here?
Once you have the instance up and running, there are several ways to deploy your code, such as a git pull. By default, the webroot folder for the PerfectServer is created in the current working directory when you run the app. There are several command line options to define the location of libraries, server port and location of webroot.
With more information, I'd be happy to help get you running.

Deploying Golang Applications to AWS OPSWORKS

Over the last few months I've become familiar with the AWS OpsWorks deployment process as it pertain to Node.js - deployment for Go seems to be another animal.
From what I've gathered, this is what I need to compile a successful Go deployment:
Install go on the EC2 box
Pull the private repository from GitHub
Pull in all dependencies
Compile the main package for the box's arch
Start the binary with a couple of flags that I use
Everywhere I have read seems to tout the ease of Go deployments because dependencies are included in the binary, but that seems to imply that you are compiling the application in your development environment and pushing that up to the cloud. This doesn't seem like a process that works well across a development team.
https://github.com/crowdmob/chef-golang-web-server-cookbook
I have been attempting to get the Chef Scripts from CrowdMob working, but to no avail. I continue to get errors that look like this:
[2014-08-01T16:08:22+00:00] WARN: Cookbook 'templates' is empty or entirely chefignored at /opt/aws/opsworks/current/merged-cookbooks/templates
What is the proper way to deal with dependencies during deployment?
Are there any established practices for deploying Go onto AWS with Chef?
Use a continuous integration service like CircleCi, Travis or your own setup Jenkins.
On the Continuous integration service then
Add a github post commit hook .
Test / Build the binary
Create the zip file as artifact
At this point you can create an new version on Elastic Beanstalk using the AWS commandline and the zip file created from this version.
venv/bin/aws elasticbeanstalk create-application-version ...
Then just select which version to deploy from the EB dashboard.
For simple services using Chef is overkill IMHO. Docker offers a simple workflow.
Use the Docker container option and then use elastic beanstalk's command-line client to initialize your environment in the project root directory and then you can simply do a 'git aws.push' from the same place.
With the correctly configured Dockerfile in your project and pushed to eb, the EBS' docker container app will pull the correct image with golang installed, then do a go get on your projects dependencies, and then compile and run your app. It sounds way more complicated but it's actually very easy.
Below is a link to a video walkthrough I did for running a simple golang webapp on EBS. The method for uploading the project does not use git. Instead, I zip it up and upload it, but the git method is recommended (and I do it) for automating deployment.
YouTube: How to run a go web app on Amazon's Elastic Beanstalk
I also had some problems to setup a good building process with Elastic Beanstalk and Go.. I don't want to use Docker, and all the people seems to be going on this direction.. so.. you can take a look at this project: https://github.com/battle-arena/heimdall
There you will find a custom setup using the Buildfile and the Procfile.. and I rely on a CI system to build the release package...
Basically I do the following:
Hook the commits to a CI system
On the CI system I run the test and the install.sh if all good
The install.sh will create a build folder and a structure that will be sended to the Elastic Beanstalk with the aws-cli tool
After send to the EB the Buildfile will run the build.sh that will basically extract the compressed package with the proper structure, and run a go get ./... and go build
The Procfile will run the generated binary
I think the result is pretty good, and you can use with any CI tool.

How do I make the web server run "constantly"?

I have a Play application at ec2 which I just have deployed. Everything seems fine, it's visible in the Internet. However, it seems fine only as the server is working. What I mean is that when I connect to ec2 via ssh and then launch the server by play run, only since then it's visible in the Internet and works fine. I know it's obvious. But I tried to run it in background by play run& and it never worked:
$ play run &
[1] 2470
$ jobs
[1]+ Stopped play run
$ play run&
[2] 2494
$ jobs
[1]- Stopped play run
[2]+ Stopped play run
Have I been doing something wrong? But what and what should I do?
You should prepare your application for production as discussed in the docs. You might also consider running it behind Nginx or Apache or another web server.
Besides also recommending running production using a reverse proxy with Apache or Nginx. (Pretty much the de facto standard these days on Linux), you can also deploy it using the play dist command. Basically, it will compile your code into a package and put it into a zip file.
You can unzip your zip file wherever you want to run your application then you can just run it with:
$ ./<yourapplication>/bin/<yourapplication> -Dhttp.port=<whichever port you want to run it at> &
Make sure you have the java executable in your PATH and this method will avoid having any dependency with the Play application itself. Eventually, you'll probably want to create a Linux init script if you need to deploy your app into multiple servers say behind a load balancer -- So you can your just run service <your-app> start or service <your-app> stop
More info here: http://www.playframework.com/documentation/2.2.x/ProductionDist.
Also, make sure you look at the latest play documentation as it gets updated pretty often.