Python/Fabric

From Omnia
Jump to navigation Jump to search

Simple Local:

from fabric.api import run
run('hostname')

Simple remote:

from fabric.api import env
from fabric.api import run

env.host_string = 'some_node'
run('hostname')

Kind of ugly:

from fabric.api import env
from fabric.api import settings
from fabric.api import run

crash_host = {'host_string': 'some-node',
                              'user': 'root',
                              'password': 'password',
                              'command_timeout': 10,
                              'connection_attempts': 1,
                              'abort_on_prompts': True}


with settings(**crash_host):
  run('hostname')