Skip to content

Instantly share code, notes, and snippets.

@jamescasbon
Created February 15, 2012 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamescasbon/1835715 to your computer and use it in GitHub Desktop.
Save jamescasbon/1835715 to your computer and use it in GitHub Desktop.
steps file to go with the feature
from lettuce import *
from fabric import api
from fabric.api import env
import socket
servers = {
'xxx.local': {
'ip': ' xxxx',
'roles': ['production']
}
}
# world is the lettuce singleton
world.hostname = socket.gethostname()
world.installed = {'postfix': False }
# configure fabric to point at localhost
# and to supress output
env.host_string = 'localhost'
env.warn_only = True
import fabric.state
for k in fabric.state.output:
fabric.state.output[k] = False
@step('I am a (\w+) server')
def has_a_role(step, role):
hostname = api.run('hostname')
return role in servers[hostname]['roles']
@step('I am not a (\w+) server')
def doesnt_have_a_role(step, role):
return not has_a_role(step, role)
@step('I should have (\w+) installed')
def check_installed(step, package):
# should call out to apt/rpm
return world.installed.get(package, False)
@step('I should have a mail relay to (\w+)')
def check_mail_relay(step, package):
result = api.run('grep foo /etc/passwd')
assert result, 'relay not set up'
@step('(\w+) should be running')
def check_service_running(step, service):
return True
@step('I should be listening on port (\d+)')
def check_service_running(step, port):
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment