Coder Social home page Coder Social logo

natxet / django-provision Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dgnest/django-provision

0.0 2.0 0.0 996 KB

provisioning a VPS to run Django with Ansible

Home Page: http://dgnest.github.io/django-provision

Shell 82.46% Python 17.54%

django-provision's Introduction

About

This repo is an in-house project made with โ™ฅ that tries to make our live easier. You don't know how much time we wasted doing this stuff by hand few years ago. So, be patient, we are still working on it.

Features:

  • Deployment server: Ubuntu 12.04 LTS

Getting started

In order to provision. First we have to generate our ssh keys. Then copy your SSH public key and put into your remote repository for SSH deployment. I forgot, we will use SSH agent forwarding strategy to deploy our keys.

$ cat ~/.ssh/id_rsa.pub

This procedure is executed just once.

Prepare the Nest

Set your local environment with the variables below. I strongly recommend to use virtualenvwrapper for this purpose. I am using it and all my virtualenv variables are set into the postactivate script.

# Linux User.
export USER=mynewuser
...

Check this out in order to generate user passwords.

...
export PASSWORD='$6$rounds=100000$.8vhLbNWv7YaHkVb$ALN9H7/4qzVPO83eT1tiT5o4EI9EpBuOo6B53JYcDEXU5Tn2ZMbdlxOCkCaHDnDeJenURpZaX5L3GGlW03s/d1'
export ROOT_PASSWORD='$6$rounds=100000$.8vhLbNWv7YaHkVb$ALN9H7/4qzVPO83eT1tiT5o4EI9EpBuOo6B53JYcDEXU5Tn2ZMbdlxOCkCaHDnDeJenURpZaX5L3GGlW03s/d1'

# Api keys local filepath.
export API_KEY_LOCALPATH='~/projects/django-provision/provisioning/config_keys'
# RSA keys for SSH authentication.
export RSA_PUB_KEY_LOCALPATH='~/.ssh/id_rsa.pub'
export RSA_PRIV_KEY_LOCALPATH='~/.ssh/id_rsa'

# Postgres rol.
export POSTGRES_ROLE=mynewrol
...

Check this out to generate encrypted passwords.

...
export POSTGRES_ROLE_PASSWORD=mypassword
# Postgres database.
export DB_NAME=mydb
export DB_HOST=localhost
export DB_PORT=5432

# Git Repo.
export REPOSITORY="[email protected]:username/myrepo.git"
export REPOSITORY_NAME="myrepo"
export DEPLOYMENT_BRANCH="master"
export REMOTE_HOST="remote-host.com"

All these enviroment variables are mapped into the file provisioning/group_vars/all. So you are free to modify it.

Provisioning with Ansible into a Virtual Machine (VM) using vagrant:

# Bringing VM 'default' up with 'virtualbox' provider.
$ vagrant up
# Provision our VM with ansible.
$ vagrant provision

More info:

Provisioning with Ansible into a VPS:

Before this step, you need to set your inventory. Then, go inside the directory named provisioning and let the hacking begin with this command.

$ ansible-playbook -vvvv -u remote_user_name --sudo site.yml
# Examples:
$ ansible-playbook -vvvv -u root --sudo site.yml
$ ansible-playbook -vvvv -u dgnest --sudo site.yml

Running our Django Project

Inside out guest machine (vagrant) run su newuser to login as our deployment user (newuser). Finally enter to the virtualenv and run the basics.

$ cd ~ && source venv/bin/activate
# Go inside your repo.
$ python manage.py runserver localhost:9000

To check in the browser's host machine:

192.168.33.10

django-provision's People

Contributors

oscargicast avatar

Watchers

 avatar  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.