GithubHelp home page GithubHelp logo

chamalis / ansible-skeleton Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

A scalable skeleton for ansible deployments featuring a simple Clock Web app (BE + FE)

Dockerfile 6.68% Go 11.32% HTML 18.84% Shell 63.17%

ansible-skeleton's Introduction

Clock ansibled

Deploy a simple "clock" web application (frontend + backend) in a virtual machine using ansible.

Ingredients

  • debian10-ssh.img.tar.xz: Compressed disk image of a virtual machine.
  • vm.xml: Virtual machine XML definition for libvirt
  • rsa: Authorized RSA key for accessing the virtual machine
  • index.html: Frontend clock application

Introduction

A script setup-prod.sh has been built in order to automate:

  • Downloading the compressed disk image file
  • Extract the file and create a VM with that disk
  • Connect to the VM via ansible and install docker and its dependancies [may take several minutes the first time]
  • copy the app into the VM and deploy through docker

It automatically creates two new files in the project tree at:

  • ./app/webserver/frontend/index.html
  • ./vm/vm.xml They are overwritten every time the automated script is invoked but they are needed if one wants to deploy by running ansible commands manually

After that the website should be available at: http:///

Prerequisites

The following binaries need to be in $PATH:

  • ansible
  • ansible-playbook

In case we follow usage example 1 or 4 from Usage, following also required:

  • virsh

Usage

The aforementioned script should be put in the project root's folder as is now, and executed after changing directory to root.

Use either as:

  1. Download VM and setup everything from scratch:
./setup.sh --auto
  1. Provide the reachable IP or FQDN/hostname of the already deployed VM, e.g:
./setup.sh --ip=192.168.122.188
  1. Provide the name of the already locally deployed VM (current: immfly-debian10), e.g:
./setup.sh --vm=immfly-debian10
  1. Provide the path to disk img file and auto create the VM, e.g:
./setup.sh --img=~/debian10-ssh.img

Cases 2 && 3 are almost identical with the only difference being, in case 3 it tries to figure out the ip based on the vm name provided.

In those cases no direct modifications are made to the VM itself, outside ansible's context.

Cases 1 && 4 differ only to the fact that in case 1 the disk file will be downloaded from the internet and extracted inside the project ./vm/

Manual ansible execution

  • export DEBIAN10_IP=<the IP of the VM>
  • Copy ./app/webserver/frontend/index-template.html to ./app/webserver/frontend/index.html and change the IP here:
const CLOCK_URL = 'http://${BACKEND_ENDPOINT}/clock';
  • ansible-playbook ./ansible/setupvm.yml -i ./ansible/env/prod/inventory.yml
  • ansible-playbook ./ansible/deploy.yml -i ./ansible/env/prod/inventory.yml

Other

Structure

The project is organized into the following dirs:

  • app : The directory thats being copied to the VM via ansible
  • ansible: Ansible files, inventories, variables, roles, tasks
  • vm: Files needed to setup the VM instance itself: SSH keys and its libvirt definition

Ansible structure

In ./ansible folder right now only the prod environment is used, meaning its inventory and its variables, as well as the env/group_00_global_vars of course.

Future work

it would be better if we didn't need to keep templated files in

  • ./app/webserver/frontent/index-template.html
  • ./vm/vm-template.xml

a.o

ansible-skeleton's People

Contributors

chamalis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.