All Projects → LunarLogic → Ansible Elixir Playbooks

LunarLogic / Ansible Elixir Playbooks

Licence: mit
Ansible playbooks for Elixir build server and Phoenix Website. Sample app here: https://github.com/LunarLogic/phoenix_website

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ansible Elixir Playbooks

Analytics
Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
Stars: ✭ 9,469 (+24179.49%)
Mutual labels:  postgresql, phoenix
Eosio sql plugin
EOSIO sql database plugin
Stars: ✭ 21 (-46.15%)
Mutual labels:  mysql, postgresql
Guardian auth
The Guardian Authentication Implementation Using Ecto/Postgresql Elixir Phoenix [ User Authentication ]
Stars: ✭ 15 (-61.54%)
Mutual labels:  postgresql, phoenix
Iobroker.sql
Store history data in SQL Database: MySQL, PostgreSQL or SQLite
Stars: ✭ 37 (-5.13%)
Mutual labels:  mysql, postgresql
Soci
Official repository of the SOCI - The C++ Database Access Library
Stars: ✭ 960 (+2361.54%)
Mutual labels:  mysql, postgresql
Netkiller.github.io
Netkiller Free ebook - 免费电子书
Stars: ✭ 861 (+2107.69%)
Mutual labels:  mysql, postgresql
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+2423.08%)
Mutual labels:  mysql, postgresql
Szt Bigdata
深圳地铁大数据客流分析系统🚇🚄🌟
Stars: ✭ 826 (+2017.95%)
Mutual labels:  mysql, phoenix
Lealone Plugins
与 Lealone 集成的各类插件(例如网络框架以及不同的数据库协议和存储引擎)
Stars: ✭ 31 (-20.51%)
Mutual labels:  mysql, postgresql
Wait4x
Wait4X is a cli tool to wait for everything! It can be wait for a port to open or enter to rquested state.
Stars: ✭ 30 (-23.08%)
Mutual labels:  mysql, postgresql
Ridgepole
Ridgepole is a tool to manage DB schema. It defines DB schema using Rails DSL, and updates DB schema according to DSL. (like Chef/Puppet)
Stars: ✭ 840 (+2053.85%)
Mutual labels:  mysql, postgresql
Docs4dev
后端开发常用框架文档及中文翻译,包含 Spring 系列文档(Spring, Spring Boot, Spring Cloud, Spring Security, Spring Session),大数据(Apache Hive, HBase, Apache Flume),日志(Log4j2, Logback),Http Server(NGINX,Apache),Python,数据库(OpenTSDB,MySQL,PostgreSQL)等最新官方文档以及对应的中文翻译。
Stars: ✭ 974 (+2397.44%)
Mutual labels:  mysql, postgresql
Experdb Db2pg
eXperDB-DB2PG is a data migration solution that transfers data extracted from various DBMSs to eXperDB or PostgreSQL. Currently, Oracle and Oracle Spatial, MySQL, SQL Server(MS-SQL) and Sybase data can be transferred.
Stars: ✭ 24 (-38.46%)
Mutual labels:  mysql, postgresql
Monogamy
Add table-level database locking to ActiveRecord
Stars: ✭ 12 (-69.23%)
Mutual labels:  mysql, postgresql
Auto App
Crie um aplicativo com todas as tabelas de um dos seus bancos sem uma linha de código.
Stars: ✭ 18 (-53.85%)
Mutual labels:  mysql, postgresql
Treefrog Framework
TreeFrog Framework : High-speed C++ MVC Framework for Web Application
Stars: ✭ 885 (+2169.23%)
Mutual labels:  mysql, postgresql
Diesel
A safe, extensible ORM and Query Builder for Rust
Stars: ✭ 7,702 (+19648.72%)
Mutual labels:  mysql, postgresql
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (+2017.95%)
Mutual labels:  ansible, mysql
Tbls
tbls is a CI-Friendly tool for document a database, written in Go.
Stars: ✭ 940 (+2310.26%)
Mutual labels:  mysql, postgresql
Notes
📝 Migrated to(迁移至) https://github.com/Kuangcp/Note 当前仓库已经废弃, 对应的博客网站:
Stars: ✭ 33 (-15.38%)
Mutual labels:  mysql, postgresql

Ansible Elixir Playbooks

This project has ansible playbooks for:

  • Elixr Build Server - it has installed Erlang, Elixir and nodejs. Basically, all what is required to compile the Phoenix Framework application.
  • Phoenix Website - it is a playbook to provision server with installed PostgreSQL and configured nginx and Let's Encrypt for SSL. There is no Erlang/Elixir on this server because we will deploy there only compiled Phoenix application.

You can learn more about the project from this blog post https://blog.lunarlogic.io/2017/phoenix-app-deployment-with-ansible-playbooks-for-elixir/

Here you will find an example Phoenix Framework app configured for deployment.

Requirements

