Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 ='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 ='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