Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ jinn = Jinn(
api_url="https://jinn-api.kalvad.cloud",
api_key="your-api-key",
groups=["production", "web"],
tags=["nginx", "database"]
tags=["nginx", "database"],
)
servers = jinn.get_servers()

# Coolify integration
coolify = Coolify(
api_url="https://coolify.example.com/api",
api_key="your-api-key",
tags=["prod", "staging"]
tags=["prod", "staging"],
)
servers = coolify.get_servers()
```
Expand Down
24 changes: 15 additions & 9 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ To execute test deployments on the local VMs:
api_key="your-access-key",
ssh_key_path="~/.ssh/id_rsa",
groups=["production", "staging"], # Optional: filter by groups
tags=["web", "database"], # Optional: filter by tags
tags=["web", "database"], # Optional: filter by tags
)
hosts = jinn.get_servers()
```
Expand Down Expand Up @@ -151,11 +151,12 @@ from pyinfra.api import deploy
from infraninja.security.common.ssh_hardening import ssh_hardening
from infraninja.security.common.kernel_hardening import kernel_hardening


@deploy("Basic Security Setup")
def basic_security():
# SSH hardening
ssh_hardening()

# Kernel security hardening
kernel_hardening()
```
Expand All @@ -167,21 +168,22 @@ from pyinfra import host
from pyinfra.facts.server import LinuxName
from pyinfra.api import deploy


@deploy("OS-Specific Security Setup")
def os_specific_security():
os_name = host.get_fact(LinuxName)

if "ubuntu" in os_name.lower():
from infraninja.security.ubuntu.fail2ban_setup import fail2ban_setup
from infraninja.security.ubuntu.install_tools import install_security_tools

install_security_tools()
fail2ban_setup()

elif "alpine" in os_name.lower():
from infraninja.security.alpine.fail2ban_setup import fail2ban_setup_alpine
from infraninja.security.alpine.install_tools import install_security_tools

install_security_tools()
fail2ban_setup_alpine()
```
Expand All @@ -194,17 +196,20 @@ def comprehensive_security():
# Common security measures
ssh_hardening(_sudo=True)
kernel_hardening(_sudo=True)

# Network security
from infraninja.security.common.nftables_setup import nftables_setup

nftables_setup(_sudo=True)

# Malware detection
from infraninja.security.common.chkrootkit_setup import chkrootkit_setup

chkrootkit_setup(_sudo=True)

# System auditing
from infraninja.security.common.auditd_setup import auditd_setup

auditd_setup(_sudo=True)
```

Expand All @@ -215,6 +220,7 @@ def comprehensive_security():
def motd_setup():
# Setup custom MOTD
from infraninja.utils.motd import setup_motd

setup_motd()
```

Expand Down
5 changes: 1 addition & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ Ninja-level deployments for infrastructure automation
from infraninja import UpdateAndUpgrade
from infraninja.inventories import Jinn

inventory = Jinn(
api_key="your-api-key",
groups=["production"]
)
inventory = Jinn(api_key="your-api-key", groups=["production"])

action = UpdateAndUpgrade()
action.execute()
Expand Down
17 changes: 10 additions & 7 deletions infraninja/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ print(metadata)
# }

# Get localized name
print(action.get_name('en')) # "SSH Hardening"
print(action.get_name('ar')) # Arabic translation
print(action.get_name("en")) # "SSH Hardening"
print(action.get_name("ar")) # Arabic translation

# Get localized description
print(action.get_description('fr')) # French description
print(action.get_description("fr")) # French description
```

### Listing All Actions
Expand Down Expand Up @@ -134,6 +134,7 @@ from infraninja.actions.base import Action
from pyinfra.api import deploy
from pyinfra.operations import server


class CustomAction(Action):
slug = "custom-action"
name = {
Expand Down Expand Up @@ -223,18 +224,20 @@ if __name__ == "__main__":
import pytest
from infraninja.actions.ssh_hardening import SSHHardening


def test_ssh_hardening_metadata():
action = SSHHardening()

assert action.slug == "ssh-hardening"
assert action.category == "security"
assert "security" in action.tags
assert action.get_name('en') == "SSH Hardening"
assert action.get_name("en") == "SSH Hardening"

metadata = action.get_metadata()
assert 'slug' in metadata
assert 'name' in metadata
assert 'en' in metadata['name']
assert "slug" in metadata
assert "name" in metadata
assert "en" in metadata["name"]


def test_ssh_hardening_validation():
# Action should validate metadata on initialization
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ target-version = "py310"
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "ERA001", "S", "CPY", "DTZ", "EM", "EXE", "FIX", "T20", "SIM", "I", "C90", "N", "PL"]
ignore = ["PLC0415"] # Deferred imports in execute() methods are intentional (pyinfra runtime context)
select = ["E4", "E7", "E9", "F", "ERA001", "S", "DTZ", "EM", "EXE", "FIX", "T20", "SIM", "I", "C90", "N", "PL"]
ignore = [
"PLC0415", # Deferred imports in execute() methods are intentional (pyinfra runtime context)
"CPY001", # Existing modules don't carry copyright headers; adding headers to ~100 files is out of scope for greenkeeping
"PLR0917", # Too many positional arguments (e.g. infraninja/inventories/jinn.py) — pre-existing, out of scope for greenkeeping
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
Expand Down
Loading
Loading