msingi 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- msingi-0.1.0a1/LICENSE +21 -0
- msingi-0.1.0a1/PKG-INFO +338 -0
- msingi-0.1.0a1/README.md +309 -0
- msingi-0.1.0a1/pyproject.toml +75 -0
- msingi-0.1.0a1/pyproject.toml.orig +65 -0
- msingi-0.1.0a1/src/msingi/__init__.py +8 -0
- msingi-0.1.0a1/src/msingi/__main__.py +6 -0
- msingi-0.1.0a1/src/msingi/account.py +93 -0
- msingi-0.1.0a1/src/msingi/cli.py +178 -0
- msingi-0.1.0a1/src/msingi/clipboard.py +24 -0
- msingi-0.1.0a1/src/msingi/errors.py +6 -0
- msingi-0.1.0a1/src/msingi/modules/__init__.py +39 -0
- msingi-0.1.0a1/src/msingi/modules/certbot.py +48 -0
- msingi-0.1.0a1/src/msingi/modules/git_ssh.py +82 -0
- msingi-0.1.0a1/src/msingi/modules/nginx.py +76 -0
- msingi-0.1.0a1/src/msingi/modules/nvm.py +63 -0
- msingi-0.1.0a1/src/msingi/modules/openssh_ufw.py +70 -0
- msingi-0.1.0a1/src/msingi/modules/packages.py +34 -0
- msingi-0.1.0a1/src/msingi/modules/postgres.py +26 -0
- msingi-0.1.0a1/src/msingi/modules/repos.py +24 -0
- msingi-0.1.0a1/src/msingi/modules/uv.py +58 -0
- msingi-0.1.0a1/src/msingi/output.py +82 -0
- msingi-0.1.0a1/src/msingi/profiles.py +47 -0
- msingi-0.1.0a1/src/msingi/py.typed +0 -0
- msingi-0.1.0a1/src/msingi/runner.py +151 -0
- msingi-0.1.0a1/src/msingi/settings.py +105 -0
- msingi-0.1.0a1/src/msingi/ssh.py +184 -0
- msingi-0.1.0a1/src/msingi/system.py +107 -0
msingi-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Treeolive Tech Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
msingi-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: msingi
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Msingi (Swahili for “foundation”): lay the foundation of an Ubuntu server over SSH. Pick a profile, run it, and only the modules you chose are set up.
|
|
5
|
+
Keywords: ubuntu,server,provisioning,ssh,devops,cli,swahili,treeolive
|
|
6
|
+
Author: Kevin Wasike Wakhisi
|
|
7
|
+
Author-email: Kevin Wasike Wakhisi <kevin@treeolive.tech>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
|
+
Classifier: Topic :: System :: Installation/Setup
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Dist: pyperclip>=1.11.0
|
|
24
|
+
Maintainer: Kevin Wasike Wakhisi
|
|
25
|
+
Maintainer-email: Kevin Wasike Wakhisi <kevin@treeolive.tech>
|
|
26
|
+
Requires-Python: >=3.13
|
|
27
|
+
Project-URL: Repository, https://github.com/treeolive-tech/pkg-msingi.git
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
<!-- ramani: README.md -->
|
|
31
|
+
<h1 align="center">msingi</h1>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<strong>Lay the foundation, once, the same way every time.</strong><br>
|
|
35
|
+
Provision an Ubuntu server over SSH from your own machine: pick a profile, run one command, and only the modules you chose are set up.
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<a href="https://pypi.org/project/msingi/"><img alt="PyPI version" src="https://img.shields.io/pypi/v/msingi?color=006600&label=pypi"></a>
|
|
40
|
+
<a href="https://www.python.org/"><img alt="Python 3.13+" src="https://img.shields.io/badge/python-3.13%2B-3776AB?logo=python&logoColor=white"></a>
|
|
41
|
+
<a href="https://docs.astral.sh/uv/"><img alt="Built with uv" src="https://img.shields.io/badge/built%20with-uv-DE5FE9"></a>
|
|
42
|
+
<img alt="Idempotent" src="https://img.shields.io/badge/modules-idempotent-006600">
|
|
43
|
+
<img alt="MIT license" src="https://img.shields.io/badge/license-MIT-blue">
|
|
44
|
+
<img alt="msingi means foundation in Swahili" src="https://img.shields.io/badge/msingi-Swahili%20for%20%22foundation%22-006600">
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<a href="#install">Install</a> ·
|
|
49
|
+
<a href="#quick-start">Quick start</a> ·
|
|
50
|
+
<a href="#profiles">Profiles</a> ·
|
|
51
|
+
<a href="#options">Options</a> ·
|
|
52
|
+
<a href="#modules">Modules</a> ·
|
|
53
|
+
<a href="#dry-run">Dry run</a> ·
|
|
54
|
+
<a href="#moving-from-github-actions">From GitHub Actions</a> ·
|
|
55
|
+
<a href="#security">Security</a>
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
> **msingi** _(m-SEEN-gee)_ is Swahili for **"foundation"**. A server needs one before anything is built on it: a firewall, a web server, certificates, a database, and a user with the right tools. msingi lays all of that in one run, over SSH, with small Python modules you can read from top to bottom in a minute each.
|
|
59
|
+
|
|
60
|
+
```console
|
|
61
|
+
$ uvx msingi 203.0.113.10 developer --sudo-user ubuntu --git-name "Ada Lovelace" --git-email ada@example.com
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Why
|
|
65
|
+
|
|
66
|
+
Setting up a fresh server by hand means the same twenty commands, in a slightly different order, with one forgotten step every time. msingi writes the steps down once. Every module checks what is already there and skips it, so running it again is always safe.
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
- 🧱 **Modular.** Nine modules, one job each. Run them all, or only the ones you pick.
|
|
71
|
+
- 🎛️ **Four profiles.** Full server, system services only, user tools only, or your own mix.
|
|
72
|
+
- ♻️ **Idempotent.** Re-run any time. Installed things are detected and skipped.
|
|
73
|
+
- 👤 **Creates the user for you.** Name the user. If it doesn't exist, msingi creates it, and can give it passwordless sudo and your public key.
|
|
74
|
+
- 🔒 **Lockout-aware firewall.** UFW is enabled only after the SSH rule is confirmed, and a custom SSH port is allowed too.
|
|
75
|
+
- 🔍 **Dry run.** See what would happen before anything on the server changes.
|
|
76
|
+
- 🔑 **Hands you the Git key.** The generated SSH public key is printed at the end, and `--copy` puts it on your clipboard, ready to paste into GitHub or GitLab.
|
|
77
|
+
- 🪶 **Nothing to install on the server, one small dependency here.** msingi uses the `ssh` command you already have, plus [`pyperclip`](https://pypi.org/project/pyperclip/) for `--copy`.
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
uv tool install msingi # install the command globally (recommended)
|
|
83
|
+
uvx msingi --help # or run it once without installing anything
|
|
84
|
+
pipx install msingi # pipx or plain pip work too: pip install msingi
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
msingi needs the OpenSSH client (`ssh`) on your machine. It comes with macOS, Linux and Windows 10/11.
|
|
88
|
+
|
|
89
|
+
## Quick start
|
|
90
|
+
|
|
91
|
+
### Before you start
|
|
92
|
+
|
|
93
|
+
- An Ubuntu server you can reach over SSH.
|
|
94
|
+
- An existing user on it with **passwordless sudo** (`NOPASSWD:ALL`), such as `ubuntu` or `root`. msingi uses it for the system modules (`--sudo-user`).
|
|
95
|
+
- A way to log in as that user **without typing a password or passphrase**: an ssh-agent with your key loaded (`ssh-add`), or a key file without a passphrase (`--key`). msingi never prompts for either.
|
|
96
|
+
|
|
97
|
+
### Run it
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
msingi 203.0.113.10 developer --sudo-user ubuntu \
|
|
101
|
+
--git-name "Ada Lovelace" --git-email ada@example.com
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
That runs the **Full Development Server** profile: it creates `developer` if needed, sets up the system services as `ubuntu`, then the user tools as `developer`. Add `--dry-run` first if you want to see the plan.
|
|
105
|
+
|
|
106
|
+
If `developer` is new, give it your public key so msingi can log in as that user for the user modules:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
msingi 203.0.113.10 developer --sudo-user ubuntu --make-sudo \
|
|
110
|
+
--public-key ~/.ssh/id_ed25519.pub \
|
|
111
|
+
--git-name "Ada Lovelace" --git-email ada@example.com
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Profiles
|
|
115
|
+
|
|
116
|
+
Pick one with `-P`, or choose your own modules with `-m`.
|
|
117
|
+
|
|
118
|
+
| Profile | System modules | User modules | Best for |
|
|
119
|
+
| -------------------------- | ------------------------------------------------- | ----------------------------- | ------------------------------------------------ |
|
|
120
|
+
| **`full`** (default) | OpenSSH/UFW, Packages, Nginx, Certbot, PostgreSQL | uv, nvm, repos dir, Git + SSH | A brand-new server, everything in one go |
|
|
121
|
+
| **`system`** | OpenSSH/UFW, Packages, Nginx, Certbot, PostgreSQL | none | Infrastructure without personal dev tools |
|
|
122
|
+
| **`user`** | none | uv, nvm, repos dir, Git + SSH | Adding dev tools to a user, no sudo needed |
|
|
123
|
+
| **`custom`** (set by `-m`) | the ones you name | the ones you name | Fine-grained control, or adding one module later |
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
msingi 203.0.113.10 developer -s ubuntu -P system
|
|
127
|
+
msingi 203.0.113.10 developer -P user --git-name "Ada" --git-email ada@example.com
|
|
128
|
+
msingi 203.0.113.10 developer -s ubuntu -m nginx,nvm # only these two
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Modules always run in the same order, whatever order you list them in.
|
|
132
|
+
|
|
133
|
+
## Options
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
msingi HOST USER [options]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Option | What it does |
|
|
140
|
+
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
141
|
+
| `HOST` | Server IP address or hostname |
|
|
142
|
+
| `USER` | The user to set up. Created if missing. User modules run as this user. |
|
|
143
|
+
| `-p, --port PORT` | SSH port (default: `22`) |
|
|
144
|
+
| `-k, --key FILE` | Private key to log in with (also `MSINGI_SSH_KEY`). Default: ssh's own keys and agent. |
|
|
145
|
+
| `-s, --sudo-user USER` | Existing user with passwordless sudo, used for system modules (also `MSINGI_SUDO_USER`) |
|
|
146
|
+
| `--make-sudo` | Give `USER` passwordless sudo (new or existing) |
|
|
147
|
+
| `--public-key KEY_OR_FILE` | Public key (or a `.pub` file) to add to `USER`'s `authorized_keys` |
|
|
148
|
+
| `-P, --profile NAME` | `full`, `system`, `user` or `custom` (default: `full`) |
|
|
149
|
+
| `-m, --modules A,B` | Set up only these modules (a custom profile). Can't be combined with `-P full`, `system` or `user`. |
|
|
150
|
+
| `--git-name NAME` | Git user name. Required when the Git + SSH module runs. |
|
|
151
|
+
| `--git-email EMAIL` | Git user email. Required when the Git + SSH module runs; must look like an email. |
|
|
152
|
+
| `--nvm-version TAG` | nvm release to install (default: `v0.40.4`; also `MSINGI_NVM_VERSION`) |
|
|
153
|
+
| `-c, --copy` | Copy the new Git public key to your clipboard (needs the Git + SSH module). On Linux the clipboard needs `xclip`, `xsel` or `wl-clipboard`. If copying fails, the key is still printed. |
|
|
154
|
+
| `-n, --dry-run` | Show what would happen, change nothing |
|
|
155
|
+
| `-V, --version` | Print the installed version and exit |
|
|
156
|
+
|
|
157
|
+
Flags beat environment variables. `NO_COLOR=1` turns colour off.
|
|
158
|
+
|
|
159
|
+
## Modules
|
|
160
|
+
|
|
161
|
+
### System modules
|
|
162
|
+
|
|
163
|
+
These run as `--sudo-user` and need sudo.
|
|
164
|
+
|
|
165
|
+
| Module | Name | What it does |
|
|
166
|
+
| -------------- | ------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
167
|
+
| 🔒 OpenSSH/UFW | `openssh-ufw` | Allows OpenSSH (and your SSH port, if it isn't 22) in UFW, then enables UFW only once the rule is confirmed |
|
|
168
|
+
| 🛠️ Packages | `packages` | Installs git, curl, wget, snapd, SQLite, Pandoc, TeX (XeTeX), and build tools |
|
|
169
|
+
| 🌐 Nginx | `nginx` | Installs, enables and starts Nginx, opens `Nginx Full` in UFW, and writes the `port-proxy.conf` snippet |
|
|
170
|
+
| 🔏 Certbot | `certbot` | Installs Certbot through snap (needs `snapd`, which Packages provides) |
|
|
171
|
+
| 🐘 PostgreSQL | `postgres` | Installs PostgreSQL and contrib, then enables and starts the service |
|
|
172
|
+
|
|
173
|
+
### User modules
|
|
174
|
+
|
|
175
|
+
These run as `USER`, without sudo.
|
|
176
|
+
|
|
177
|
+
| Module | Name | What it does |
|
|
178
|
+
| ------------ | --------- | ------------------------------------------------------------------------------------------ |
|
|
179
|
+
| 🐍 uv | `uv` | Installs [uv](https://docs.astral.sh/uv/), then a Python through it if uv manages none yet |
|
|
180
|
+
| 📗 nvm | `nvm` | Installs nvm (version from `--nvm-version`), then the latest Node.js, and updates npm |
|
|
181
|
+
| 📁 Repos dir | `repos` | Makes sure `~/repos` exists |
|
|
182
|
+
| 🔑 Git + SSH | `git-ssh` | Sets global git name and email, and creates `~/.ssh/id_ed25519` if absent |
|
|
183
|
+
|
|
184
|
+
### Nginx: a proxy snippet, not a site
|
|
185
|
+
|
|
186
|
+
msingi installs Nginx and a reusable snippet. It does **not** create a server block; that part is yours.
|
|
187
|
+
|
|
188
|
+
```nginx
|
|
189
|
+
server {
|
|
190
|
+
listen 80;
|
|
191
|
+
server_name your.domain;
|
|
192
|
+
set $upstream_port 8080; # the port your app listens on
|
|
193
|
+
include /etc/nginx/snippets/port-proxy.conf;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Then `sudo nginx -t && sudo systemctl reload nginx`.
|
|
198
|
+
|
|
199
|
+
## What you do after a run
|
|
200
|
+
|
|
201
|
+
msingi stops at the foundation on purpose. These are left to you:
|
|
202
|
+
|
|
203
|
+
| Module | Follow-up |
|
|
204
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
205
|
+
| Nginx | Add your server block (above) |
|
|
206
|
+
| Certbot | Once your domain and server block exist: `sudo certbot certonly --nginx -d your.domain` |
|
|
207
|
+
| PostgreSQL | Create roles and databases: `sudo -iu postgres psql` |
|
|
208
|
+
| Git + SSH | Copy the public key printed at the end of the run (or use `--copy`) into GitHub, GitLab or wherever you host code |
|
|
209
|
+
|
|
210
|
+
## Dry run
|
|
211
|
+
|
|
212
|
+
Add `--dry-run` to see what a run would do. Steps print `[DRY RUN] Would …` lines instead of acting.
|
|
213
|
+
|
|
214
|
+
```console
|
|
215
|
+
$ msingi 203.0.113.10 developer -s ubuntu --git-name Ada --git-email ada@example.com --dry-run
|
|
216
|
+
[DRY RUN] Would create user: developer
|
|
217
|
+
[DRY RUN] Would run apt-get update
|
|
218
|
+
[DRY RUN] Would set up OpenSSH and UFW
|
|
219
|
+
[DRY RUN] Would set up necessary packages
|
|
220
|
+
[DRY RUN] Would set up Nginx
|
|
221
|
+
...
|
|
222
|
+
[DRY RUN] Would set up Git and SSH
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
What a dry run does and doesn't do:
|
|
226
|
+
|
|
227
|
+
- ✅ Connects over SSH and checks whether the target user exists.
|
|
228
|
+
- ❌ Doesn't create users, install packages, enable services or edit configuration.
|
|
229
|
+
|
|
230
|
+
## How it works
|
|
231
|
+
|
|
232
|
+
```text
|
|
233
|
+
read the command line ◄── profile, or --modules
|
|
234
|
+
│
|
|
235
|
+
▼
|
|
236
|
+
validate ── names, port, key, Git name/email, --sudo-user for system modules
|
|
237
|
+
│
|
|
238
|
+
▼
|
|
239
|
+
connect ── as --sudo-user, or USER if there are no system modules
|
|
240
|
+
│
|
|
241
|
+
▼
|
|
242
|
+
create / update USER (+ sudo, + authorized key)
|
|
243
|
+
│
|
|
244
|
+
▼
|
|
245
|
+
apt-get update (only if a system module will run)
|
|
246
|
+
│
|
|
247
|
+
▼
|
|
248
|
+
system modules (as --sudo-user) → user modules (as USER)
|
|
249
|
+
│
|
|
250
|
+
▼
|
|
251
|
+
summary → the new Git public key
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Each module is one file in `src/msingi/modules/` with a `setup(conn, settings)` function. It checks its own state (binary installed, service enabled, directory or key present) and does only what is missing, so the second run changes nothing.
|
|
255
|
+
|
|
256
|
+
## Moving from GitHub Actions
|
|
257
|
+
|
|
258
|
+
msingi used to be a GitHub Actions workflow plus shell scripts. The modules do the same jobs, now as Python run from your machine.
|
|
259
|
+
|
|
260
|
+
| Before (workflow) | Now (CLI) |
|
|
261
|
+
| ---------------------------------------- | ------------------------------------------------- |
|
|
262
|
+
| Fork the repo, add Secrets and Variables | Nothing to set up; `uvx msingi ...` |
|
|
263
|
+
| `SERVER_SSH_KEY` secret | Your own key: `--key`, or ssh-agent |
|
|
264
|
+
| `SUDO_ACCESS_USER` secret | `--sudo-user` (or `MSINGI_SUDO_USER`) |
|
|
265
|
+
| `setup_profile` input | `--profile` |
|
|
266
|
+
| Custom profile with `SETUP_*` variables | `--modules nginx,nvm` |
|
|
267
|
+
| `NVM_VERSION` variable | `--nvm-version` |
|
|
268
|
+
| Scripts uploaded to `/tmp`, then removed | Commands run directly, nothing left on the server |
|
|
269
|
+
| Key printed in the run summary | Key printed in your terminal at the end |
|
|
270
|
+
|
|
271
|
+
A few things changed on purpose while porting:
|
|
272
|
+
|
|
273
|
+
- **No shell injection.** The workflow pasted inputs straight into shell scripts, so a quote in a public key could run commands. msingi checks every input and quotes every command.
|
|
274
|
+
- **UFW and custom SSH ports.** The old script only allowed the `OpenSSH` profile (port 22), so enabling UFW on a server with SSH on another port would lock you out. msingi also allows your `--port`.
|
|
275
|
+
- **uv.** `uv python list` includes downloadable versions, so the old check always said Python was installed. msingi counts only Pythons that uv manages itself (the system Python doesn't count).
|
|
276
|
+
- **nvm.** `nvm ls | grep node` matches nvm's built-in `node` alias even with no Node.js installed. msingi asks `nvm version node`, which prints `N/A` when there is none.
|
|
277
|
+
- **Failed downloads.** `curl ... | sh` went on after a failed download; msingi stops.
|
|
278
|
+
- **Authorized keys.** A key is skipped only when the exact line is already there, and it is written without going through a shell.
|
|
279
|
+
|
|
280
|
+
## Troubleshooting
|
|
281
|
+
|
|
282
|
+
| Problem | What to check |
|
|
283
|
+
| ----------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
284
|
+
| "can't connect to …" | Host, port, and that `ssh -i KEY USER@HOST` works by itself. msingi can't type passwords or passphrases. |
|
|
285
|
+
| `a sudo user is required` | System modules need `--sudo-user` (or `MSINGI_SUDO_USER`), and that user needs passwordless sudo |
|
|
286
|
+
| Can't log in as the new user | Pass `--public-key` so msingi can add your key before the user modules run |
|
|
287
|
+
| Git module error | Give both `--git-name` and `--git-email` whenever the profile includes Git + SSH |
|
|
288
|
+
| UFW wasn't enabled | The SSH rule couldn't be confirmed. Fix that and run again; it's a deliberate safeguard |
|
|
289
|
+
| Certbot says snapd is missing | Run `packages` first (it installs `snapd`), or include it in your `--modules` |
|
|
290
|
+
|
|
291
|
+
## Security
|
|
292
|
+
|
|
293
|
+
- Passwordless sudo goes only to `--sudo-user` and, if you ask for it with `--make-sudo`, `USER`. Keep that list short.
|
|
294
|
+
- Use a **dedicated** deploy key, and rotate it now and then.
|
|
295
|
+
- msingi accepts new host keys on first contact (`StrictHostKeyChecking=accept-new`) and refuses changed ones. For a server you haven't connected to before, compare the fingerprint yourself if that matters to you.
|
|
296
|
+
- The generated Git private key never leaves the server. Only the public half is printed.
|
|
297
|
+
- Audit `~/.ssh/authorized_keys` and skim the output of a run for surprises.
|
|
298
|
+
- Give `--sudo-user` no more privilege than the modules need.
|
|
299
|
+
|
|
300
|
+
## Add your own module
|
|
301
|
+
|
|
302
|
+
1. Add `src/msingi/modules/your_module.py` with `NAME` (its command-line name), `TITLE` (shown in the run), `SYSTEM` (`True` if it needs sudo) and `setup(conn, settings)`. Check first, return early if satisfied, print clear status lines. Copy `repos.py`; it is the smallest.
|
|
303
|
+
2. Add it to `MODULES` in `src/msingi/modules/__init__.py`, in the order it should run.
|
|
304
|
+
3. Add its name to `SYSTEM_MODULES` or `USER_MODULES` in `src/msingi/profiles.py`.
|
|
305
|
+
4. Add a test in `tests/test_modules.py`. The `server` fixture is a fake server that records commands, so tests need no real server.
|
|
306
|
+
|
|
307
|
+
## Development
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
uv sync
|
|
311
|
+
uv run pytest
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
msingi has one runtime dependency, [`pyperclip`](https://pypi.org/project/pyperclip/), imported only when you pass `--copy`. Tests use a fake server, plus a stand-in `ssh` that runs commands on your own machine to check quoting.
|
|
315
|
+
|
|
316
|
+
```text
|
|
317
|
+
src/msingi/
|
|
318
|
+
cli.py arguments in, settings out
|
|
319
|
+
runner.py the whole run, top to bottom
|
|
320
|
+
account.py create the user, sudo, authorized key
|
|
321
|
+
ssh.py run commands on the server
|
|
322
|
+
system.py apt, services, UFW
|
|
323
|
+
clipboard.py copy the Git public key
|
|
324
|
+
profiles.py the module sets
|
|
325
|
+
settings.py what a run needs, and its checks
|
|
326
|
+
modules/ one file per module
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## License
|
|
330
|
+
|
|
331
|
+
MIT © Treeolive Tech Ltd. Use it, change it, ship it; just keep the copyright notice.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
<p align="center">
|
|
336
|
+
<em>"...but the people who know their God shall be strong and do exploits."</em><br>
|
|
337
|
+
Daniel 11:32
|
|
338
|
+
</p>
|