Intro to Ansible Presentation
My presentation at Riyadh Linux User Group about Ansible
Git directory outside working directory
I have an old PHP website that I wanted to have its code/content versioned with Git, normally Git setup the repo directory in the “.git” directory inside the working directory, but I faced a problem, if the working directory is accessible from the web server it means “.git” is also accessible too.
Luckily git have an option to have the repo directory located somewhere else using the GIT_DIR environment variable, so here what I did:
Install psycopg2 (PostgreSQL adapter for Python) on OSX
I was playing with Django with Postgres backend, and I had little difficulty installing “psycopg2” the Python DB adapter for Postgres on my Mac OSX.
I’ve installed Postgres using Postgres.app for OSX which is straight forward and standard Mac app.
But when I tried installing “psycopg2” using “pip” (the python package manager) I got an error:
$ pip install psycopg2
:
Error: pg_config executable not found.
:
I just searched for “pg_config” in my system:
Limit SSH to Copy a Single File Only
I want to allow host-2 to copy a file securely from host-1, so the easiest way is to use “scp” command which use “ssh” as a transport to copy the file.
If you want to do it manually it is straight forward “scp” invocation:
host-2$ scp host-1:data.csv .
But if you want to automate it you have to use “ssh” keys, but this means leaving a private ssh key on host-2 that can access host-1 without any restriction, i.e.
“sar” command cheat sheet
“sar” is a Unix command that collect, report, or save system activity information, it is different from other system status command like “top” or “vmstat” that only show real time status only, “sar” in the other hand collect these data so you can find the system state at any time.
Solving Python virtualenv “DistributionNotFound: distribute”
After upgrading my Ubuntu machine from 12.04 to 14.04 I had this error on virtualenv wrapper:
Rsnapshot on OSX
Rsnapshot is a backup solution for Unix machines including Linux and OSX, it supports many great features including full backups with the size of only incremental backup, it also support backing up local and remote machines.
Monitoring Servers with Munin
This is a draft on configuring Munin to monitor services on a Linux machine, still dirty but published for my reference, if you have question let me know.
Django memory leak with gunicorn
If you have a long running job that leaks few bytes of memory it will eventually will consume all of your memory with time.
Django Themes (or where to put base.html?)
The Wrong Way
I used to create a new directory to hold common templates like “base.html”, and add it TEMPLATES_DIR in the settings.py file: