Skip to content

Instantly share code, notes, and snippets.

View ihassin's full-sized avatar
🏠
Working from home

Itamar Hassin ihassin

🏠
Working from home
View GitHub Profile
@ihassin
ihassin / dbserver.yml
Created December 24, 2013 00:17
Ansible script to install mySQL
- hosts: webservers
user: vagrant
sudo: true
vars_files:
- vars.yml
tasks:
- name: Install MySQL
action: apt pkg=$item state=installed
with_items:
@ihassin
ihassin / Reconnect
Created June 3, 2012 14:51
Reconnect to a lost database connection using an exception block trick (ruby, rails, mysql, activerecord)
def my_task
while(true) do
begin
database_access_here
rescue Exception => ex
begin
ActiveRecord::Base.connection.reconnect!
rescue
sleep 10
retry # will retry the reconnect
@ihassin
ihassin / Vagrantfile
Last active February 24, 2020 20:30
Vagrantfile used in the blog entry
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define :web do |web_config|
web_config.vm.box = "precise64"
web_config.vm.box_url = "http://files.vagrantup.com/precise64.box"
web_config.vm.network :private_network, ip: "33.33.33.33"
web_config.vm.network :forwarded_port, guest: 80, host: 8080
@ihassin
ihassin / user.yml
Last active June 23, 2018 09:56
Ansible user.yml playbook used in blog post
---
- hosts: webservers
user: vagrant
sudo: True
vars_files:
- vars.yml
vars:
deploy: deploy
home_dir: /home/deploy

Keybase proof

I hereby claim:

  • I am ihassin on github.
  • I am itamar (https://keybase.io/itamar) on keybase.
  • I have a public key ASDrmzdPARW675_0HGog-jOPjeSuvIeG39Fl9XVs54PNAAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am ihassin on github.
  • I am itamarhassin (https://keybase.io/itamarhassin) on keybase.
  • I have a public key whose fingerprint is 6ADD D726 34EC B42A 5F5C 58D9 4F1E 1B5A F429 72E5

To claim this, I am signing this object:

@ihassin
ihassin / production.rb
Created December 24, 2013 00:31
config/deploy/production.rb - Capistrano file to deploy
set :stage, :production
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
role :app, %w{deploy@33.33.33.33}
role :web, %w{deploy@33.33.33.33}
role :db, %w{deploy@33.33.33.33}
@ihassin
ihassin / deploy.rb
Created December 24, 2013 00:11
Capistrano 3 script to deploy the app
set :application, '<APP_NAME>'
set :repo_url, "<git@PATH/REPO.git>"
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :deploy_to, "/home/deploy/rails/<APP_NAME>"
# set :scm, :git
set :format, :pretty
set :log_level, :debug
@ihassin
ihassin / webserver.yml
Last active December 31, 2015 09:39
Ansible webserver.yml playbook used in the blog post
- hosts: webservers
user: vagrant
sudo: True
vars_files:
- vars.yml
vars:
deploy: deploy
home_dir: /home/deploy
tasks:
@ihassin
ihassin / project.yml
Last active December 31, 2015 09:39
Ansible project.yml playbook for blog post
- hosts: webservers
user: deploy
vars_files:
- vars.yml
tasks:
- name: Make directory for database.yml
shell: mkdir -p {{home_dir}}/rails/narui/shared/config
- name: Copy database.yml