Code

Taboot

The Taboot task library.

Taboot was created as a framework to do code deployments which require a repetitive set of tasks to be run in a certain order against certain groups of hosts.

Taboot runner

class taboot.runner.Runner(script, config, expand_globs=True)[source]

The Runner, responsible for running a taboot job.

Parameters :
  • script: an instance of tabootScript
  • expand_globs: whether to expand the globs or just leave them as is.
run()[source]

Run the preflight/tasks-body

class taboot.runner.TaskRunner(host, tasks, semaphore, output, fail_event)[source]

TaskRunner is responsible for executing a set of tasks for a single host in it’s own thread.

Parameters :
  • host: The host to operate on.
  • tasks: A list of tasks to perform (see Runner)
  • semaphore: The Runner semaphore to acquire before executing
  • output: A list of outputters to use. (see Runner)
  • fail_event: The Runner failure event to check before executing. If this event is set when the TaskRunner acquires the semaphore, then the TaskRunner is effectively a no-op.
run()[source]

Run the task(s) for the given host. If the fail_event passed from the invoking Runner is set, do nothing.

run_task(task)[source]

Run a single task. Sets task.host and then invokes the run method for the task.

Parameters :
  • task: The task to run

Taboot tasks

class taboot.tasks.BaseTask(*args, **kwargs)[source]

Base Task. All tasks should inherit from this. It does the pretty string representation of a task and allows setting of the host attribute.

class taboot.tasks.FuncErrorTask(*args, **kwargs)[source]

Explicitly cause a func remote error by calling a bad command. Used to verify func exception handling works as expected

class taboot.tasks.FuncTask(*args, **kwargs)[source]

A Func-based task. All tasks that utilize Func should inherit from this.

run(runner)[source]

Run the FuncTask.

Parameters :
class taboot.tasks.TaskResult(task, success=False, output='', ignore_errors=False)[source]

An encapsulation of the results of a task. This is passed to one or more instances of output classes (derived from BaseOutput) in order to display to the user.

Parameters :
  • task: The task object represented by this result
  • success: Whether the task completed successfully or not
  • output: Any text output produced by the task

AJP Tasks

class taboot.tasks.mod_jk.InRotation(proxies, action='enable', **kwargs)[source]

Put an AJP node in rotation on a proxy via modjkapi access on the proxy with func.

Parameters :
  • proxies: A list of URLs to AJP jkmanage interfaces
class taboot.tasks.mod_jk.OutOfRotation(proxies, action='stop', **kwargs)[source]

Remove an AJP node from rotation on a proxy via modjkapi access on the proxy with func.

Parameters :
  • proxies: A list of URLs to AJP jkmanage interfaces

Command tasks

class taboot.tasks.command.Run(command, **kwargs)[source]

Run arbitrary commands via Func. The arguments passed to __init__ are used to execute func.overlord.Client.command.run(args).

Parameters :
  • command: Command to run on the remote host

Misc tasks

Nagios tasks

class taboot.tasks.nagios.DisableAlerts(nagios_url, **kwargs)[source]

Disable alerts for a host on a nagios instance

Parameters :
  • nagios_url: Hostname of the Nagios server.
class taboot.tasks.nagios.EnableAlerts(nagios_url, **kwargs)[source]

Enable alerts for a host on a nagios instance

Parameters :
  • nagios_url: Hostname of the Nagios server.
class taboot.tasks.nagios.NagiosBase(*args, **kwargs)[source]

All subsequent Nagios tasks are subclasses of this.

Code note: Because a FuncTask expects to make connections to self.host we need to switch nagios_url with self.host and pass the original self.host as an argument.

Changed in version 0.2.14.

class taboot.tasks.nagios.ScheduleDowntime(nagios_url, service='HOST', minutes=30, **kwargs)[source]

Schedule downtime for services on a host in Nagios

Parameters :
  • nagios_url: Hostname of the Nagios server.
  • service: Service or list of services to schedule down for.
  • minutes: The number of minutes to schedule downtime for. Default is 30.
class taboot.tasks.nagios.SilenceHost(nagios_url, **kwargs)[source]

Silence all notifications for a given host

Parameters :
  • nagios_url: Hostname of the Nagios server.
class taboot.tasks.nagios.UnsilenceHost(nagios_url, **kwargs)[source]

Unsilence all notifications for a given host

Parameters :
  • nagios_url: Hostname of the Nagios server.

Polling tasks

class taboot.tasks.poller.PollTask(task, sleep_interval=5, max_attempts=6, fail_task=None, **kwargs)[source]

PollTask. A task that will poll a particular task until the task succeeds or until max_attempts is reached.

Parameters :
  • task The task to poll.

  • sleep_interval The number of seconds to wait before trying

    the task again.

  • max_attempts The maximum number of attempts that the task

    should be run.

  • fail_task The task to run when max_attempts has been exhausted.

    If no fail_task is provided, then a simple TaskResult indicating failure is returned.

Puppet tasks

class taboot.tasks.puppet.DeleteLockfile(**kwargs)[source]

Remove the puppet lock file.

