Overview
Requirements
HapiDeploy requires Python 3.13+
, so you need to check your python version.
python --version
Installation
Globally
You can install the hapideploy
library using pip.
pip install hapideploy
Check if the hapi
command is available.
hapi about
If you see a result like this, the installation process is successful.
Hapi CLI <version>
Locally
I recommend you to hold HapiDeploy stuff in a directory called ".hapi" inside each project directory. You should also create isolated Python environments for them. Then, you should run the hapi
command inside .hapi
directory, so generated resources are going to be separated from your projects.
E.g., for the project-1, I'll run these commands in the terminal.
cd /path/to/project-1
mkdir .hapi
cd .hapi
uv venv --python 3.13
source ./.venv/bin/activate
pip install hapideploy
hapi about
You can use uv, pyenv or any other similar things.
Usage
Create files by the init
command.
hapi init
After that, you can define remotes (at least one) in the inventory.yml
file.
remotes:
remote-1:
host: 192.168.33.11
user: vagrant
remote-2:
host: 192.168.33.12
user: vagrant
remote-3:
host: 192.168.33.13
user: vagrant
You may define one or more tasks in the deploy.py
file.
from hapi import Context
from hapi.cli import app
@app.task(name="whoami", desc="Run whoami command")
def whoami(c: Context):
c.run("whoami")
Executing the "whoami" task on all remotes.
hapi whoami
Try "hapi --help" for more information.
hapi --help