GithubHelp home page GithubHelp logo

bridgecrew-perf7 / rails-deploy-ansible Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidpgero/rails-deploy-ansible

0.0 0.0 0.0 56 KB

Rails deploy with Ansible

License: GNU General Public License v3.0

Jinja 100.00%

rails-deploy-ansible's Introduction

Deploying Rails

I learnt a lot from

  • Thank you!

Prepare

Instead of Vagrant with Virtualbox, we're going to use Multipass as our primary VM.

  • Install Multipass

With Python

pip install ansible
pip install -r requirements.txt
ansible-galaxy install -r requirements.yml

Run

# launch multipass
multipass launch --cloud-init cloud-init.yml --name 'PICK_YOUR_NAME' 20.04
# run the provision
ansible-playbook site.yml --verbose

Generate password

Important: the hash can change from OS to OS. Use the VM to create a hash.

ssh [email protected]
python3 -c 'import crypt,getpass,sys;print(crypt.crypt(getpass.getpass(), crypt.mksalt(crypt.METHOD_SHA512)))'

Ansible Vault

ansible-vault create group_vars/all/vault
ansible-vault edit group_vars/all/vault

cat ~/.ssh/id_rsa.pub >> roles/user/files/ansible/authorized_keys
ansible-vault encrypt roles/user/files/ansible/*

# replace keys
ansible-vault rekey group_vars/*/vault roles/user/files/*/*
ansible-vault edit group_vars/all/vault

If you totally forget your password... We can't get them back, but we can recreate the files.

  • Find the vault files grep '$ANSIBLE_VAULT' . -r -l
  • Store the list somewhere so you can go one by one
  • Remove the file and encrypt it again ansible-vault encrypt YOUR_FILE
  • Whenever we use enrcyped variables, you can find the name of the value by vault_ prefix
    • Open a new vault file, add the variable and encrypt the file

Multipass

Multipass as a primary VM.

You can set your SSH public key in the cloud-init.yml file. After you set up your SSH key, you can ssh in ssh ubuntu@VM_IP_ADDRESS. Get your VM_IP_ADDRESS by multipass info --all

ssh_authorized_keys:
  - YOUR_SSH_PUBLIC_KEY

Useful for set up SSH key in your ~/.ssh/config.

Host VM_IP_ADDRESS
  IdentityFile ~/.ssh/YOUR_PRIVATE_KEY
  User ubuntu
  ForwardAgent yes

Useful commands are:

# Launch a new VM
multipass launch --cloud-init cloud-init.yml --name 'YOUR_VM_NAME' 20.04
# Get info about your VM
multipass info YOUR_VM_NAME

Services

ss -ltun
lsof -i :25
systemctl --type=service

ssh -o BatchMode=yes -o ConnectTimeout=3 [email protected] exit
echo $?

How to use app user?

sudo su - app

rails-deploy-ansible's People

Contributors

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