class taboot.tasks.puppet.Disable(**kwargs)[source]

Run ‘puppetd –disable’.

class taboot.tasks.puppet.Enable(**kwargs)[source]

Run ‘puppetd –enable’.

class taboot.tasks.puppet.PuppetBase(pcmd, **kwargs)[source]

Base class for puppet commands

class taboot.tasks.puppet.PuppetTaskResult(task, success=False, output='', ignore_errors=False)[source]

Wrapper around TaskResult to be able to differentiate in output class

class taboot.tasks.puppet.Run(server='', noop=False, safe=False, **kwargs)[source]

Run ‘puppetd –test || true’

Optional Parameters:
 
  • server: Puppetmaster to run against
  • noop: If this should be a noop run (Boolean)
  • safe: Abort if puppet errors (Boolean)

See also: taboot.tasks.Puppet.SafeRun()

class taboot.tasks.puppet.SafeRun(server='', **kwargs)[source]

Run ‘puppetd –test’.

How is this different from Run? Simple, it will abort everything if puppet returns with a non-zero exit status.

RPM tasks

class taboot.tasks.rpm.PostManifest(**kwargs)[source]

Gather list of installed RPMs and compare against a previously taken PreManifest

run(runner)[source]

The runner that gets passed in contains state that can be access via dict-like access. PreManifest uses this to write to the rpm.Premanifest field. So we’ll check to make sure the pre-manifest is there by looking for that state.

class taboot.tasks.rpm.PreManifest(**kwargs)[source]

Gather list of installed RPMs. A later invocation of PostManifest is then used to output the RPMs changed during intermediate tasks.

run(runner)[source]

Override the default command.Run to strip the output from the result because we’re really not interested in the contents of the pre-manifest; we just want to collect it to compare later on with PostManifest.

class taboot.tasks.rpm.RPMBase(pcmd, **kwargs)[source]

Base class for rpm commands

class taboot.tasks.rpm.RPMTaskResult(task, success=False, output='', ignore_errors=False)[source]

Wrapper around TaskResult to be able to differentiate in output class

Service tasks

class taboot.tasks.service.Restart(service, **kwargs)[source]

Restart a service.

Arguments:
  • service - The service to restart.
class taboot.tasks.service.ServiceBase(command, **kwargs)[source]

Base Class for system service tasks

class taboot.tasks.service.Start(service, **kwargs)[source]

Start a service.

Arguments:
  • service - The service to start.
class taboot.tasks.service.Stop(service, **kwargs)[source]

Stop a service.

Arguments:
  • service - The service to stop.

Sleep tasks

class taboot.tasks.sleep.Minutes(minutes=1, **kwargs)[source]

Halt task processing on a node for a certain number of minutes.

Parameters :
  • minutes: Number of minutes to halt execution for.
class taboot.tasks.sleep.Seconds(seconds=60, **kwargs)[source]

Halt task processing on a node for a certain number of seconds.

Parameters :
  • seconds: Number of seconds to halt execution for.
class taboot.tasks.sleep.SleepBase(**kwargs)[source]

Base class for task-queue pausing classes.

class taboot.tasks.sleep.WaitOnInput(message='Press enter to continuen', **kwargs)[source]

Halt task processing on a node until the user presses enter.

Parameters :
  • message: The message to prompt on the CLI.

Yum tasks

class taboot.tasks.yum.Install(packages, **kwargs)[source]

Install one or more packages.

Parameters :
  • packages: A list of packages to install
class taboot.tasks.yum.Remove(packages, **kwargs)[source]

Remove one or more packages.

Parameters :
  • packages: A list of packages to remove.
class taboot.tasks.yum.Update(packages=[], **kwargs)[source]

Update one or more packages.

Parameters :
  • packages: A list of packages to update. If packages is empty,

    update all packages on the system.

class taboot.tasks.yum.YumBase(packages)[source]

Base class for all Yum-related tasks.

Taboot output

class taboot.output.CLIOutput(*args, **kwargs)[source]

Output a taboot.tasks.TaskResult to the command line with pretty formatting and colors.

Creates an instance of a file-like object.

Parameters :
  • args: all non-keyword arguments.
  • kwargs: all keyword arguments.
class taboot.output.EmailOutput(*args, **kwargs)[source]

Output a taboot.tasks.TaskResult to a logfile.

Creates an instance of a file-like object.

Parameters :
  • args: all non-keyword arguments.
  • kwargs: all keyword arguments.
flush()[source]

Flushing sends the email with the buffer.

class taboot.output.HTMLOutput(*args, **kwargs)[source]

Output a taboot.tasks.TaskResult to the command line with pretty formatting and colors.

_write(result)[source]

Write a tasks result out to HTML. Handles enhanced stylizing for task results that support such as:

Creates an instance of a file-like object.

Parameters :
  • args: all non-keyword arguments.
  • kwargs: all keyword arguments.
class taboot.output.LogOutput(*args, **kwargs)[source]

Output a taboot.tasks.TaskResult to a logfile.

Creates an instance of a file-like object.

Parameters :
  • args: all non-keyword arguments.
  • kwargs: all keyword arguments.