Mixins

The Task class inherits from many mixins, which provide a lot of useful utilities for performing common server admin tasks.

AptMixin

class refit.mixins.apt.AptMixin[source]
async apt_autoremove()[source]
Return type

None

async apt_install(*packages)[source]
Return type

None

async apt_update()[source]
Return type

None

DockerMixin

class refit.mixins.docker.DockerMixin[source]
async create_docker_network(network_name)[source]
Return type

None

async docker_compose_up(compose_file_path)[source]
Parameters

compose_file_path (str) – Path to the compose file on the remote machine.

Return type

None

async docker_prune()[source]

Remove any unused images, networks, and containers.

Return type

None

async get_docker_network_names()[source]
Return type

List[str]

async pull_docker_image(image_name)[source]
Return type

None

FileMixin

class refit.mixins.file.FileMixin[source]
async create_file(path)[source]

Create an empty file on the remote server.

Return type

None

async create_folder(path, owner='root', group='root', permissions='755')[source]

Creates folder, and all intermediate directories.

Only changes the group and owner of the deepest directory. If each folder in the chain needs certain permissions, call this function repeatedly for each folder.

Return type

None

async path_exists(path)[source]

Checks whether the path exists on the remote machine.

Return type

bool

async upload_file(local_path, remote_path, root='')[source]

Upload a file using scp to the remote machine.

Return type

None

PathMixin

class refit.mixins.path.PathMixin[source]

Utilities for inspecting the path on the remote machine.

async in_path(executable, raise_exception=False)[source]

Check whether an executable is available on the path.

Return type

bool

PythonMixin

class refit.mixins.python.PythonMixin[source]
async pip(package)[source]

Install a Python package using pip.

Return type

None

SystemdMixin

TemplateMixin

class refit.mixins.template.TemplateMixin[source]
async upload_template(local_path, remote_path, context, root='')[source]

Render a jinja template using the provided context, and upload it to the remote server using scp.

Custom Mixins

There’s nothing magical about the builtin mixins - you can develop your own, and inherit from them.

from refit.task import Task


class MyMixin():
    def hello_world(self):
        print('hello world')


class MyTask(Task, MyMixin):
    async def run(self):
        self.hello_world()