Control machine (your computer)

  • Install Ansible

  • Download roles:

    $ ansible-galaxy install -r requirements.yml
    
  • Generate vault_pass.txt file into this repository. You need it to be able to encrypt/decrypt secrets.

    ⚠️ For security reasons, the vault_pass.txt file should not be committed into the repository. It's ignored in .gitignore.

    $ openssl rand -base64 256 > vault_pass.txt
    
  • Generate your DB password and put output to apps/phoenix-website/host_vars/phoenix-website.lunarlogic.io

    $ ansible-vault encrypt_string --name db_password "YOUR_DB_PASSWORD"
    

Target machine (server)

  • Server with Ubuntu 16.04 LTS.

Public keys

We keep our public keys in public_keys/ directory. This set of keys is uploaded to the server during each provisioning and overwrites the list of authorized keys, so proper people have access to the server. It is important to keep the list of keys up to date.

If you don't know how to generate a key for yourself, read this article.

App deployement

CircleCI deployment

If you want to deploy app from CI to the staging/production host then you must generate RSA keys for CircleCI.

$ ssh-keygen -t rsa -b 4096 -N "" -C "circle_ci" -f ./apps/elixir-build-server/circle_ci
$ ssh-keygen -t rsa -b 4096 -N "" -C "circle_ci" -f ./apps/phoenix-website/circle_ci

Add circle_ci.pub public key to your app playbook for the role user:

- role: user/0.0.1
  username: phoenix
  authorized_key_paths:
    - ../../public_keys/*.pub
    - ./circle_ci.pub # add this line

Go to CircleCI and find your project, open settings and find SSH Permissions. Click Add an SSH key button and paste there private key apps/YOUR_APP_NAME/circle_ci.

Now you can remove private key apps/YOUR_APP_NAME/circle_ci from local machine. It should not be commited into repo!

Commit into repo only public key apps/YOUR_APP_NAME/circle_ci.pub.

You can always generate a new fresh keys if you need it hence no reason to backup private key. You already added it to CircleCI.

Run playbooks

Warning: This command will provision all servers listed in inventory file for particular app apps/app_name.

$ ./play apps/app_name

If you want to provision only specific machine do (it's useful if your app is deployed to multiple servers like staging and production):

# Warning: There must be comma and the end of the hosts list!
$ ansible-playbook -i 'example-staging.lunarlogic.io,' apps/app_name/playbook.yml

Provisioning logs

You can check when and with what git commit the host was provisioned in log file: /var/log/provision.log (stored on the target machine).

System users

There are 3 types of users on the server:

  • root - for provisioning
  • admin - user has the sudo access
  • app_name_user - for instance phoenix user for Phoenix Website application. The user has no sudo access. The application is running under this user.

Add playbook for new app

  • create new app directory in the app directory
  • in this new directory create playbook.yml and inventory files
  • in the inventory file put host names to provision (see Ansible docs)
  • implement playbook.yml

Secrets

We store secrets in encrypted version using Vault. If you are adding new secrets, make sure you commit them to the repository in the encrypted form.

  • Encrypting single values (that can be placed inside a "clear text" YAML file, using the !vault tag):

    $ ansible-vault encrypt_string --name pass_to_some_service "secret"  # stdout encrypted string
    
  • Encrypting whole YAML files:

    $ ansible-vault encrypt secret.yml   # encrypt unencrypted file
    $ ansible-vault edit secret.yml      # edit encrypted file
    $ ansible-vault decrypt secret.yml   # decrypt encrypted file
    

Roles

Role versioning

We use roles versioning the simplest possible way, we just add version subdirectories under every role directory.

roles/role-name/role-version/ # e.g. roles/webserver/0.3.2/

To create a new version just copy an existing one, bump the role version and modify it. Please, respect Semantic Versioning 2.0.0.

Community developed roles

Include the roles in requirements.yml and download them using the following command:

$ ansible-galaxy install -r requirements.yml

SSL with Let's Encrypt

You can use lets_encrypt role to generate free SSL certificate thanks to https://letsencrypt.org

Rate Limits

The main limit is Certificates per Registered Domain (20 per week).

https://letsencrypt.org/docs/rate-limits/

If you are testing Let's Encrypt then use staging environment with higher limits!

- role: lets_encrypt/0.0.1
  app_name: myapp
  lets_encrypt_contact_email: [email protected]
  lets_encrypt_environment: staging # you can change it to production once ready

If you want to change main domain for your certificate

If you want to change main domain for your certificate then you need to generate a new certificate.

Here is example file for Phoenix Website project with multiple domains.

In order to generate a new certificate please remove first the old files generated by lets_encrypt role on the server:

$ rm -rf /etc/letsencrypt/accounts/*
$ rm -rf /etc/letsencrypt/archive/*
$ rm -rf /etc/letsencrypt/csr/*
$ rm -rf /etc/letsencrypt/keys/*
$ rm -rf /etc/letsencrypt/live/*
$ rm -rf /etc/letsencrypt/renewal/*

# remove the snippents that load SSL certificate
$ rm -rf /etc/nginx/snippets/project_name

Ensure the nginx is running. It's required so Let's Encrypt can do request to our domain. Provision server again.

Note: If you would like to add a new subdomain to domain list then you can just provision server and a new subdomain will be added to the certificate. You need to generate certificate from scrach only if you change the main domain (the first domain on the list of domains).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].