Automation of Systems Administration Tasks

Jan 31
2010

No need for complex, unclear, and clumsy programs like Capistrano.

Use Fabric, here is a short exmple, which automates the archive process of users’ directories:

 
# install the Python library
easy_install fabric
 
# create a file called "fabfile"
# it will be used from the "fab" command
# add the following tasks in "fabfile":
from fabric.api import *
 
env.hosts = ["main"]
env.user  = "root"
 
 
def archive_home():
  with cd("/tmp"):
   run("zip -rq home_`date +%Y:%m:%d-%H:%M`.zip /home")
 
def archive_download():
  import os
  os.system("scp %s:/tmp/home_*.zip /home/su/archive" % env.hosts[0])
 
def archive_remove():
  run("rm /tmp/home_*.zip")

In addition you can use decorators to specify different hosts for different tasks.

More about the “fab” command:

fab --help
Usage: fab [options] (command) [:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...
 
Options:
  -h, --help       show this help message and exit
  -V, --version  show program's version number and exit
  -l, --list           print list of possible commands and exit
  -d COMMAND, --display=COMMAND
                        print detailed info about a given command and exit
  -r, --reject-unknown-hosts
                        reject unknown hosts
  -D, --disable-known-hosts
                        do not load user known_hosts file
  -u USER, --user=USER  username to use when connecting to remote hosts
  -p PASSWORD, --password=PASSWORD
                        password for use with authentication and/or sudo
  -H HOSTS, --hosts=HOSTS
                        comma-separated list of hosts to operate on
  -R ROLES, --roles=ROLES
                        comma-separated list of roles to operate on
  -i KEY_FILENAME       path to SSH private key file. May be repeated.
  -f FABFILE, --fabfile=FABFILE
                        name of fabfile to load, e.g. 'fabfile.py' or
                        '../other.py'
  -w, --warn-only       warn, instead of abort, when commands fail
  -s SHELL, --shell=SHELL
                        specify a new shell, defaults to '/bin/bash -l -c'
  -c RCFILE, --config=RCFILE
                        specify location of config file to use
  --hide=LEVELS           comma-separated list of output levels to hide
  --show=LEVELS         comma-separated list of output levels to show

Smoking Kills

Jan 24
2010

Cigarettes can expose you to a great danger due to a little know behavioural feature.
Imagine the way that each cigarette has – long, boring, lonely. So it’s very natural for a cigarette to become talkative once you free it from the box. And here comes the catch – you begin to socialize with the cigarettes. Which in turn makes you addicted, but even worse – this habit can peril your cosy existence to the point this person has reached:

ssh fails silently on key authentication

Jan 20
2010

If it happens that only root (or no one) can use key authentication, most probably the permissions are wrong. Check the following permissions:

ls -ld ~/.ssh | awk '{print $1}'
# should return drwx------
# otherwise: chmod 0700 ~/.ssh

Calendar

January 2010
M T W T F S S
« Dec   Feb »
 123
45678910
11121314151617
18192021222324
25262728293031

Tags