RiotKit-Do (RKD) usage and development manual

RKD is a stable, open-source, multi-purpose automation tool which balance flexibility with simplicity. The primary language is Python and YAML syntax.

RiotKit-Do can be compared to Gradle and to GNU Make , by allowing both Python and Makefile-like YAML syntax.

What can be achieved with RKD?

  • Simplify the scripts

  • Put your Python and Bash scripts inside a YAML file (like in GNU Makefile)

  • Do not reinvent the wheel (argument parsing, logs, error handling for example)

  • Share the code across projects and organizations, use native Python Packaging to share tasks (like in Gradle)

  • Natively integrate scripts with .env files

  • Automatically generate documentation for your scripts

  • Maintain your scripts in a good standard

RKD can be used on PRODUCTION, for development, for testing, to replace some of Bash scripts inside docker containers, and for many more, where Makefile was used.

version: org.riotkit.rkd/yaml/v1
tasks:
    :hello1:
        extends: rkd.core.standardlib.syntax.PythonSyntaxTask
        arguments:
            "--name":
                required: True
                help: "Allows to specify a name"
        description: Prints your name
        execute: |
            self.io().info_msg(f'Hello {ctx.get_arg("--name")}, I\'m talking from YAML, and you?')
            return True

Example use cases

  • Docker based production environment with multiple configuration files, procedures (see: Harbor project )

  • Database administrator workspace (importing dumps, creating new user accounts, plugging/unplugging databases)

  • Development environment (executing migrations, importing test database, splitting tests and running parallel)

  • On CI (prepare project to run on eg. Jenkins or Gitlab CI) - RKD is reproducible on local computer which makes inspection easier

  • Application cluster management, deploying applications, adding users, setting permissons

  • Automate things like certificate regeneration on production server, RKD can generate any application configs using JINJA2

  • Installers (RKD has built-in commands for replacing lines in files, modifying .env files, asking user questions and validating answers)

Install RKD

RiotKit-Do is delivered as a Python package that can be installed system-wide or in a virtual environment. The virtual environment installation is similar in concept to the Gradle wrapper (gradlew)

# download a wrapper that will automatically setup virtual environment and install RKD
# do not forget to commit wrapper to the GIT repository
wget https://github.com/riotkit-org/riotkit-do/blob/master/src/core/rkd/core/misc/initial-structure/rkdw.py -O rkdw
chmod +x rkdw
./rkdw

Getting started in freshly created structure

The “Quick start” section ends up with a .rkd directory, a requirements.txt and ./rkdw

  1. Call RKD using a wrapper in project directory ./rkdw

  2. Each time you install anything from pip in your project - add it to requirements.txt (or use pipenv install ), additional RKD tasks can be installed from PIP

  3. In .rkd/makefile.yaml add your tasks, pipelines and imports

Create your first task with Getting started

Check how to use commandline to run tasks in RKD with Commandline usage

See how to import existing tasks to your Makefile with Importing tasks page

Keep learning