Files
ShellBook/templates/workspace/notebooks/install-package.md
T
Florian Schmidt 91ac1df8a5 feat(templates): add starter runbook workspace (#5)
Document the notebook format and provide SSH-key, hardening-check, and package-install examples with inventory and credential exclusions.
2026-11-16 00:04:45 +01:00

1.8 KiB

title, params
title params
Install and enable a package
host package service
type required label
host true Debian server
type required default label
name true nginx Package
type required default label
name true nginx Systemd service

Install and enable {{package}}

For Debian hosts using apt and systemd. Check the package/service pairing before running; installing packages can start services and expose network ports. Existing apt indexes must be available. Runs require passwordless sudo and confirmation.

command -v apt-get
command -v systemctl
apt-cache show -- {{package}} > /dev/null
dpkg-query -W -f='${Status}\n' -- {{package}} | grep -qx 'install ok installed'

An absent package is an expected failed check. Proceed with installation only after the repository check succeeds.

if ! dpkg-query -W -f='${Status}\n' -- {{package}} 2>/dev/null | grep -qx 'install ok installed'; then
  DEBIAN_FRONTEND=noninteractive apt-get install -y -- {{package}}
fi
systemctl enable --now -- {{service}}
systemctl is-enabled -- {{service}}
systemctl is-active -- {{service}}

:::after{step=enable} The enable command succeeded. Run the final checks and verify application health and firewall policy before directing traffic to {{host}}. :::