Skip to content

Instantly share code, notes, and snippets.

View bitprophet's full-sized avatar
🎯
Focusing

Jeff Forcier bitprophet

🎯
Focusing
View GitHub Profile
jeff:~/D/C/fabfile {fabric} [master] $ fab -l
Available commands:
add_nrpe_cpu_check One-time command to append a new CPU check com...
add_user Add a new user named ``name`` to the remote sy...
apache
ar_mailer
build_djb_packages Download, build and install djbdns, ucspi-tcp ...
check_timezone If date(1) reports UTC, run dpkg-reconfigure t...
check_yum_repos
enum = 'http://readyroom/catalog/enumerate/'
def get_hosts(which=None):
qs = ''
if which:
qs = '?which=%s' % which
ret = urllib.urlopen(enum + 'systems/' + qs).read()
return ret.split()
env.roledefs.update({
from django.conf.urls.defaults import *
from django.db.models.loading import cache
from django.contrib import databrowse
urlpatterns = patterns('',
# blah blah blah
)
In [20]: list(value for key, value in vars(models).items() if isinstance(value, type) and issubclass(value, Model))
Out[20]:
[<class 'readyroom.catalog.models.Service'>,
<class 'readyroom.catalog.models.System'>,
<class 'readyroom.catalog.models.DriveType'>,
<class 'readyroom.catalog.models.DriveConfig'>,
<class 'readyroom.catalog.models.Worklog'>,
<class 'django.contrib.auth.models.User'>,
<class 'readyroom.catalog.models.Daemon'>,
<class 'readyroom.catalog.models.MemoryType'>,
from fabric.api import *
env.host_string = 'my_user@my_django_host'
env.roledefs = {
'host1': run('workon myenv && ./manage.py account_to_shell')
}
@roles('host1')
def mytask():
run('whatever')
@bitprophet
bitprophet / system.py
Created November 11, 2009 21:23
1st-draft quality Fabric user adding task
def add_user(name=None, password=None, admin='no', apache='no', skip='yes'):
"""
Add a new user named ``name`` to the remote system.
If ``name`` or ``password`` are unspecified, you will be prompted for them.
To have a user added to the admin/wheel group, specify ``admin=yes``.
To add the user to the appropriate Apache group, specify ``apache=yes``.
rb(main):002:0> "bobsmith".match(/(b.b)(.+)/)
=> #<MatchData "bobsmith" 1:"bob" 2:"smith">
irb(main):003:0> result = "bobsmith".match(/(b.b)(.+)/)
=> #<MatchData "bobsmith" 1:"bob" 2:"smith">
irb(main):004:0> result[0]
=> "bobsmith"
irb(main):005:0> result[1]
=> "bob"
irb(main):006:0> result[2]
=> "smith"
irb(main):001:0> "bobsmith" =~ /(b.b)(.+)/
=> 0
irb(main):002:0> puts $1
bob
=> nil
irb(main):003:0> puts $2
smith
=> nil
ytram:/u/local [master] $ echo "$FOO"
ytram:/u/local [master] $ FOO='wtf' echo "$FOO"
ytram:/u/local [master] $ FOO='wtf' echo '$FOO'
$FOO
ytram:/u/local [master] $ FOO="wtf" echo "$FOO"
ytram:/u/local [master] $ export FOO="wtf"
ytram:/u/local [master] $ echo "$FOO"
bitprophet.org:~ [master] $ cat /srv/git/repositories/fabric.git/hooks/post-update
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, make this file executable by "chmod +x post-update".
#exec git-update-server-info
exec git push --mirror [email protected]:bitprophet/fabric.git >> /tmp/fabric-to-github.log 2>&1