Compare commits
133
Commits
aeb2e80ab1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e84b5344de | ||
|
|
2f245d4934 | ||
|
|
24696e79d0 | ||
|
|
f76a02181a | ||
|
|
6a2550b733 | ||
|
|
241d41e128 | ||
|
|
44e9687c75 | ||
|
|
1f634a6aa0 | ||
|
|
6683c8c892 | ||
|
|
1590923b58 | ||
|
|
23237f8934 | ||
|
|
acf880afe1 | ||
|
|
29b398976e | ||
|
|
7216eb5583 | ||
|
|
2806eab187 | ||
|
|
eea5495fc8 | ||
|
|
95f475c2f9 | ||
|
|
8f38cab2b3 | ||
|
|
36db591bfd | ||
|
|
69f86c2368 | ||
|
|
a59ba939ca | ||
|
|
ba54c55329 | ||
|
|
8e0a67fd20 | ||
|
|
f96baa77d1 | ||
|
|
6f02cd3425 | ||
|
|
1d7c74676c | ||
|
|
59f155d06e | ||
|
|
dbecf87806 | ||
|
|
13f4e44671 | ||
|
|
2aeda8a39d | ||
|
|
404e608b14 | ||
|
|
894acd626e | ||
|
|
d648bfeda2 | ||
|
|
ba6f30492c | ||
|
|
77e88c98a1 | ||
|
|
d4cbdf5ef4 | ||
|
|
95ad74a068 | ||
|
|
b909cd5afb | ||
|
|
cddf4351e1 | ||
|
|
db6c7829ee | ||
|
|
c115ea8ea1 | ||
|
|
96e01987c1 | ||
|
|
75b8cb5d9b | ||
|
|
f9954fd9b4 | ||
|
|
78e31ea450 | ||
|
|
116bc1ef01 | ||
|
|
b39fb246ef | ||
|
|
512860703e | ||
|
|
ec6e228b05 | ||
|
|
25a71c0265 | ||
|
|
776afc212d | ||
|
|
457d78d4f0 | ||
|
|
8081d09e73 | ||
|
|
7814227259 | ||
|
|
d22db46e9f | ||
|
|
7fb37d5b40 | ||
|
|
7be2be4027 | ||
|
|
608c006c9e | ||
|
|
16db9b0426 | ||
|
|
5614138919 | ||
|
|
88faf35ec3 | ||
|
|
d6988bb35f | ||
|
|
bad40feae6 | ||
|
|
4f82520e0e | ||
|
|
d4850a3c02 | ||
|
|
75e229c0ab | ||
|
|
30ddb37b34 | ||
|
|
6c58671d15 | ||
|
|
317a98b9b1 | ||
|
|
33b5c76bec | ||
|
|
d159504121 | ||
|
|
04ed433e84 | ||
|
|
ea54beea70 | ||
|
|
959c3a5bb9 | ||
|
|
4d86012762 | ||
|
|
6244c1cc25 | ||
|
|
46c35106fb | ||
|
|
a1beb6cd3e | ||
|
|
9c2882ea00 | ||
|
|
290245349f | ||
|
|
0a8865de38 | ||
|
|
cd1c2f7332 | ||
|
|
24b08aa592 | ||
|
|
26de312c42 | ||
|
|
d9b32e4eef | ||
|
|
e7312ad460 | ||
|
|
48cdd81779 | ||
|
|
4b26aca5ee | ||
|
|
5456c783c6 | ||
|
|
0fa0692c37 | ||
|
|
54e9927167 | ||
|
|
72ab6b4b32 | ||
|
|
25a7234f40 | ||
|
|
51db52f862 | ||
|
|
050e235f8b | ||
|
|
fa0c77fb58 | ||
|
|
80693e4f8e | ||
|
|
396349640f | ||
|
|
9c47d93a2f | ||
|
|
edb34a75ec | ||
|
|
23e5ecc4cb | ||
|
|
915111e9dd | ||
|
|
6199368710 | ||
|
|
575d79f611 | ||
|
|
428e9ecb1d | ||
|
|
b860cb116d | ||
|
|
b6f94483e5 | ||
|
|
28e0b0c7a6 | ||
|
|
0600321968 | ||
|
|
5dcddfa4ba | ||
|
|
322e20e50f | ||
|
|
eb99b00a70 | ||
|
|
799d270261 | ||
|
|
8124483da8 | ||
|
|
8f1642bf96 | ||
|
|
174deea2a9 | ||
|
|
99270c344d | ||
|
|
6b6a8ff021 | ||
|
|
4f2bfe18a5 | ||
|
|
a7fbad60ab | ||
|
|
c2b592a66b | ||
|
|
4851517947 | ||
|
|
132c0854d1 | ||
|
|
1044224d02 | ||
|
|
291a7ebc27 | ||
|
|
53954d8494 | ||
|
|
6814374bac | ||
|
|
019ab468bf | ||
|
|
ea2048dc87 | ||
|
|
db575080c9 | ||
|
|
11ae08f7e6 | ||
|
|
a791baa085 | ||
|
|
422999bf3c |
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!crush.json
|
||||
!.gitignore
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"hooks": {
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "^(bash|edit|write|multiedit|lsp_replace_symbol|lsp_rename)$",
|
||||
"command": "./hooks/ticket-gate.sh",
|
||||
"timeout": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# PFVCluster environment variables
|
||||
# Copy to .env and fill in values for local development/testing.
|
||||
|
||||
# Pi-hole (netinfra/pihole/docker-compose.yml)
|
||||
PIHOLE_WEB_PASSWORD=changeme
|
||||
|
||||
# Shellcheck wrapper (tests/shellcheck.sh) — no config needed, uses Docker.
|
||||
+35
-2
@@ -1,8 +1,31 @@
|
||||
# Crush internal state (track crush.json config, ignore session data)
|
||||
.crush/crush.db
|
||||
.crush/crush.db-*
|
||||
.crush/logs/
|
||||
.crush/memory/
|
||||
.crush/active-ticket
|
||||
|
||||
# OS/editor
|
||||
.DS_Store
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
\#*\#
|
||||
.\#*
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.bak
|
||||
*.log.tmp
|
||||
|
||||
# LOGFILENAME artifacts: the framework (Logging.sh + PrettyPrint.sh) appends
|
||||
# every print_info/print_error line to LOGFILENAME, defined as
|
||||
# "$0.<Weekday>-YYYY-MM-DD-HH:MM:SS.$$". Running any script that sources the
|
||||
# framework therefore drops a timestamped log file next to it. Ignore these
|
||||
# everywhere in the repo.
|
||||
# framework therefore drops a timestamped log file next to it.
|
||||
*.Monday-*
|
||||
*.Tuesday-*
|
||||
*.Wednesday-*
|
||||
@@ -10,4 +33,14 @@
|
||||
*.Friday-*
|
||||
*.Saturday-*
|
||||
*.Sunday-*
|
||||
|
||||
# Sensitive exports / runtime data
|
||||
dns-cluster-setup/.export/
|
||||
returned-logs/
|
||||
|
||||
# Kubernetes secrets (kubeconfig contains embedded client certs)
|
||||
k8s/kubeconfig.yaml
|
||||
k8s/*.token
|
||||
|
||||
# Pi-hole web UI password (real value only in on-box .env, never committed)
|
||||
netinfra/pihole/.env
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# ShellCheck configuration for PFVCluster
|
||||
# (used when running `shellcheck` directly; tests/shellcheck.sh applies the
|
||||
# same disables via -e for consistent results under Docker)
|
||||
#
|
||||
# These checks are DISABLED because they flag intentional conventions of this
|
||||
# codebase, not bugs:
|
||||
#
|
||||
# SC1090 / SC1091 — cannot follow dynamically-computed `source` paths. The KNEL
|
||||
# framework (vendor/) and test harness source helpers via computed include
|
||||
# dirs, which shellcheck cannot resolve statically.
|
||||
# SC2029 — ssh orchestration (tests/remote.sh and perf/k8s/dns scripts)
|
||||
# deliberately builds and expands the remote command on the CLIENT side before
|
||||
# sending it. That is the whole point of the single-chokepoint remote pattern.
|
||||
disable=SC1090,SC1091,SC2029
|
||||
|
||||
# Treat external-sourced files as bash (matches #!/usr/bin/env bash framework).
|
||||
external-sources=true
|
||||
@@ -1,76 +1,587 @@
|
||||
# Agent Guidelines
|
||||
|
||||
## Agent Authority (NON-NEGOTIABLE)
|
||||
|
||||
**No work is permissible on any system without an approved Redmine ticket.
|
||||
There are no exceptions to this rule.**
|
||||
|
||||
### Scope of authority
|
||||
|
||||
1. **Tickets govern all work.** The agent performs ONLY the work described in
|
||||
the approved Redmine ticket. Anything outside that scope — no matter how
|
||||
small, helpful, or "obvious" — is prohibited.
|
||||
|
||||
2. **No autonomous system changes.** The agent does not modify, configure,
|
||||
create, delete, or grant anything on a production system unless it is
|
||||
explicitly directed by an approved ticket. "Production system" means
|
||||
every system in the fleet — there is no "test" exception unless the ticket
|
||||
says so.
|
||||
|
||||
3. **Propose, never implement.** If the agent discovers additional work that
|
||||
should be done — a bug, a misconfiguration, a missing dependency, an
|
||||
enhancement — it does NOT implement it. Instead, it creates a Redmine
|
||||
sub-ticket (status Feedback) describing the finding and surfaces it to
|
||||
the user for approval.
|
||||
|
||||
4. **Security and access changes require extra scrutiny.** Changes to sudoers,
|
||||
SSH keys, user accounts, firewall rules, authentication policy, file
|
||||
permissions, or any privilege-related configuration are treated as
|
||||
policy decisions, not implementation details. The agent may suggest
|
||||
them but NEVER implements them without explicit user direction in the
|
||||
ticket or a sub-ticket the user has approved.
|
||||
|
||||
5. **The user makes policy. The agent implements policy.** The agent does
|
||||
not decide who gets sudo, what keys go where, what services run, or what
|
||||
the access model is. The agent executes the user's decisions, exactly
|
||||
as specified.
|
||||
|
||||
6. **When in doubt, ask.** If the ticket is ambiguous, if a task seems to
|
||||
require something not explicitly authorized, or if the agent is unsure
|
||||
whether an action is in scope — STOP and ask the user via the ticket
|
||||
or directly. Asking is always acceptable. Overstepping is never
|
||||
acceptable.
|
||||
|
||||
7. **NEVER close a ticket without explicit user permission.** You may
|
||||
SUGGEST a close when the result is clearly scoped and delivered. If
|
||||
it's ambiguous whether the work is truly complete, don't suggest a
|
||||
close — leave that decision to the user. This applies to ALL tickets,
|
||||
no exceptions.
|
||||
8. **User acceptance testing is MANDATORY before declaring work done.**
|
||||
The agent performs implementation and technical validation (services
|
||||
running, configs correct, APIs responding). The user performs UAT —
|
||||
visually confirming dashboards render data, alerts deliver, tools are
|
||||
usable. The agent MUST NOT set done-ratio to 100%, MUST NOT suggest
|
||||
closing, and MUST NOT move to the next ticket until the user explicitly
|
||||
accepts the work. "Technically wired but blank dashboard" is NOT done.
|
||||
9. **NEVER access a database directly if an API exists.** APIs are the
|
||||
stable contract; databases change schemas without warning. If a tool
|
||||
has an API, use it — exhaust all API endpoints, check the docs, try
|
||||
alternative methods. Only fall back to direct DB access as a last
|
||||
resort AND with explicit user approval for that specific instance.
|
||||
Soon all DB access will route through a proxy under zero trust;
|
||||
building API-first habits now ensures that transition is clean.
|
||||
|
||||
### Access-channel policy: SSH only (NON-NEGOTIABLE)
|
||||
|
||||
**The qemu guest-agent is NEVER an access, execution, or key-delivery
|
||||
channel.** SSH (`sshd`) is the only approved remote access path. Every
|
||||
command must flow through sshd so it is captured by the standard
|
||||
auth/logging/audit infrastructure. This is an ITAR/CMMC/TS/SCI
|
||||
environment — there is no back-door exception, ever.
|
||||
|
||||
- **Forbidden:** `qm guest exec` (runs arbitrary commands inside a guest
|
||||
over an unaudited channel) and any wrapper around it (e.g. a `vm-guest`
|
||||
mode). This includes using guest-agent to *deliver* an SSH key, even if
|
||||
the resulting SSH login is itself audited — the delivery bypassed audit.
|
||||
- **Allowed:** installing or checking qemu-guest-agent for its intended
|
||||
purpose — letting Proxmox see guest state (`qm guest cmd <id> ping`,
|
||||
`agent: 1` config, `apt install qemu-guest-agent`). Visibility only;
|
||||
never execution.
|
||||
- **Enforced mechanically:** `scripts/check-rules.sh` rule #11 fails on
|
||||
any `qm guest exec` / `vm-guest` pattern in code. `tests/remote.sh` has
|
||||
no guest-exec mode.
|
||||
- **If a system is locked out** (no SSH key, no guest-exec path): surface
|
||||
it to the user. Do NOT improvise an alternate back-channel. The user
|
||||
authorizes the unblock method (console login, credential, etc.).
|
||||
|
||||
### Ticket-closing policy (NON-NEGOTIABLE)
|
||||
|
||||
**NEVER close a Redmine ticket without explicit user permission.** You
|
||||
may SUGGEST a close when the result is clearly scoped and delivered. If
|
||||
it's ambiguous whether the work is truly complete, don't suggest a close
|
||||
— leave that decision to the user. This applies to ALL tickets, no
|
||||
exceptions.
|
||||
|
||||
### What this means in practice
|
||||
|
||||
- Discovered a typo in a config during approved work? **Finish the approved
|
||||
work. Create a sub-ticket for the typo. Do not fix it inline.**
|
||||
- Think a system should also have localuser sudo configured? **Do not add
|
||||
it. Propose it in a sub-ticket.**
|
||||
- Need to install a package the ticket didn't mention? **Ask first.**
|
||||
- Found a security issue? **Create a ticket immediately with full details.
|
||||
Do not remediate without approval.**
|
||||
|
||||
This environment operates in ITAR/CMMC/TS/SCI space. Every action must be
|
||||
traceable to an approved ticket. There is no "I thought it would help."
|
||||
|
||||
## Quick Start
|
||||
|
||||
**You are an AI agent working on this project. Your first actions, in order:**
|
||||
|
||||
> **SESSION-START GATE (NON-NEGOTIABLE):** Steps 1-3 orient you. Step 4 is the
|
||||
> check-for-understanding gate (rule summary). Steps 5-7 gather state. Step 8 is
|
||||
> the scope-alignment gate. You MUST NOT begin any task work until the user
|
||||
> (a) confirms your rule summary AND (b) names the ticket to work on. This runs
|
||||
> **every session, automatically** — the user should never have to ask for it.
|
||||
|
||||
1. **Set up the environment:** `bash scripts/setup-hooks.sh` (installs git hooks — idempotent).
|
||||
2. **Read this file** (`AGENTS.md`) — project policy and domain knowledge.
|
||||
3. **Read the latest questions file** (`questions-v*.md`) — open questions awaiting human input. The version number increments each round (v1, v2, v3...).
|
||||
4. **Check for understanding — GATE.** In your own words, summarize ALL the rules
|
||||
back to the user before doing any work: Agent Authority (ticket-governed,
|
||||
propose-never-implement), Access-Channel SSH-only policy, Remote access
|
||||
(remote.sh chokepoint mandatory, DNS names only — never IP literals),
|
||||
Questions policy (no harness question-tools), Documentation policy
|
||||
(Discourse is SoR), Redmine tracking, Git policy (always commit+push,
|
||||
shellcheck), Mandatory infra-change documentation (#298 audit log), SSH
|
||||
routing chokepoints (`tests/remote.sh`), the mechanically enforced
|
||||
`check-rules.sh` rules, and Credentials (Vault migration TODO). Then stop
|
||||
and wait for the user to confirm. This checkpoint guarantees every
|
||||
session starts aligned.
|
||||
5. **Check Redmine** — `docker run --rm --env-file ~/.creds/redmine.env git.knownelement.com/reachableceo/redmine-cli:latest list --assigned-to-me -p 55` for active work.
|
||||
6. **Check current state:** `git log --oneline -10`.
|
||||
7. **Run rule audit:** `bash scripts/check-rules.sh --fast`.
|
||||
8. **Scope-alignment — GATE.** Present the session handoff's "What's Left"
|
||||
priority list (or the Redmine queue if no handoff exists). Do NOT scan the
|
||||
full ticket queue and pick work on your own — **the user directs what gets
|
||||
worked on, always.** Note any new or urgent items from the Redmine check,
|
||||
then ask which ticket to work on tonight. **STOP and wait.** Do not set
|
||||
`.crush/active-ticket`, do not read systems, do not run diagnostics, until
|
||||
the user names the target. This gate prevents the agent from burning
|
||||
context on work the user didn't ask for.
|
||||
|
||||
## Enforcement Model
|
||||
|
||||
Git hooks (`scripts/pre-commit`, `scripts/pre-push`) enforce the rules defined in
|
||||
`scripts/check-rules.sh`. The rules engine checks: shellcheck (zero warnings
|
||||
including info-level), Docker image pinning (no `:latest`), container naming,
|
||||
required files, Discourse pointer headers, and more. Run `bash scripts/check-rules.sh`
|
||||
for a full audit or `--fast` for pre-commit speed. Bypass with `--no-verify`
|
||||
(emergencies only).
|
||||
|
||||
## Task Tracking
|
||||
|
||||
- **Redmine is the system of record for all work.**
|
||||
- **NEVER close a ticket without explicit user permission.** Suggest a
|
||||
close when clearly scoped/delivered; if ambiguous, don't suggest.
|
||||
- **Ticket-first enforcement (mechanically enforced).** Before starting
|
||||
any work, set the active ticket: `echo '#NNN' > .crush/active-ticket`.
|
||||
The Crush hook (`hooks/ticket-gate.sh`) blocks modifying operations
|
||||
until this file exists. If no ticket exists, CREATE ONE FIRST via
|
||||
redmine-cli, then set it. Clear when done: `> .crush/active-ticket`.
|
||||
- **WORKING.md** is the only in-repo task tracker — a scratchpad for the current
|
||||
session. The pre-commit hook blocks commits while any task remains unchecked.
|
||||
- Clear WORKING.md before responding to the user.
|
||||
|
||||
## Rolling HUD (session-scoped, NOT persisted)
|
||||
|
||||
The rolling HUD is a **live status display** the agent maintains throughout
|
||||
the session to help the human follow along. It is NOT a system of record —
|
||||
Redmine, Discourse, and git are the durable systems. The HUD exists purely
|
||||
for the human's situational awareness during the session.
|
||||
|
||||
- **Format:** a compact block shown at the end of each significant response
|
||||
(after completing a step, hitting a blocker, or pivoting). Example:
|
||||
|
||||
```
|
||||
┌─ SESSION HUD ────────────────────────────────────────
|
||||
│ Active: #343 (Monitoring coverage matrix)
|
||||
│ Done: ✓ scope-alignment gate added to both AGENTS.md
|
||||
│ ✓ committed + pushed (6a2550b)
|
||||
│ Now: drafting coverage matrix on Discourse
|
||||
│ Next: → #341 TEMPer USB (deploy on pfv-tsys1)
|
||||
│ → #338 LibreNMS alerts (BLOCKED: pushover.env)
|
||||
├─ USER ACTION ITEMS ──────────────────────────────────
|
||||
│ • Populate ~/.creds/pushover.env (unblocks #338, #428)
|
||||
│ • Populate ~/.creds/prometheus.env + grafana.env (#430)
|
||||
└──────────────────────────────────────────────────────
|
||||
```
|
||||
|
||||
- **Placement:** may be written to `.crush/hud.md` on disk to keep context
|
||||
window smaller (re-read and update rather than hold in memory). Never
|
||||
committed to git. Wiped at session end.
|
||||
- **Sections:**
|
||||
- **Active:** current ticket number + one-line description
|
||||
- **Done:** ✓ items completed this session (append as work progresses)
|
||||
- **Now:** what the agent is actively doing
|
||||
- **Next:** the queued items (per handoff priority or user direction)
|
||||
- **User action items:** things ONLY the user can do (populate creds,
|
||||
physical work, manual deploys) with the tickets they unblock
|
||||
- **When to show it:** after each logical unit of work, at blockers, and
|
||||
when pivoting between tickets. Not every trivial response — use judgment.
|
||||
- **NOT a substitute for Redmine/Discourse/git.** The HUD is ephemeral. When
|
||||
work completes, update the durable systems (ticket notes, Discourse wiki,
|
||||
commits). The HUD just tracks the live narrative for the human.
|
||||
|
||||
## Working Style
|
||||
|
||||
- **Stop over-thinking.** Get to code and output faster. Explore with code;
|
||||
gather ground truth. Do not burn tokens reasoning about things a quick command
|
||||
answers.
|
||||
- **Farm work out to deterministic tooling:** linters, LSPs, formatters, test
|
||||
runners. If an LSP is wired up, use it; otherwise pull a Docker image and lint
|
||||
inside it.
|
||||
- **Use sub-agents as subcontractors:** scoped spec in, distilled deliverable out.
|
||||
Never read 10+ files sequentially; batch into agent calls.
|
||||
- **Command timeouts (NON-NEGOTIABLE):** Every command that touches a remote
|
||||
system MUST be wrapped with `timeout`. Hard limits: 30s for quick reads
|
||||
(status, ps, ls), 120s for standard operations, 300s for deployments/pulls.
|
||||
If a command hits the timeout, STOP and investigate root cause — never
|
||||
blindly retry. A hung command is a failed command. Detect failure fast,
|
||||
diagnose, fix, move on. Example: `timeout 120 bash tests/remote.sh vm 'cmd'`.
|
||||
This applies to ALL tools — bash, docker, CLIs, sub-agents.
|
||||
|
||||
## Questions (NON-NEGOTIABLE)
|
||||
|
||||
**NEVER use a harness "question"/"ask user" tool** (structured prompts,
|
||||
modal forms, tabbed questions). Banned across every project, every harness.
|
||||
They are not portable, not version-controlled, and bypass the git record.
|
||||
**All questions go in the current `questions-v(N).md` file** — write the
|
||||
question; the human edits the answer inline in the same file. **Version up
|
||||
the filename each time answers land** (v1 → v2 → v3...): create
|
||||
`questions-v2.md` with resolved Q&A marked, new questions appended. This
|
||||
preserves the history of each Q&A round. Synthesize resolved Q&A into
|
||||
Discourse (decisions) and Redmine (work items). See `BASELINE-PROMPT.md`
|
||||
§10.
|
||||
|
||||
## Documentation policy (IMPORTANT)
|
||||
|
||||
**Discourse is the canonical source of truth for all knowledge documentation.**
|
||||
Knowledge docs (architecture, runbooks, references, audits, policies) have been
|
||||
migrated to [community.turnsys.com](https://community.turnsys.com/c/vp-techops)
|
||||
as wiki topics in the **VP TechOps** category.
|
||||
|
||||
All `.md` files in this repo (except `AGENTS.md` and `LICENSE`) are now
|
||||
**pointers** that link to their corresponding Discourse topic. **Do not update
|
||||
documentation content in git** — edit the Discourse wiki topic instead. Git
|
||||
edit history no longer serves as the documentation changelog; Discourse
|
||||
preserves wiki edit history automatically.
|
||||
|
||||
Code (scripts, configs, playbooks) still lives in git as the source of truth
|
||||
for executables. Only *documentation* moved to Discourse.
|
||||
|
||||
## Top-level files
|
||||
|
||||
All `.md` files now point to Discourse. The key pointers:
|
||||
|
||||
| File | Points to | Discourse topic |
|
||||
|------|-----------|-----------------|
|
||||
| `README.md` | Project overview | [#296](https://community.turnsys.com/t/296) |
|
||||
| `STATUS.md` | Ticket index + infra summary | [#297](https://community.turnsys.com/t/297) |
|
||||
| `docs/docmap.md` | Documentation index | [#296](https://community.turnsys.com/t/296) |
|
||||
|
||||
Work tracking stays in [Redmine](https://projects.knownelement.com).
|
||||
|
||||
## Repository Layout
|
||||
|
||||
Knowing where things live prevents broken edits:
|
||||
|
||||
- **Vendored framework**: `KNELShellFramework` lives at
|
||||
`vendor/git@git.knownelement.com/29418/KNEL/KNELShellFramework/`, **not** at
|
||||
the repo root. Its includes are under `Framework-Includes/` there. Never
|
||||
assume `./Framework-Includes` exists relative to the repo root.
|
||||
- **Self-locating scripts**: All provisioning scripts derive their own
|
||||
location via `BASH_SOURCE` and compute `PROJECT_ROOT_PATH` from it. They must
|
||||
**never** depend on the current working directory or on `cd`/`realpath ..`
|
||||
chains. Run them from anywhere — `sudo bash SetupNewSystem.sh` works.
|
||||
- **Local config files are the source of truth**: Configs in
|
||||
`ProjectCode/ConfigFiles/` are read with `cat`/`cp`. Do **not** re-introduce
|
||||
`curl ${DL_ROOT}/...` downloads from `dl.knownelement.com` — that CDN is
|
||||
deprecated for this repo.
|
||||
- **Path variables**: Scripts export `PROJECT_ROOT_PATH`, `CONFIGFILES_PATH`,
|
||||
`MODULES_PATH`, `SCRIPTS_PATH`, and `AGENTS_PATH` for locating repo content.
|
||||
- **Non-bash agents**: Some files under `ProjectCode/Agents/` carry a `.sh`
|
||||
extension but are PHP (e.g. `mysql.sh`, shebang `#!/usr/bin/php`). Syntax
|
||||
checkers must skip these.
|
||||
|
||||
## Git Commit Requirements
|
||||
|
||||
When making changes to this repository, ALWAYS:
|
||||
|
||||
1. **Commit atomically**: Each logical change should be its own commit
|
||||
2. **Use conventional commit format**:
|
||||
- `feat(scope): description` - New feature
|
||||
- `fix(scope): description` - Bug fix
|
||||
- `docs: description` - Documentation changes
|
||||
- `refactor(scope): description` - Code refactoring
|
||||
- `test(scope): description` - Test additions/changes
|
||||
- `chore: description` - Maintenance tasks
|
||||
3. **Write verbose, beautifully formatted messages**:
|
||||
- Title line (50 chars max)
|
||||
- Blank line
|
||||
- Body explaining WHAT and WHY (not how)
|
||||
- Reference related files/issues
|
||||
- Include footer with attribution
|
||||
|
||||
## Example Commit
|
||||
|
||||
```
|
||||
feat(security-hardening): implement SCAP-STIG compliance logic
|
||||
|
||||
Refactor apply script to implement comprehensive security hardening:
|
||||
|
||||
- Add GRUB bootloader permission hardening (root:root, mode 0400)
|
||||
- Disable and remove autofs service per STIG requirements
|
||||
- Deploy modprobe configurations for kernel module blacklisting
|
||||
- Create STIG-compliant network protocol blacklist
|
||||
|
||||
This ensures servers meet DoD security requirements for production
|
||||
deployment.
|
||||
|
||||
🤖 Generated with [Crush](https://github.com/charmassociates/crush)
|
||||
|
||||
Assisted-by: GLM-5 via Crush <crush@charm.land>
|
||||
dcinfra/ Data-center infra: PDU (powerman), serial console (console), UPS (ups)
|
||||
netinfra/ DNS/NTP/DHCP setup + audit; DNS cluster replication (dns-cluster-setup);
|
||||
switch captures (switches); DHCP config (dhcp)
|
||||
k8s/ k3s cluster setup scripts (HA control plane over Tailscale) + docs/
|
||||
proxmox/ Proxmox fleet docs (hardware audit, capacity, storage) + perf tuning (perf/)
|
||||
awx/ Ansible AWX deployment (k3s + AWX Operator)
|
||||
tests/ Test suite + VM validation harness + remote.sh SSH chokepoint
|
||||
scripts/ Framework: git hooks, rule engine (check-rules.sh), shared lib
|
||||
docs/ Server-build docs, docmap index, and archive
|
||||
archive/ Historical/superseded code (provisioning -> replaced by KNELIAC project)
|
||||
vendor/ Vendored KNELShellFramework
|
||||
```
|
||||
|
||||
## Autonomous Git Workflow
|
||||
- **Server provisioning moved to KNELIAC**: The
|
||||
[`archive/provisioning/`](archive/provisioning/) tree is historical. Active
|
||||
server provisioning lives in the **KNELIAC** project at
|
||||
`/home/reachableceo/projects/KNELIAC`.
|
||||
- **Non-bash files**: Some files under `archive/provisioning/Agents/` have `.sh`
|
||||
extension but are PHP (shebang `#!/usr/bin/php`). Skip in syntax checks.
|
||||
- **Remote access (NON-NEGOTIABLE):** ALL SSH/SCP to ANY host MUST go
|
||||
through the chokepoint scripts — [`tests/remote.sh`](tests/remote.sh)
|
||||
(Proxmox hosts + all VMs) or
|
||||
[`netinfra/dns-cluster-setup/remote-dns.sh`](netinfra/dns-cluster-setup/remote-dns.sh)
|
||||
(DNS infra hosts: netinfra-01/02, tsrouter, netboot). NEVER call
|
||||
`ssh`/`scp` directly — the harness blocks raw ssh and the command scanner
|
||||
rejects it. There are no exceptions.
|
||||
- **DNS names ONLY (NON-NEGOTIABLE):** NEVER use IP address literals
|
||||
(neither LAN nor Tailscale IPs) in any command, script, or config.
|
||||
ALWAYS use DNS names. For Proxmox hosts: `PROX_HOST=<dns-name>`. For VMs:
|
||||
`VM_IP=<dns-name>`. For conman/SNMP/any tool: pass the DNS name. If a
|
||||
DNS name does not resolve, fix it in DNS (Technitium) or consult the
|
||||
[system inventory — Discourse #307](https://community.turnsys.com/t/307).
|
||||
Do NOT fall back to IP literals. This rule eliminates the per-session
|
||||
discovery tax of finding the right IP for each host.
|
||||
- **How to access a production VM:**
|
||||
1. Look up the DNS name in the [system inventory — Discourse #307](https://community.turnsys.com/t/307).
|
||||
2. `VM_IP=<dns-name> VM_USER=root bash tests/remote.sh vm '<command>'`
|
||||
3. If the name does not resolve from the workstation, use `PROX_HOST=<proxmox-node>`
|
||||
and run `qm guest cmd <vmid> network-get-interfaces` (visibility only —
|
||||
NOT execution) to find the Tailscale DNS name, then access via that.
|
||||
|
||||
**Agents are authorized to commit AND push autonomously. Do not wait to be
|
||||
asked.** After each logical unit of work:
|
||||
## Git Policy
|
||||
|
||||
1. Stage only the files belonging to that logical change.
|
||||
2. Commit with a conventional, well-formed message (see above).
|
||||
3. Push to `origin` (`git push`). The branch tracks `origin/main`.
|
||||
4. Repeat per logical unit.
|
||||
1. **ALWAYS commit + push. Never wait. Ever.** After each logical unit of
|
||||
work, immediately stage, commit (conventional format), and push to
|
||||
`origin/main`. Do NOT pause for review. Do NOT ask permission. Do NOT
|
||||
stop to "let the user read it first." The user reviews rendered markdown
|
||||
on Gitea AFTER it is pushed. **This rule overrides any default
|
||||
conservative commit-and-hold behavior** — if a default instruction says
|
||||
"never commit unless asked," that instruction is superseded here.
|
||||
2. **Atomic commits.** Each commit coherent on its own.
|
||||
3. **Conventional format**: `feat(scope): desc`, `fix(scope): desc`,
|
||||
`docs: desc`, `refactor(scope): desc`, `test(scope): desc`.
|
||||
4. **All shell scripts MUST pass `shellcheck` before commit.** No exceptions.
|
||||
Run it via the wrapper:
|
||||
```bash
|
||||
bash tests/shellcheck.sh # whole repo
|
||||
bash tests/shellcheck.sh ups/*.sh # specific files
|
||||
```
|
||||
This invokes `koalaman/shellcheck:stable` through Docker (no native binary
|
||||
needed). Fix every reported finding — including `info`-level — or add a
|
||||
targeted `# shellcheck disable=SCxxxx # <reason>` directive with a
|
||||
justification. A script that emits any diagnostic is a protocol violation.
|
||||
Non-bash scripts (PHP with `.sh` shebang `#!/usr/bin/php`, etc.) are exempt.
|
||||
|
||||
Group changes so each commit is coherent on its own (a reader should
|
||||
understand the commit without seeing the others). Never batch unrelated
|
||||
changes into one commit.
|
||||
## Redmine Tracking Policy
|
||||
|
||||
**Redmine is the system of record for all work.** Do not track status,
|
||||
checklists, or TODOs in repo files. Use Redmine tickets instead.
|
||||
|
||||
- **URL:** https://projects.knownelement.com
|
||||
- **Version:** Potential to Kinetic Ready (due 2026-09-30)
|
||||
- **Project:** Known Element Enterprises - Technology & Facility Services (id 55)
|
||||
|
||||
### Rules
|
||||
1. **Every piece of work** (feature, fix, deployment, config change) gets a
|
||||
Redmine ticket. If one doesn't exist, create it.
|
||||
2. **Reference tickets in docs and commits** using `[#NNN]` notation.
|
||||
Example: `[#367] Rebuilt k3s control plane after cnode wipe`.
|
||||
3. **When work completes**, update the ticket: set done ratio to 100%,
|
||||
add a note describing what was done and where the code lives.
|
||||
**NEVER close a ticket without explicit user permission.** You may
|
||||
SUGGEST a close when the result is clearly scoped and delivered. If
|
||||
it's ambiguous whether the work is truly complete, don't suggest a
|
||||
close — leave that decision to the user.
|
||||
4. **Operations Status** lives on Discourse ([topic #297](https://community.turnsys.com/t/297)) — update that wiki topic if the infrastructure summary needs refreshing. The `STATUS.md` file in git is now a pointer only.
|
||||
5. **Link code to tickets** — ticket descriptions and notes should reference
|
||||
the relevant file paths in this repo (e.g., `dcinfra/ups/`).
|
||||
|
||||
### CLI access (read + write)
|
||||
|
||||
Tickets are managed via the `redmine-cli` container, invoked directly
|
||||
with `docker run` (no wrapper script). Full command reference, patterns, and
|
||||
the subtask escape hatch live in the CLI's own `AGENTS.md`
|
||||
(`~/projects/KNEL-AIMiddleware/tooling-cli/redmine/AGENTS.md`) — read it
|
||||
for anything beyond the basics.
|
||||
|
||||
```bash
|
||||
# Connection sanity check (run first in any session):
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest whoami
|
||||
|
||||
# Your queue (project 55):
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest list --assigned-to-me -p 55
|
||||
|
||||
# Show / create / update / close:
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest show 367
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest create -p 55 -s "Subject" -d "desc"
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest update 367 -n "Done: committed in abc123" --done-ratio 100
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest close 367
|
||||
```
|
||||
|
||||
Key IDs: project **55** (`technicaloperations`), user **5** (`reachableceo`).
|
||||
Statuses: New(1), In Progress(2), Resolved(3,closed), Feedback(4), Closed(5),
|
||||
Rejected(6). New subtasks go to **Feedback (4)**. Tracker **3** = Support.
|
||||
**Gotcha:** `create` has no `--parent` flag — to make a subtask, use the
|
||||
`python-redmine` escape hatch inside the container (see
|
||||
`tooling-cli/redmine/AGENTS.md`). Always `show` a ticket before updating it.
|
||||
|
||||
Credentials (`REDMINE_URL`/`REDMINE_API_KEY`) live in the centralized store
|
||||
at `~/.creds/redmine.env`.
|
||||
|
||||
## Documentation Workflow
|
||||
|
||||
**Discourse is the source of truth for all knowledge docs.** After any work
|
||||
session, an agent MUST:
|
||||
|
||||
1. **Update Discourse wiki topics** — if infrastructure facts changed (new
|
||||
VM, IP change, host retired), edit the relevant wiki topic at
|
||||
[community.turnsys.com/c/vp-techops](https://community.turnsys.com/c/vp-techops).
|
||||
2. **Update the Operations Status topic** ([#297](https://community.turnsys.com/t/297))
|
||||
if tickets were opened or closed.
|
||||
3. **Grep for stale paths in code** — `grep -rn 'old/path' --include='*.sh'`
|
||||
after any rename or restructure. Fix all references in the same commit.
|
||||
4. **If a new top-level directory was created**, update:
|
||||
- `AGENTS.md` → "Repository Layout" code block
|
||||
- `AGENTS.md` → "Key Scripts" table (if it has an entrypoint script)
|
||||
- Create a new Discourse wiki topic for any documentation
|
||||
5. **Self-audit before commit.** Code changes must be internally consistent.
|
||||
Documentation changes go to Discourse, not git.
|
||||
|
||||
### CLI access (read + write)
|
||||
|
||||
Wiki topics are managed via the `discourse-cli` container, invoked directly
|
||||
with `docker run` (no wrapper script). Full command reference, patterns, and
|
||||
the raw-API escape hatch live in the CLI's own `AGENTS.md`
|
||||
(`~/projects/KNEL-AIMiddleware/tooling-cli/discourse/AGENTS.md`) — read it
|
||||
for anything beyond the basics.
|
||||
|
||||
```bash
|
||||
# Connection sanity check (run first in any session):
|
||||
docker run --rm --env-file ~/.creds/discourse.env \
|
||||
git.knownelement.com/reachableceo/discourse-cli:latest whoami
|
||||
|
||||
# List VP TechOps topics:
|
||||
docker run --rm --env-file ~/.creds/discourse.env \
|
||||
git.knownelement.com/reachableceo/discourse-cli:latest ls -c vp-techops
|
||||
|
||||
# Show a topic / edit a wiki post (find post id via `show`):
|
||||
docker run --rm --env-file ~/.creds/discourse.env \
|
||||
git.knownelement.com/reachableceo/discourse-cli:latest show 297
|
||||
docker run --rm --env-file ~/.creds/discourse.env \
|
||||
git.knownelement.com/reachableceo/discourse-cli:latest update <post_id> -b "new markdown body"
|
||||
```
|
||||
|
||||
VP TechOps = category **74**. Key topics: #296 (project overview), #297
|
||||
(ops status), #298 (audit log). The API user is trust-level 4 but **not
|
||||
admin** — admin-only ops (category creation, setting the wiki flag) will
|
||||
403; surface those to the user rather than retrying. **Gotcha:**
|
||||
`update`/`delete` take a post **id**, not a post number. Never create a new
|
||||
topic for an update to existing knowledge — edit the wiki post in place.
|
||||
|
||||
Credentials (`DISCOURSE_URL`/`DISCOURSE_API_KEY`/`DISCOURSE_API_USERNAME`)
|
||||
live in the centralized store at `~/.creds/discourse.env`.
|
||||
|
||||
## Key Scripts
|
||||
|
||||
| Script | Purpose |
|
||||
|--------|---------|
|
||||
| [`scripts/check-rules.sh`](scripts/check-rules.sh) | Rule audit engine (shellcheck, image pinning, Discourse pointers, required files) |
|
||||
| [`scripts/setup-hooks.sh`](scripts/setup-hooks.sh) | Install git hooks (pre-commit, pre-push) |
|
||||
| [`tests/remote.sh`](tests/remote.sh) | **SSH chokepoint** — all Proxmox host + sandbox VM access routes here |
|
||||
| [`netinfra/dns-cluster-setup/remote-dns.sh`](netinfra/dns-cluster-setup/remote-dns.sh) | SSH chokepoint for DNS infra hosts (netinfra-01/02, tsrouter, netboot) |
|
||||
| `redmine-cli` container | Redmine CLI (ticket read/write via `docker run`; see `tooling-cli/redmine/`) |
|
||||
| `discourse-cli` container | Discourse CLI (wiki topic read/write via `docker run`; see `tooling-cli/discourse/`) |
|
||||
| `dns-cli` container | Technitium DNS CLI (zones, list, add, delete, search, flush; see `tooling-cli/dns/`) |
|
||||
| [`tests/vm-validation.sh`](tests/vm-validation.sh) | Deploy + validate on sandbox VM |
|
||||
| [`tests/run-tests.sh`](tests/run-tests.sh) | Test suite |
|
||||
| [`netinfra/dns-cluster-setup/setup.sh`](netinfra/dns-cluster-setup/setup.sh) | DNS cluster replication |
|
||||
| [`k8s/install-cp.sh`](k8s/install-cp.sh) | Bootstrap k3s HA control plane |
|
||||
| [`dcinfra/powerman/setup.sh`](dcinfra/powerman/setup.sh) | Configure Cyclades PDU via powerman |
|
||||
| [`dcinfra/console/setup.sh`](dcinfra/console/setup.sh) | Configure serial console access via ser2net + conman |
|
||||
| [`dcinfra/ups/setup.sh`](dcinfra/ups/setup.sh) | Configure NUT (Network UPS Tools) for UPS monitoring |
|
||||
| [`proxmox/perf/deploy-tuning.sh`](proxmox/perf/deploy-tuning.sh) | Deploy perf tunings |
|
||||
| [`proxmox/perf/scripts/`](proxmox/perf/scripts/) | Read-only audit: probe-storage, probe-network, conman-console, snmp-switch-audit, probe-drift, audit-vm-disks, audit-guest-io, deploy-tuned-guests |
|
||||
|
||||
## Switch Console Access (conman)
|
||||
|
||||
Switch configs are pulled via serial console through a conman + ser2net
|
||||
stack on pfv-tsys4.
|
||||
|
||||
- **conmand server:** pfv-tsys4 (port 7890)
|
||||
- **ser2net:** pfv-tsys4, TCP ports 2001-2006
|
||||
(do NOT connect to ser2net directly — it conflicts with conman's
|
||||
persistent sessions; always use the conman client)
|
||||
- **Script:** [`proxmox/perf/scripts/conman-console.py`](proxmox/perf/scripts/conman-console.py)
|
||||
— drives console sessions read-only via PTY. No expect/tcl required.
|
||||
- **Command files:** [`netinfra/switches/`](netinfra/switches/) — `.cmds` files
|
||||
with switch-specific show commands
|
||||
- **Query available consoles:** `conman -d 100.70.77.93 -q`
|
||||
|
||||
```bash
|
||||
# Pull a switch config (example):
|
||||
CONMAN_SERVER=100.70.77.93:7890 python3 proxmox/perf/scripts/conman-console.py \
|
||||
--console pfv-r5-core-01 --cmds netinfra/switches/pfv-r5-core-01.cmds
|
||||
```
|
||||
|
||||
| Console name | TCP port | Device |
|
||||
|--------------|----------|--------|
|
||||
| pfv-r5-core-01 | 2001 | Dell PowerConnect 5448 (rack 5 core, mgmt+storage) |
|
||||
| pfv-r3-tor-mgmt-01 | 2002 | Dell PowerConnect 5324 (rack 3 mgmt TOR) |
|
||||
| pfv-r3-tor-stor-01 | 2003 | Dell PowerConnect 5324 (rack 3 storage TOR) |
|
||||
| pfv-rrinfra-rtr | 2004 | Cisco router (rrinfra) |
|
||||
| pfv-r2-tor-01 | 2005 | Rack 2 TOR switch |
|
||||
| pfv-r6-mgmt-01 | 2006 | Rack 6 management switch |
|
||||
|
||||
## Mandatory: Document ALL Infrastructure Changes
|
||||
|
||||
**This is non-negotiable. Every infrastructure change (VM config, disk
|
||||
cache, network setting, service config, storage migration) MUST be
|
||||
documented BEFORE moving to the next task step — not "later" or "at the
|
||||
end."**
|
||||
|
||||
Required for EVERY infrastructure change:
|
||||
|
||||
1. **Redmine ticket** — create one if none exists. Reference as `[#NNN]`.
|
||||
2. **Discourse audit log** — reply to topic
|
||||
[#298](https://community.turnsys.com/t/298) with a dated entry (what
|
||||
changed, why, where).
|
||||
3. **Discourse relevant wiki topic** — update the architecture/reference
|
||||
topic if the change affects documented infrastructure facts (storage
|
||||
#300, network #299, k8s #305, etc.).
|
||||
4. **Git commit** — if code/config changed in the repo, commit + push
|
||||
immediately per the Git Policy above.
|
||||
|
||||
## Tooling
|
||||
|
||||
- `gh`, `docker`, `jq` available on the workstation.
|
||||
- No native shellcheck — use `bash tests/shellcheck.sh` (Docker wrapper
|
||||
`koalaman/shellcheck:stable`). ALL scripts must pass including info-level.
|
||||
- For raw API calls not covered by the Redmine/Discourse CLIs, use
|
||||
`python3` inside the CLI Docker containers (escape hatch pattern in
|
||||
`tooling-cli/{discourse,redmine}/AGENTS.md`).
|
||||
- `curl`/`wget`/`httpie` may be blocked by some harnesses. Use the CLIs or
|
||||
the python-in-Docker escape hatch for HTTP writes.
|
||||
|
||||
## Key Commands Quick Reference
|
||||
|
||||
```bash
|
||||
# Tests + validation:
|
||||
bash tests/run-tests.sh # test suite
|
||||
bash tests/vm-validation.sh # VM validation
|
||||
bash tests/shellcheck.sh # shellcheck whole repo
|
||||
bash tests/shellcheck.sh path/to/*.sh # shellcheck specific files
|
||||
|
||||
# Redmine + Discourse sanity checks (run first in any session):
|
||||
docker run --rm --env-file ~/.creds/redmine.env \
|
||||
git.knownelement.com/reachableceo/redmine-cli:latest whoami
|
||||
docker run --rm --env-file ~/.creds/discourse.env \
|
||||
git.knownelement.com/reachableceo/discourse-cli:latest whoami
|
||||
|
||||
# Proxmox host access (DNS names only — never IPs):
|
||||
PROX_HOST=pfv-tsys5 bash tests/remote.sh prox 'qm list'
|
||||
PROX_HOST=pfv-tsys5 bash tests/remote.sh prox 'pvesm status'
|
||||
|
||||
# Production VM access (DNS names only — never IPs):
|
||||
VM_IP=tsys-librenms VM_USER=root bash tests/remote.sh vm 'systemctl status cron'
|
||||
|
||||
# DNS infra access:
|
||||
bash netinfra/dns-cluster-setup/remote-dns.sh netinfra01-root 'systemctl status docker'
|
||||
|
||||
# Switch console (read-only config pull — DNS names only):
|
||||
CONMAN_SERVER=pfv-tsys4:7890 python3 proxmox/perf/scripts/conman-console.py \
|
||||
--console pfv-r5-core-01 --cmds netinfra/switches/pfv-r5-core-01.cmds
|
||||
```
|
||||
|
||||
## Credential Management
|
||||
|
||||
- API keys currently in `.env` files under KNEL-AIMiddleware (gitignored).
|
||||
- User goal: migrate all keys to Hashicorp Vault
|
||||
(`vault.knownelement.com`). No vault token present yet
|
||||
(`~/.vault-token` missing). Track as high-priority TODO.
|
||||
|
||||
## Key Docs
|
||||
|
||||
→ **All documentation lives on Discourse:**
|
||||
[community.turnsys.com/c/vp-techops](https://community.turnsys.com/c/vp-techops)
|
||||
|
||||
→ All `.md` files in this repo are pointers to Discourse topics.
|
||||
|
||||
→ **Complete Linux System Inventory:**
|
||||
[Topic #307](https://community.turnsys.com/t/307) — every Linux system
|
||||
(hosts + VMs + physical), with Tailscale IPs, DNS names, SSH access
|
||||
status, and tuned profiles. Reference this for monitoring coverage,
|
||||
access management, and hostname consistency.
|
||||
|
||||
## Project Context
|
||||
|
||||
Solo-founder R&D Proxmox cluster in a private residence. Shoestring budget.
|
||||
Production lives on a Cloudron VPS in Reston VA. See the
|
||||
[Operations Status topic](https://community.turnsys.com/t/297) for the ticket
|
||||
index and infrastructure summary.
|
||||
All work is tracked in [Redmine](https://projects.knownelement.com)
|
||||
(version: Potential to Kinetic Ready, due 2026-09-30).
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Makefile — convenience dispatch to scripts/.
|
||||
#
|
||||
# Not required. The scripts in scripts/ are the real entry points and work
|
||||
# standalone. This file just gives you short verbs if you're at a terminal.
|
||||
#
|
||||
# In Mode 2 (Hermes/OWUI/MCP), agents call the scripts directly or via API —
|
||||
# they don't need this file.
|
||||
|
||||
# Project-specific overrides for check-rules.sh
|
||||
export PROJECT_DOC_EXEMPT ?= AGENTS.md STATUS.md WORKING.md README.md ADOPTING.md LICENSE .env.example questions-v1.md BASELINE-PROMPT.md PATTERNS.md
|
||||
export PROJECT_DISCOURSE_HOST ?= community.turnsys.com
|
||||
|
||||
.PHONY: setup validate fast lint test garden up down status clean help
|
||||
|
||||
help: ## Show available targets
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
setup: ## Install git hooks
|
||||
@bash scripts/setup-hooks.sh
|
||||
|
||||
validate: ## Full rule audit (includes tests)
|
||||
@bash scripts/check-rules.sh
|
||||
|
||||
fast: ## Fast rule audit (pre-commit equivalent)
|
||||
@bash scripts/check-rules.sh --fast
|
||||
|
||||
lint: ## Lint shell scripts (shellcheck via docker)
|
||||
@docker run --rm -v "$$(pwd):/mnt" koalaman/shellcheck:stable \
|
||||
$$(find . -path ./.git -prune -o -path ./.tmp -prune -o -path ./vendor -prune -o -path ./node_modules -prune -o \( -name '*.sh' -o -name '*.bash' \) -print | sed 's|^\./|/mnt/|') || true
|
||||
|
||||
test: ## Run the test suite (override per project)
|
||||
@bash scripts/test.sh
|
||||
|
||||
garden: ## Doc-sprawl / Discourse-migration report
|
||||
@bash scripts/garden.sh
|
||||
|
||||
up: ## Bring up the docker-compose stack
|
||||
@bash scripts/up.sh
|
||||
|
||||
down: ## Bring down the docker-compose stack
|
||||
@bash scripts/down.sh
|
||||
|
||||
status: ## Show repo status snapshot
|
||||
@echo "== branch =="; git branch --show-current 2>/dev/null || echo "(no branch)"
|
||||
@echo "== last commit =="; git log --oneline -1 2>/dev/null || true
|
||||
@echo "== working tree =="; git status --short 2>/dev/null || echo "(not a git repo)"
|
||||
@echo "== STATUS.md head =="; sed -n '1,12p' STATUS.md 2>/dev/null || echo "(no STATUS.md)"
|
||||
|
||||
clean: ## Remove build/test artifacts (override per project)
|
||||
@echo "make clean: nothing to clean — override this in your project's Makefile."
|
||||
@@ -1,176 +0,0 @@
|
||||
# TSYS FetchApply Testing Framework
|
||||
|
||||
## Overview
|
||||
|
||||
This testing framework provides comprehensive validation for the TSYS FetchApply infrastructure provisioning system. It includes unit tests, integration tests, security tests, and system validation.
|
||||
|
||||
## Test Categories
|
||||
|
||||
### 1. Unit Tests (`unit/`)
|
||||
- **Purpose:** Test individual framework functions and components
|
||||
- **Scope:** Framework includes, helper functions, syntax validation
|
||||
- **Example:** `framework-functions.sh` - Tests logging, pretty print, and error handling functions
|
||||
|
||||
### 2. Integration Tests (`integration/`)
|
||||
- **Purpose:** Test complete workflows and module interactions
|
||||
- **Scope:** End-to-end deployment scenarios, module integration
|
||||
- **Future:** Module interaction testing, deployment workflow validation
|
||||
|
||||
### 3. Security Tests (`security/`)
|
||||
- **Purpose:** Validate security configurations and practices
|
||||
- **Scope:** HTTPS enforcement, deployment security, SSH hardening
|
||||
- **Example:** `https-enforcement.sh` - Validates all URLs use HTTPS
|
||||
|
||||
### 4. Validation Tests (`validation/`)
|
||||
- **Purpose:** System compatibility and pre-flight checks
|
||||
- **Scope:** System requirements, network connectivity, permissions
|
||||
- **Example:** `system-requirements.sh` - Validates minimum system requirements
|
||||
|
||||
## Usage
|
||||
|
||||
### Run All Tests
|
||||
```bash
|
||||
./Project-Tests/run-tests.sh
|
||||
```
|
||||
|
||||
### Run Specific Test Categories
|
||||
```bash
|
||||
./Project-Tests/run-tests.sh unit # Unit tests only
|
||||
./Project-Tests/run-tests.sh integration # Integration tests only
|
||||
./Project-Tests/run-tests.sh security # Security tests only
|
||||
./Project-Tests/run-tests.sh validation # Validation tests only
|
||||
```
|
||||
|
||||
### Run Individual Tests
|
||||
```bash
|
||||
./Project-Tests/validation/system-requirements.sh
|
||||
./Project-Tests/security/https-enforcement.sh
|
||||
./Project-Tests/unit/framework-functions.sh
|
||||
```
|
||||
|
||||
## Test Results
|
||||
|
||||
- **Console Output:** Real-time test results with color-coded status
|
||||
- **JSON Reports:** Detailed test reports saved to `logs/tests/`
|
||||
- **Exit Codes:** 0 for success, 1 for failures
|
||||
|
||||
## Configuration Validation
|
||||
|
||||
The validation framework performs pre-flight checks to ensure system compatibility:
|
||||
|
||||
### System Requirements
|
||||
- **Memory:** Minimum 2GB RAM
|
||||
- **Disk Space:** Minimum 10GB available
|
||||
- **OS Compatibility:** Ubuntu/Debian (tested), others (may work)
|
||||
|
||||
### Network Connectivity
|
||||
- Tests connection to required download sources
|
||||
- Validates HTTPS endpoints are accessible
|
||||
- Checks for firewall/proxy issues
|
||||
|
||||
### Command Dependencies
|
||||
- Verifies required tools are installed (`curl`, `wget`, `git`, `systemctl`, `apt-get`)
|
||||
- Checks for proper versions where applicable
|
||||
|
||||
### Permissions
|
||||
- Validates write access to system directories
|
||||
- Checks for required administrative privileges
|
||||
|
||||
## Adding New Tests
|
||||
|
||||
### Test File Structure
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
function test_something() {
|
||||
echo "🔍 Testing something..."
|
||||
|
||||
if [[ condition ]]; then
|
||||
echo "✅ Test passed"
|
||||
return 0
|
||||
else
|
||||
echo "❌ Test failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function main() {
|
||||
echo "🧪 Running Test Suite Name"
|
||||
echo "=========================="
|
||||
|
||||
local total_failures=0
|
||||
test_something || ((total_failures++))
|
||||
|
||||
echo "=========================="
|
||||
if [[ $total_failures -eq 0 ]]; then
|
||||
echo "✅ All tests passed"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ $total_failures tests failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
main "$@"
|
||||
fi
|
||||
```
|
||||
|
||||
### Test Categories Guidelines
|
||||
|
||||
- **Unit Tests:** Focus on individual functions, fast execution
|
||||
- **Integration Tests:** Test module interactions, longer execution
|
||||
- **Security Tests:** Validate security configurations
|
||||
- **Validation Tests:** Pre-flight system checks
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
The testing framework is designed to integrate with CI/CD pipelines:
|
||||
|
||||
```bash
|
||||
# Example CI script
|
||||
./Project-Tests/run-tests.sh all
|
||||
test_exit_code=$?
|
||||
|
||||
if [[ $test_exit_code -eq 0 ]]; then
|
||||
echo "All tests passed - deployment approved"
|
||||
else
|
||||
echo "Tests failed - deployment blocked"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## Test Development Best Practices
|
||||
|
||||
1. **Clear Test Names:** Use descriptive function names
|
||||
2. **Proper Exit Codes:** Return 0 for success, 1 for failure
|
||||
3. **Informative Output:** Use emoji and clear messages
|
||||
4. **Timeout Protection:** Use timeout for network operations
|
||||
5. **Cleanup:** Remove temporary files and resources
|
||||
6. **Error Handling:** Use `set -euo pipefail` for strict error handling
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
- **Permission Denied:** Run tests with appropriate privileges
|
||||
- **Network Timeouts:** Check firewall and proxy settings
|
||||
- **Missing Dependencies:** Install required tools before testing
|
||||
- **Script Errors:** Validate syntax with `bash -n script.sh`
|
||||
|
||||
### Debug Mode
|
||||
```bash
|
||||
# Enable debug output
|
||||
export DEBUG=1
|
||||
./Project-Tests/run-tests.sh
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
When adding new functionality to FetchApply:
|
||||
|
||||
1. Add corresponding tests in appropriate category
|
||||
2. Run full test suite before committing
|
||||
3. Update documentation for new test cases
|
||||
4. Ensure tests pass in clean environment
|
||||
@@ -1 +0,0 @@
|
||||
export HISTTIMEFORMAT="%m/%d/%Y %T "
|
||||
@@ -1,139 +0,0 @@
|
||||
# AI Review: KNELServerBuild (FetchApply) Project
|
||||
|
||||
## Executive Summary
|
||||
|
||||
The KNELServerBuild project is a comprehensive Infrastructure-as-Code (IaC) solution designed for provisioning Linux servers within the TSYS Group environment. The project implements a fetch-and-apply framework that automates the setup and hardening of server systems, incorporating security, monitoring, and operational components.
|
||||
|
||||
## Project Overview
|
||||
|
||||
The FetchApply project is a shell-based automation framework that provisions Linux servers with:
|
||||
- Security hardening (SSH, 2FA, Wazuh, STIG compliance)
|
||||
- Operational monitoring (LibreNMS, cockpit, SNMP)
|
||||
- System packages and configurations for enterprise operations
|
||||
- Network discovery and management capabilities
|
||||
|
||||
## Architecture and Structure
|
||||
|
||||
### Key Components
|
||||
- **ProjectCode/**: Main setup and configuration scripts
|
||||
- **Project-ConfigFiles/**: Configuration variables and parameters
|
||||
- **Project-Includes/**: Reusable shell functions and utilities
|
||||
- **Project-Tests/**: Comprehensive testing framework
|
||||
- **Modules/**: Functional modules for security, operations, etc.
|
||||
- **vendor/**: External dependencies and frameworks
|
||||
|
||||
### Core Workflow
|
||||
The `SetupNewSystem.sh` orchestrates:
|
||||
1. Preflight checks and environment validation
|
||||
2. Package installation and system updates
|
||||
3. Service configuration and hardening
|
||||
4. Security implementation (SSH, Wazuh, 2FA)
|
||||
5. Operational monitoring setup
|
||||
|
||||
## Strengths
|
||||
|
||||
### 1. Comprehensive Testing Framework
|
||||
- Well-structured testing with unit, integration, security, and validation categories
|
||||
- Clear documentation and usage instructions
|
||||
- JSON reporting for CI/CD integration
|
||||
|
||||
### 2. Security-First Approach
|
||||
- Multiple layers of security hardening (SSH, 2FA, audit agents)
|
||||
- STIG compliance for government/hybrid environments
|
||||
- Proper permission management and configuration validation
|
||||
|
||||
### 3. Modular Architecture
|
||||
- Separated concerns into functional modules
|
||||
- Reusable functions and components
|
||||
- Clear separation between framework and project-specific code
|
||||
|
||||
### 4. Operational Readiness
|
||||
- Built-in monitoring and alerting
|
||||
- System performance optimization
|
||||
- Network discovery and management tools
|
||||
|
||||
### 5. Cross-Platform Considerations
|
||||
- Detection for different hardware types (physical, virtual, Raspberry Pi)
|
||||
- Distribution-specific handling
|
||||
- Environment-aware configurations
|
||||
|
||||
## Areas for Improvement
|
||||
|
||||
### 1. Documentation Completeness
|
||||
- README mentions usage but lacks detailed architecture overview
|
||||
- Missing troubleshooting and recovery procedures
|
||||
- Limited guidance for extending/adding new modules
|
||||
|
||||
### 2. Security and Secrets Management
|
||||
- Configuration files may expose hardcoded credentials or tokens
|
||||
- No clear secrets management strategy
|
||||
- Download URLs and endpoints are hardcoded in scripts
|
||||
|
||||
### 3. Error Handling and Resilience
|
||||
- While scripts have basic error handling, recovery mechanisms are limited
|
||||
- No rollback capabilities for failed installations
|
||||
- Some operations may fail silently
|
||||
|
||||
### 4. Scalability and Performance
|
||||
- Scripts execute sequentially without parallelization
|
||||
- No caching mechanisms for downloads
|
||||
- Limited handling for high-latency networks
|
||||
|
||||
### 5. Configuration Management
|
||||
- Configuration values scattered across multiple files
|
||||
- No centralized configuration management
|
||||
- Difficult to customize for different environments
|
||||
|
||||
## Recommendations
|
||||
|
||||
### 1. Enhance Security Practices
|
||||
- Implement secrets management (HashiCorp Vault, AWS Secrets Manager, etc.)
|
||||
- Add configuration validation before applying changes
|
||||
- Implement digital signature verification for downloaded content
|
||||
- Add security scanning of packages before installation
|
||||
|
||||
### 2. Improve Testing Coverage
|
||||
- Add end-to-end tests for complete deployment scenarios
|
||||
- Implement performance benchmarks
|
||||
- Add security validation tests
|
||||
- Include tests for different hardware configurations
|
||||
|
||||
### 3. Add Monitoring and Observability
|
||||
- Implement deployment success/failure metrics
|
||||
- Add progress tracking for long-running operations
|
||||
- Include health checks post-deployment
|
||||
- Add rollback mechanisms for failed deployments
|
||||
|
||||
### 4. Refactor for Maintainability
|
||||
- Centralize configuration management
|
||||
- Abstract environment-specific variables
|
||||
- Implement plugin architecture for new modules
|
||||
- Add proper logging and audit trails
|
||||
|
||||
### 5. Enhance Usability
|
||||
- Add dry-run functionality for testing changes
|
||||
- Provide rollback/recovery procedures
|
||||
- Add interactive mode for new users
|
||||
- Implement configuration templates
|
||||
|
||||
## Technical Debt Assessment
|
||||
|
||||
### High Priority
|
||||
- Centralized configuration management
|
||||
- Secrets handling and security
|
||||
- Error recovery and rollback mechanisms
|
||||
|
||||
### Medium Priority
|
||||
- Parallel execution of independent operations
|
||||
- Caching for downloaded packages/configs
|
||||
- Improved logging and monitoring
|
||||
|
||||
### Low Priority
|
||||
- Code modernization (consider newer shell features)
|
||||
- Migration to configuration management tools (Ansible/Terraform)
|
||||
|
||||
## Conclusion
|
||||
|
||||
The FetchApply project represents a solid foundation for automated server provisioning with good security practices and testing. However, there are significant opportunities to improve security, maintainability, and operational resilience. Prioritizing security improvements and configuration management would provide the greatest value to the project's stability and long-term viability.
|
||||
|
||||
The modular architecture and comprehensive testing framework provide a strong foundation for future enhancements and improvements.
|
||||
@@ -1,44 +0,0 @@
|
||||
# AI Overview of KNELServerBuild
|
||||
|
||||
This is an AI-generated overview of the KNELServerBuild project. The analysis is based on a read-only review of the project's files.
|
||||
|
||||
## Project Overview
|
||||
|
||||
The KNELServerBuild project is an Infrastructure as Code (IAC) repository for provisioning and configuring Linux servers. It is based on a collection of bash scripts that automate the installation of packages, configuration of services, and security hardening of the system. The project is designed to be used with the `FetchApply` tool, which is not included in this repository.
|
||||
|
||||
The main entry point of the project is the `ProjectCode/SetupNewSystem.sh` script. This script performs the following actions:
|
||||
|
||||
* **Initializes the environment:** Sets up project paths and sources a shell framework (`KNELShellFramework`) and project-specific includes.
|
||||
* **Installs packages:** Installs a wide range of packages, including monitoring agents (check_mk, snmp), security tools (auditd, aide, lynis, clamav), administration tools (cockpit, webmin), and common utilities (tmux, vim, zsh).
|
||||
* **Configures services:** Configures various services like Postfix for email, `rsyslog` for system logging, `snmpd` for monitoring, `lldpd` for network discovery, and `cockpit`.
|
||||
* **Security Hardening:** It runs a series of security hardening scripts from `Modules/Security`, including `secharden-ssh.sh`, `secharden-wazuh.sh`, `secharden-2fa.sh`, and `secharden-scap-stig.sh`.
|
||||
* **OAM:** It runs an OAM (Operations, Administration, and Maintenance) script for LibreNMS.
|
||||
* **Conditional Logic:** It has conditional logic to apply different configurations based on whether the host is a physical Dell server, a virtual machine (KVM or Hyper-V), or a Raspberry Pi.
|
||||
|
||||
## What I Like
|
||||
|
||||
* **Well-structured:** The project is well-structured, with separate directories for code, configuration files, documentation, and tests. This makes it easy to understand and maintain.
|
||||
* **Modularity:** The use of modules for different functionalities (e.g., security hardening, OAM) is a good practice. It allows for easy extension and modification of the project.
|
||||
* **Comprehensive:** The project covers a wide range of aspects of server provisioning, from package installation to security hardening.
|
||||
* **Conditional Logic:** The use of conditional logic to adapt the configuration to different environments is a good feature.
|
||||
* **Good commenting:** The scripts are generally well-commented, which makes them easier to understand.
|
||||
|
||||
## Areas for Improvement
|
||||
|
||||
* **Error Handling:** The scripts could benefit from more robust error handling. For example, the `SetupNewSystem.sh` script uses `set -e` to exit on error, but it does not have any specific error handling logic.
|
||||
* **Idempotency:** The scripts are not fully idempotent. For example, some of the `curl` commands will re-download files even if they already exist. This could be improved by adding checks to see if the files already exist.
|
||||
* **Testing:** The project has a `Project-Tests` directory, but it is not clear how the tests are run or what they cover. The testing framework could be improved to provide more comprehensive coverage of the project's functionality.
|
||||
* **Secrets Management:** The scripts contain some hardcoded secrets, such as the `relayhost` for Postfix. These secrets should be managed using a secrets management tool like HashiCorp Vault or AWS Secrets Manager.
|
||||
* **Configuration Management:** The project uses a collection of shell scripts to manage the configuration of the system. While this works, it can be difficult to manage and maintain in the long run. A configuration management tool like Ansible, Puppet, or Chef would be a better choice for this task. The project already installs `ansible-core`, so it would be a natural progression to move the logic to Ansible playbooks.
|
||||
* **Documentation:** The project has some documentation, but it could be improved. For example, the `README.md` file could provide more information on how to use the project and how to contribute to it.
|
||||
|
||||
## Recommendations
|
||||
|
||||
* **Improve Error Handling:** Add more robust error handling to the scripts to make them more reliable.
|
||||
* **Improve Idempotency:** Make the scripts more idempotent to avoid unnecessary re-downloads and re-configurations.
|
||||
* **Improve Testing:** Implement a more comprehensive testing framework to ensure the quality of the project.
|
||||
* **Use a Secrets Management Tool:** Use a secrets management tool to manage the secrets in the project.
|
||||
* **Use a Configuration Management Tool:** Use a configuration management tool like Ansible to manage the configuration of the system.
|
||||
* **Improve Documentation:** Improve the documentation of the project to make it easier to use and contribute to.
|
||||
|
||||
Overall, the KNELServerBuild project is a good starting point for an IAC repository. It is well-structured and covers a wide range of aspects of server provisioning. However, there are some areas where it could be improved. By addressing the areas for improvement, the project can be made more robust, reliable, and maintainable.
|
||||
@@ -1,308 +0,0 @@
|
||||
# AI Overview: KNEL Server Build (FetchApply) Project
|
||||
|
||||
**Date:** December 26, 2025
|
||||
**Reviewer:** OpenCode AI Assistant
|
||||
**Project:** TSYS Infrastructure Provisioning System
|
||||
|
||||
## Executive Summary
|
||||
|
||||
The KNEL Server Build project is a comprehensive Infrastructure as Code (IaC) system for Linux server provisioning and security hardening. It demonstrates strong architectural patterns with a modular framework approach but has several areas requiring improvement for production readiness, security, and maintainability.
|
||||
|
||||
## Architecture Assessment
|
||||
|
||||
### Strengths ✅
|
||||
|
||||
**1. Modular Framework Design**
|
||||
- Well-structured KNELShellFramework with centralized includes
|
||||
- Clear separation between framework, project code, and configuration
|
||||
- Consistent pattern for sourcing framework components
|
||||
- Proper abstraction of common functionality
|
||||
|
||||
**2. Comprehensive Security Modules**
|
||||
- Extensive security hardening capabilities (SSH, Wazuh, 2FA, SCAP/STIG)
|
||||
- HTTPS enforcement throughout
|
||||
- Proper audit logging integration
|
||||
- Good compliance focus with industry standards
|
||||
|
||||
**3. Testing Infrastructure**
|
||||
- Automated test suite with multiple categories (unit, integration, security, validation)
|
||||
- JSON-based test reporting
|
||||
- Good test organization and coverage
|
||||
|
||||
**4. Documentation Excellence**
|
||||
- Comprehensive deployment guide with troubleshooting
|
||||
- Detailed development guidelines with best practices
|
||||
- Security documentation with threat model
|
||||
- Code review findings and refactoring examples
|
||||
|
||||
### Areas for Improvement ⚠️
|
||||
|
||||
**1. Performance Issues**
|
||||
- Multiple separate package installation commands instead of consolidated approach
|
||||
- Individual file downloads causing network overhead
|
||||
- No connection pooling for multiple downloads from same host
|
||||
|
||||
**2. Security Vulnerabilities**
|
||||
- SSH keys stored in git repository (secrets management needed)
|
||||
- No download integrity verification (checksum validation)
|
||||
- Missing comprehensive input validation
|
||||
- Unquoted variable expansions creating injection risks
|
||||
|
||||
**3. Error Handling Gaps**
|
||||
- Network operations lack timeout and retry logic
|
||||
- Inconsistent error handling across modules
|
||||
- Missing graceful failure handling in critical paths
|
||||
|
||||
## Technical Debt Analysis
|
||||
|
||||
### High Priority Issues
|
||||
|
||||
**1. Package Installation Performance**
|
||||
```bash
|
||||
# Current inefficient pattern in SetupNewSystem.sh
|
||||
apt-get -y install git sudo dmidecode curl # Line 27
|
||||
# Later: separate massive apt-get command
|
||||
```
|
||||
**Impact:** 30-40% slower deployments, multiple package cache updates
|
||||
|
||||
**2. Network Resilience**
|
||||
```bash
|
||||
# Vulnerable pattern throughout codebase
|
||||
curl --silent ${DL_ROOT}/path/file >/etc/config
|
||||
```
|
||||
**Impact:** Deployment failures in poor network conditions, no recovery mechanism
|
||||
|
||||
**3. Variable Quoting Security**
|
||||
```bash
|
||||
# Risky pattern
|
||||
chsh -s $(which zsh) root
|
||||
```
|
||||
**Impact:** Potential command injection vulnerabilities
|
||||
|
||||
### Medium Priority Issues
|
||||
|
||||
**1. Framework Consistency**
|
||||
- Not all modules follow established error handling patterns
|
||||
- Inconsistent logging and progress reporting
|
||||
- Mixed coding standards across different components
|
||||
|
||||
**2. Testing Coverage**
|
||||
- Limited integration testing for complex workflows
|
||||
- Missing performance benchmarking tests
|
||||
- No automated regression testing for configuration changes
|
||||
|
||||
## Recommendations
|
||||
|
||||
### Immediate Actions (Week 1-2)
|
||||
|
||||
**1. Implement Safe Download Framework**
|
||||
```bash
|
||||
# Create centralized download function with:
|
||||
# - Connection timeouts (30s)
|
||||
# - Retry logic (3 attempts)
|
||||
# - Checksum validation
|
||||
# - Error recovery
|
||||
```
|
||||
|
||||
**2. Consolidate Package Management**
|
||||
```bash
|
||||
# Single package installation with logical grouping:
|
||||
# - Core system tools
|
||||
# - Security packages
|
||||
# - Monitoring tools
|
||||
# - Development utilities
|
||||
```
|
||||
|
||||
**3. Fix Variable Quoting**
|
||||
- Audit entire codebase for unquoted variables
|
||||
- Implement static analysis check in CI pipeline
|
||||
- Add input validation framework
|
||||
|
||||
### Medium-term Improvements (Month 1-2)
|
||||
|
||||
**1. Secrets Management**
|
||||
- Remove SSH keys from repository
|
||||
- Integrate Bitwarden/Vault for secret storage
|
||||
- Implement key rotation procedures
|
||||
|
||||
**2. Performance Optimization**
|
||||
- Implement batch download operations
|
||||
- Add connection pooling
|
||||
- Create deployment metrics collection
|
||||
|
||||
**3. Enhanced Testing**
|
||||
- Add performance benchmarking
|
||||
- Implement chaos engineering for network failures
|
||||
- Create automated regression testing
|
||||
|
||||
### Long-term Enhancements (Quarter 1)
|
||||
|
||||
**1. Infrastructure Improvements**
|
||||
- Implement configuration backup/restore
|
||||
- Add rollback capability for failed deployments
|
||||
- Create deployment pipeline with staging environments
|
||||
|
||||
**2. Advanced Security**
|
||||
- Implement supply chain security with SBOM
|
||||
- Add automated vulnerability scanning
|
||||
- Create security compliance reporting
|
||||
|
||||
## Code Quality Assessment
|
||||
|
||||
### Positive Patterns
|
||||
- Good function documentation in recent code
|
||||
- Proper error handling in newer modules
|
||||
- Consistent use of framework logging functions
|
||||
- Clear separation of concerns
|
||||
|
||||
### Problem Patterns
|
||||
- Mixed coding styles across files
|
||||
- Inconsistent framework usage
|
||||
- Missing input validation
|
||||
- Hardcoded configuration values
|
||||
|
||||
### Modernization Opportunities
|
||||
|
||||
**1. Containerization**
|
||||
- Consider Docker-based deployment testing
|
||||
- Create immutable infrastructure patterns
|
||||
- Implement blue-green deployments
|
||||
|
||||
**2. Configuration Management**
|
||||
- Move to declarative configuration approach
|
||||
- Implement configuration drift detection
|
||||
- Add automated compliance checking
|
||||
|
||||
**3. Observability**
|
||||
- Implement comprehensive logging with structured formats
|
||||
- Add metrics collection for deployment performance
|
||||
- Create dashboard for system health monitoring
|
||||
|
||||
## Security Posture Review
|
||||
|
||||
### Current Strengths
|
||||
- HTTPS-only downloads
|
||||
- Good SSH hardening practices
|
||||
- Comprehensive audit logging
|
||||
- Regular security scanning integration
|
||||
|
||||
### Critical Gaps
|
||||
- No integrity verification for downloads
|
||||
- Secrets stored in version control
|
||||
- Limited defense in depth
|
||||
- Missing automated security testing
|
||||
|
||||
### Recommended Security Enhancements
|
||||
|
||||
**1. Supply Chain Security**
|
||||
- Implement checksum validation for all downloads
|
||||
- Add GPG signature verification where available
|
||||
- Create SBOM generation for deployments
|
||||
|
||||
**2. Access Control**
|
||||
- Implement role-based access control
|
||||
- Add privileged access management
|
||||
- Create audit trail for all administrative actions
|
||||
|
||||
**3. Continuous Security**
|
||||
- Integrate automated vulnerability scanning
|
||||
- Implement security testing in CI/CD
|
||||
- Create security metrics dashboard
|
||||
|
||||
## Deployment Readiness Assessment
|
||||
|
||||
### Current State: **70% Production Ready**
|
||||
|
||||
**Ready Components:**
|
||||
- Core provisioning functionality
|
||||
- Security hardening modules
|
||||
- Basic testing framework
|
||||
- Documentation
|
||||
|
||||
**Missing Components:**
|
||||
- Robust error handling
|
||||
- Performance optimization
|
||||
- Secrets management
|
||||
- Comprehensive testing
|
||||
|
||||
### Path to Production Readiness
|
||||
|
||||
**Phase 1 (2 weeks):** Critical fixes and performance optimization
|
||||
**Phase 2 (4 weeks):** Security enhancements and testing improvements
|
||||
**Phase 3 (8 weeks):** Advanced features and production hardening
|
||||
|
||||
## Overall Assessment
|
||||
|
||||
### What I Like 🎯
|
||||
|
||||
**1. Architectural Excellence**
|
||||
- The KNELShellFramework shows mature thinking about code organization
|
||||
- Modular approach allows for easy maintenance and extension
|
||||
- Clear separation of concerns between framework and project code
|
||||
|
||||
**2. Security-First Mindset**
|
||||
- Comprehensive security hardening capabilities
|
||||
- Good threat awareness and mitigation strategies
|
||||
- Integration with industry-standard security tools
|
||||
|
||||
**3. Documentation Quality**
|
||||
- Excellent documentation with practical examples
|
||||
- Clear deployment guides with troubleshooting sections
|
||||
- Good development guidelines for team consistency
|
||||
|
||||
### What I Don't Like 🚫
|
||||
|
||||
**1. Performance Oversights**
|
||||
- Multiple package installations causing unnecessary delays
|
||||
- Individual file downloads creating network overhead
|
||||
- No performance metrics or monitoring
|
||||
|
||||
**2. Security Gaps**
|
||||
- Critical vulnerability with secrets in git repository
|
||||
- No download integrity verification
|
||||
- Missing comprehensive input validation
|
||||
|
||||
**3. Code Quality Issues**
|
||||
- Inconsistent error handling across modules
|
||||
- Variable quoting creating security risks
|
||||
- Mixed coding standards throughout codebase
|
||||
|
||||
### Improvement Potential 📈
|
||||
|
||||
**1. Immediate Impact (High ROI)**
|
||||
- Package installation consolidation: 30-40% performance improvement
|
||||
- Safe download framework: 90% reduction in network-related failures
|
||||
- Variable quoting fixes: Eliminate security vulnerabilities
|
||||
|
||||
**2. Medium-term Benefits**
|
||||
- Secrets management: Eliminate critical security risks
|
||||
- Performance optimization: Better user experience
|
||||
- Enhanced testing: Higher reliability and confidence
|
||||
|
||||
**3. Long-term Value**
|
||||
- Containerization: Modern deployment patterns
|
||||
- Observability: Better operational insight
|
||||
- Automation: Reduced manual overhead
|
||||
|
||||
## Final Recommendation
|
||||
|
||||
The KNEL Server Build project demonstrates solid architectural foundations and comprehensive security capabilities. With focused improvements in performance optimization, security hardening (particularly secrets management), and error handling, this system can become a production-grade infrastructure provisioning solution.
|
||||
|
||||
**Priority:**
|
||||
1. **Immediate:** Fix security vulnerabilities and performance bottlenecks
|
||||
2. **Short-term:** Enhance testing and error handling
|
||||
3. **Long-term:** Implement advanced features and modernization
|
||||
|
||||
**Investment Justification:** The project shows strong potential with a clear path to production readiness. The modular architecture and comprehensive security focus make it a valuable foundation for enterprise infrastructure automation.
|
||||
|
||||
---
|
||||
|
||||
**Next Steps:**
|
||||
1. Create implementation roadmap for critical fixes
|
||||
2. Establish performance benchmarks
|
||||
3. Implement continuous integration with quality gates
|
||||
4. Plan phased rollout to production environments
|
||||
|
||||
**Risk Level:** Medium - manageable with proper remediation plan
|
||||
**Business Value:** High - significant time savings and security improvements
|
||||
**Technical Debt:** Moderate - requires systematic but achievable refactoring
|
||||
@@ -1,27 +0,0 @@
|
||||
# AI Security Audit of KNELServerBuild
|
||||
|
||||
This is an AI-generated security audit of the KNELServerBuild project. The analysis is based on a read-only review of the project's files.
|
||||
|
||||
## Summary of Findings
|
||||
|
||||
The KNELServerBuild project has a good security posture overall, but there are a few areas that could be improved. The most significant finding is the presence of SSH authorized keys in the repository. This is a security risk, as it allows anyone with access to the repository to know which public keys are authorized to access the servers.
|
||||
|
||||
### High-Risk Findings
|
||||
|
||||
* **SSH Authorized Keys in Repository:** The `ProjectCode/ConfigFiles/SSH/AuthorizedKeys` directory contains SSH authorized keys for the `localuser` and `root` users. This is a security risk, as it allows anyone with access to the repository to know which public keys are authorized to access the servers.
|
||||
|
||||
### Medium-Risk Findings
|
||||
|
||||
* **Hardcoded Hostnames:** The scripts contain several hardcoded hostnames for services like Postfix, NTP, syslog, and Wazuh. This is not a direct security risk, but it does represent a configuration management issue. If any of these hostnames change, they will need to be updated in multiple places.
|
||||
|
||||
### Low-Risk Findings
|
||||
|
||||
* **Potential for Password on Command Line:** The `ProjectCode/Agents/librenms/mysql.sh` script has a `--pass` argument for a MySQL password. This is a potential security risk if the password is provided on the command line, as it could be logged in the shell history.
|
||||
|
||||
## Recommendations
|
||||
|
||||
* **Remove SSH Authorized Keys from Repository:** The SSH authorized keys should be removed from the repository and managed using a secrets management tool like HashiCorp Vault or AWS Secrets Manager.
|
||||
* **Use Variables for Hostnames:** The hardcoded hostnames should be replaced with variables that are defined in a central configuration file. This will make it easier to update the hostnames if they change.
|
||||
* **Avoid Passwords on Command Line:** The `ProjectCode/Agents/librenms/mysql.sh` script should be modified to avoid passing the MySQL password on the command line. For example, the script could prompt the user for the password or read it from a configuration file.
|
||||
|
||||
Overall, the KNELServerBuild project is a good starting point for an IAC repository. By addressing the security risks identified in this audit, the project can be made more secure and reliable.
|
||||
@@ -1,279 +0,0 @@
|
||||
# TSYS FetchApply Code Review Findings
|
||||
|
||||
**Review Date:** July 14, 2025
|
||||
**Reviewer:** Claude (Anthropic)
|
||||
**Repository:** TSYS Group Infrastructure Provisioning Scripts
|
||||
|
||||
## Executive Summary
|
||||
|
||||
The repository shows good architectural structure with centralized framework components, but has several performance, security, and maintainability issues that require attention. The codebase is functional but needs optimization for production reliability.
|
||||
|
||||
## Critical Issues (High Priority)
|
||||
|
||||
### 1. Package Installation Performance ⚠️
|
||||
**Location:** `ProjectCode/SetupNewSystem.sh:27` and `Lines 117-183`
|
||||
**Issue:** Multiple separate package installation commands causing performance bottlenecks
|
||||
```bash
|
||||
# Current inefficient pattern
|
||||
apt-get -y install git sudo dmidecode curl
|
||||
# ... later in script ...
|
||||
DEBIAN_FRONTEND="noninteractive" apt-get -qq --yes install virt-what auditd ...
|
||||
```
|
||||
**Impact:** Significantly slower deployment, multiple package cache updates
|
||||
**Fix:** Combine all package installations into single command
|
||||
|
||||
### 2. Network Operations Lack Error Handling 🔴
|
||||
**Location:** `ProjectCode/SetupNewSystem.sh:61-63`, multiple modules
|
||||
**Issue:** curl commands without timeout or error handling
|
||||
```bash
|
||||
# Vulnerable pattern
|
||||
curl --silent ${DL_ROOT}/path/file >/etc/config
|
||||
```
|
||||
**Impact:** Deployment failures in poor network conditions
|
||||
**Fix:** Add timeout, error handling, and retry logic
|
||||
|
||||
### 3. Unquoted Variable Expansions 🔴
|
||||
**Location:** Multiple files, including `ProjectCode/SetupNewSystem.sh:244`
|
||||
**Issue:** Variables used without proper quoting creating security risks
|
||||
```bash
|
||||
# Risky pattern
|
||||
chsh -s $(which zsh) root
|
||||
```
|
||||
**Impact:** Potential command injection, script failures
|
||||
**Fix:** Quote all variable expansions consistently
|
||||
|
||||
## Security Concerns
|
||||
|
||||
### 4. No Download Integrity Verification 🔴
|
||||
**Issue:** All remote downloads lack checksum verification
|
||||
**Impact:** Supply chain attack vulnerability
|
||||
**Recommendation:** Implement SHA256 checksum validation
|
||||
|
||||
### 5. Excessive Root Privilege Usage ⚠️
|
||||
**Issue:** All operations run as root without privilege separation
|
||||
**Impact:** Unnecessary security exposure
|
||||
**Recommendation:** Delegate non-privileged operations when possible
|
||||
|
||||
## Performance Optimization Opportunities
|
||||
|
||||
### 6. Individual File Downloads 🟡
|
||||
**Location:** `ProjectCode/Modules/Security/secharden-scap-stig.sh:66-77`
|
||||
**Issue:** 12+ individual curl commands for config files
|
||||
```bash
|
||||
curl --silent ${DL_ROOT}/path1 > /etc/file1
|
||||
curl --silent ${DL_ROOT}/path2 > /etc/file2
|
||||
# ... repeated 12+ times
|
||||
```
|
||||
**Impact:** Network overhead, slower deployment
|
||||
**Fix:** Batch download operations
|
||||
|
||||
### 7. Missing Connection Pooling ⚠️
|
||||
**Issue:** No connection reuse for multiple downloads from same host
|
||||
**Impact:** Unnecessary connection overhead
|
||||
**Fix:** Use curl with connection reuse or wget with keep-alive
|
||||
|
||||
## Code Quality Issues
|
||||
|
||||
### 8. Inconsistent Framework Usage 🟡
|
||||
**Issue:** Not all modules use established error handling framework
|
||||
**Impact:** Inconsistent error reporting, debugging difficulties
|
||||
**Fix:** Standardize framework usage across all modules
|
||||
|
||||
### 9. Incomplete Function Implementations 🟡
|
||||
**Location:** `Framework-Includes/LookupKv.sh`
|
||||
**Issue:** Stubbed functions with no implementation
|
||||
**Impact:** Technical debt, confusion
|
||||
**Fix:** Implement or remove unused functions
|
||||
|
||||
### 10. Missing Input Validation 🟡
|
||||
**Location:** `Project-Includes/pi-detect.sh`
|
||||
**Issue:** Functions lack proper input validation and quoting
|
||||
**Impact:** Potential script failures
|
||||
**Fix:** Add comprehensive input validation
|
||||
|
||||
## Recommended Immediate Actions
|
||||
|
||||
### Phase 1: Critical Fixes (Week 1)
|
||||
1. **Fix variable quoting** throughout codebase
|
||||
2. **Add error handling** to all network operations
|
||||
3. **Combine package installations** for performance
|
||||
4. **Implement download integrity verification**
|
||||
|
||||
### Phase 2: Performance Optimization (Week 2)
|
||||
1. **Batch file download operations**
|
||||
2. **Add connection timeouts and retries**
|
||||
3. **Implement bulk configuration deployment**
|
||||
4. **Optimize service restart procedures**
|
||||
|
||||
### Phase 3: Code Quality (Week 3-4)
|
||||
1. **Standardize framework usage**
|
||||
2. **Add comprehensive input validation**
|
||||
3. **Implement proper logging with timestamps**
|
||||
4. **Remove or complete stubbed functions**
|
||||
|
||||
## Specific Code Improvements
|
||||
|
||||
### Enhanced Error Handling Pattern
|
||||
```bash
|
||||
function safe_download() {
|
||||
local url="$1"
|
||||
local dest="$2"
|
||||
local max_attempts=3
|
||||
local attempt=1
|
||||
|
||||
while [[ $attempt -le $max_attempts ]]; do
|
||||
if curl --silent --connect-timeout 30 --max-time 60 --fail "$url" > "$dest"; then
|
||||
print_success "Downloaded: $(basename "$dest")"
|
||||
return 0
|
||||
else
|
||||
print_warning "Download attempt $attempt failed: $url"
|
||||
((attempt++))
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
print_error "Failed to download after $max_attempts attempts: $url"
|
||||
return 1
|
||||
}
|
||||
```
|
||||
|
||||
### Bulk Package Installation Pattern
|
||||
```bash
|
||||
function install_all_packages() {
|
||||
print_info "Installing all required packages..."
|
||||
|
||||
local packages=(
|
||||
# Core system packages
|
||||
git sudo dmidecode curl wget
|
||||
|
||||
# Security packages
|
||||
auditd fail2ban aide
|
||||
|
||||
# Monitoring packages
|
||||
snmpd snmp-mibs-downloader
|
||||
|
||||
# Additional packages
|
||||
virt-what net-tools htop
|
||||
)
|
||||
|
||||
if DEBIAN_FRONTEND="noninteractive" apt-get -qq --yes -o Dpkg::Options::="--force-confold" install "${packages[@]}"; then
|
||||
print_success "All packages installed successfully"
|
||||
else
|
||||
print_error "Package installation failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
### Batch Configuration Download
|
||||
```bash
|
||||
function download_configurations() {
|
||||
print_info "Downloading configuration files..."
|
||||
|
||||
local -A configs=(
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/ZSH/tsys-zshrc"]="/etc/zshrc"
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/SMTP/aliases"]="/etc/aliases"
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/Syslog/rsyslog.conf"]="/etc/rsyslog.conf"
|
||||
)
|
||||
|
||||
for url in "${!configs[@]}"; do
|
||||
local dest="${configs[$url]}"
|
||||
if ! safe_download "$url" "$dest"; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
print_success "All configurations downloaded"
|
||||
}
|
||||
```
|
||||
|
||||
## Testing Recommendations
|
||||
|
||||
### Add Performance Tests
|
||||
```bash
|
||||
function test_package_installation_performance() {
|
||||
local start_time=$(date +%s)
|
||||
install_all_packages
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
echo "✅ Package installation completed in ${duration}s"
|
||||
|
||||
if [[ $duration -gt 300 ]]; then
|
||||
echo "⚠️ Installation took longer than expected (>5 minutes)"
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
### Add Network Resilience Tests
|
||||
```bash
|
||||
function test_network_error_handling() {
|
||||
# Test with invalid URL
|
||||
if safe_download "https://invalid.example.com/file" "/tmp/test"; then
|
||||
echo "❌ Error handling test failed - should have failed"
|
||||
return 1
|
||||
else
|
||||
echo "✅ Error handling test passed"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
## Monitoring and Metrics
|
||||
|
||||
### Deployment Performance Metrics
|
||||
- **Package installation time:** Should complete in <5 minutes
|
||||
- **Configuration download time:** Should complete in <2 minutes
|
||||
- **Service restart time:** Should complete in <30 seconds
|
||||
- **Total deployment time:** Should complete in <15 minutes
|
||||
|
||||
### Error Rate Monitoring
|
||||
- **Network operation failures:** Should be <1%
|
||||
- **Package installation failures:** Should be <0.1%
|
||||
- **Service restart failures:** Should be <0.1%
|
||||
|
||||
## Compliance Assessment
|
||||
|
||||
### Development Guidelines Adherence
|
||||
✅ **Good:** Single package commands in newer modules
|
||||
✅ **Good:** Framework integration patterns
|
||||
✅ **Good:** Function documentation in recent code
|
||||
|
||||
❌ **Needs Work:** Variable quoting consistency
|
||||
❌ **Needs Work:** Error handling standardization
|
||||
❌ **Needs Work:** Input validation coverage
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
**Current Risk Level:** Medium
|
||||
|
||||
**Key Risks:**
|
||||
1. **Deployment failures** due to network issues
|
||||
2. **Security vulnerabilities** from unvalidated downloads
|
||||
3. **Performance issues** in production deployments
|
||||
4. **Maintenance challenges** from code inconsistencies
|
||||
|
||||
**Mitigation Priority:**
|
||||
1. Network error handling (High)
|
||||
2. Download integrity verification (High)
|
||||
3. Performance optimization (Medium)
|
||||
4. Code standardization (Medium)
|
||||
|
||||
## Conclusion
|
||||
|
||||
The TSYS FetchApply repository has a solid foundation but requires systematic improvements to meet production reliability standards. The recommended fixes will significantly enhance:
|
||||
|
||||
- **Deployment reliability** through better error handling
|
||||
- **Security posture** through integrity verification
|
||||
- **Performance** through optimized operations
|
||||
- **Maintainability** through code standardization
|
||||
|
||||
Implementing these improvements in the suggested phases will create a robust, production-ready infrastructure provisioning system.
|
||||
|
||||
---
|
||||
|
||||
**Next Steps:**
|
||||
1. Review and prioritize findings with development team
|
||||
2. Create implementation plan for critical fixes
|
||||
3. Establish testing procedures for improvements
|
||||
4. Set up monitoring for deployment metrics
|
||||
@@ -1,93 +0,0 @@
|
||||
# Claude Code Review - TSYS FetchApply Infrastructure
|
||||
|
||||
**Review Date:** July 14, 2025 (Updated)
|
||||
**Reviewed by:** Claude (Anthropic)
|
||||
**Repository:** TSYS Group Infrastructure Provisioning Scripts
|
||||
**Previous Review:** July 12, 2025
|
||||
|
||||
## Project Overview
|
||||
|
||||
This repository contains infrastructure-as-code for provisioning Linux servers in the TSYS Group environment. The codebase includes 32 shell scripts (~2,800 lines) organized into a modular framework for system hardening, security configuration, and operational tooling deployment.
|
||||
|
||||
## Strengths ✅
|
||||
|
||||
### Security Hardening
|
||||
- **SSH Security:** Comprehensive SSH hardening with key-only authentication, disabled password login, and secure cipher configurations
|
||||
- **Security Agents:** Automated deployment of Wazuh SIEM agents, audit tools, and SCAP-STIG compliance checking
|
||||
- **File Permissions:** Proper restrictive permissions (400 for SSH keys, 644 for configs)
|
||||
- **Network Security:** Firewall configuration, network discovery tools (LLDP), and monitoring agents
|
||||
|
||||
### Code Quality
|
||||
- **Error Handling:** Robust bash strict mode implementation (`set -euo pipefail`) with custom error trapping and line number reporting
|
||||
- **Modular Design:** Well-organized structure separating framework components, configuration files, and functional modules
|
||||
- **Environment Awareness:** Intelligent detection of physical vs virtual hosts, distribution-specific logic, and hardware-specific optimizations
|
||||
- **Logging:** Centralized logging with timestamp-based log files and colored output for debugging
|
||||
|
||||
### Operational Excellence
|
||||
- **Package Management:** Automated repository setup for security tools (Lynis, Webmin, Tailscale, Wazuh)
|
||||
- **System Tuning:** Performance optimizations for physical hosts, virtualization-aware configurations
|
||||
- **Monitoring Integration:** LibreNMS agents, SNMP configuration, and system metrics collection
|
||||
|
||||
## Security Concerns ⚠️
|
||||
|
||||
### Critical Issues
|
||||
1. **~~Insecure Deployment Method~~** ✅ **RESOLVED:** Now uses `git clone` + local script execution instead of `curl | bash`
|
||||
2. **No Integrity Verification:** Downloaded scripts lack checksum validation or cryptographic signatures
|
||||
3. **~~HTTP Downloads~~** ✅ **RESOLVED:** All HTTP URLs converted to HTTPS (Dell OMSA, Proxmox, Apache sources)
|
||||
|
||||
### Moderate Risks
|
||||
4. **Exposed SSH Keys:** Public SSH keys committed directly to repository without rotation mechanism
|
||||
5. **Hard-coded Credentials:** Server hostnames and domain names embedded in scripts
|
||||
6. **Missing Secrets Management:** No current implementation of Bitwarden/Vault integration (noted in TODO comments)
|
||||
|
||||
## Improvement Recommendations 🔧
|
||||
|
||||
### High Priority (Security Critical)
|
||||
1. **~~Secure Deployment Pipeline~~** ✅ **RESOLVED:** Now uses git clone-based deployment
|
||||
2. **~~HTTPS Enforcement~~** ✅ **RESOLVED:** All HTTP downloads converted to HTTPS
|
||||
3. **Script Integrity:** Implement SHA256 checksum verification for all downloaded components
|
||||
4. **Secrets Management:** Deploy proper secrets handling for SSH keys and sensitive configurations
|
||||
|
||||
### Medium Priority (Operational)
|
||||
5. **Testing Framework:** Add integration tests for provisioning workflows
|
||||
6. **Documentation Enhancement:** Expand security considerations and deployment procedures
|
||||
7. **Configuration Validation:** Add pre-deployment validation of system requirements
|
||||
8. **Rollback Capability:** Implement configuration backup and rollback mechanisms
|
||||
|
||||
### Low Priority (Quality of Life)
|
||||
9. **Error Recovery:** Enhanced error recovery and partial deployment resumption
|
||||
10. **Monitoring Integration:** Centralized logging and deployment status reporting
|
||||
11. **User Interface:** Consider web-based deployment dashboard for non-technical users
|
||||
|
||||
## Risk Assessment 📊
|
||||
|
||||
**Overall Risk Level:** Low-Medium ⬇️ (Reduced from Medium-Low)
|
||||
|
||||
The repository contains well-architected defensive security tools with strong error handling and modular design. **Major security improvement:** The insecure `curl | bash` deployment method has been replaced with git-based deployment. Remaining concerns are primarily around hardening the provisioning scripts themselves rather than the deployment method.
|
||||
|
||||
**Recommendation:** Continue addressing remaining security issues (HTTPS enforcement, secrets management) but the critical deployment risk has been mitigated. The codebase is much safer for production use.
|
||||
|
||||
## Update Summary (July 14, 2025)
|
||||
|
||||
**✅ Resolved Issues:**
|
||||
- Insecure deployment method replaced with git clone approach
|
||||
- README.md updated with project management and community links
|
||||
- Deployment security risk significantly reduced
|
||||
- All HTTP URLs converted to HTTPS (Dell OMSA, Proxmox, Apache sources)
|
||||
|
||||
**🔄 Remaining Priorities:**
|
||||
1. ~~HTTPS enforcement for internal downloads~~ ✅ **RESOLVED:** All HTTP URLs converted to HTTPS
|
||||
2. Secrets management implementation
|
||||
3. Script integrity verification
|
||||
4. SSH key rotation from repository
|
||||
|
||||
## Files Reviewed
|
||||
|
||||
- 32 shell scripts across Framework-Includes, Project-Includes, and ProjectCode directories
|
||||
- Configuration files for SSH, SNMP, logging, and system services
|
||||
- Security modules for hardening, authentication, and monitoring
|
||||
- Documentation and framework configuration files
|
||||
|
||||
## Next Steps
|
||||
|
||||
See `charles-todo.md` and `claude-todo.md` for detailed action items prioritized for human operators and AI assistants respectively.
|
||||
@@ -1,336 +0,0 @@
|
||||
# TSYS FetchApply Deployment Guide
|
||||
|
||||
## Overview
|
||||
|
||||
This guide provides comprehensive instructions for deploying the TSYS FetchApply infrastructure provisioning system on Linux servers.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### System Requirements
|
||||
- **Operating System:** Ubuntu 18.04+ or Debian 10+ (recommended)
|
||||
- **RAM:** Minimum 2GB, recommended 4GB
|
||||
- **Disk Space:** Minimum 10GB free space
|
||||
- **Network:** Internet connectivity for package downloads
|
||||
- **Privileges:** Root or sudo access required
|
||||
|
||||
### Required Tools
|
||||
- `git` - Version control system
|
||||
- `curl` - HTTP client for downloads
|
||||
- `wget` - Alternative download tool
|
||||
- `systemctl` - System service management
|
||||
- `apt-get` - Package management (Debian/Ubuntu)
|
||||
|
||||
### Network Requirements
|
||||
- **HTTPS access** to:
|
||||
- `https://archive.ubuntu.com` (Ubuntu packages)
|
||||
- `https://linux.dell.com` (Dell hardware support)
|
||||
- `https://download.proxmox.com` (Proxmox packages)
|
||||
- `https://github.com` (Git repositories)
|
||||
|
||||
## Pre-Deployment Validation
|
||||
|
||||
### 1. System Compatibility Check
|
||||
```bash
|
||||
# Clone repository
|
||||
git clone [repository-url]
|
||||
cd FetchApply
|
||||
|
||||
# Run system validation
|
||||
./Project-Tests/validation/system-requirements.sh
|
||||
```
|
||||
|
||||
### 2. Network Connectivity Test
|
||||
```bash
|
||||
# Test network connectivity
|
||||
curl -I https://archive.ubuntu.com
|
||||
curl -I https://linux.dell.com
|
||||
curl -I https://download.proxmox.com
|
||||
```
|
||||
|
||||
### 3. Permission Verification
|
||||
```bash
|
||||
# Verify write permissions
|
||||
test -w /etc && echo "✅ /etc writable" || echo "❌ /etc not writable"
|
||||
test -w /usr/local/bin && echo "✅ /usr/local/bin writable" || echo "❌ /usr/local/bin not writable"
|
||||
```
|
||||
|
||||
## Deployment Methods
|
||||
|
||||
### Method 1: Standard Deployment (Recommended)
|
||||
```bash
|
||||
# 1. Clone repository
|
||||
git clone [repository-url]
|
||||
cd FetchApply
|
||||
|
||||
# 2. Run pre-deployment tests
|
||||
./Project-Tests/run-tests.sh validation
|
||||
|
||||
# 3. Execute deployment
|
||||
cd ProjectCode
|
||||
sudo bash SetupNewSystem.sh
|
||||
```
|
||||
|
||||
### Method 2: Dry Run Mode
|
||||
```bash
|
||||
# 1. Clone repository
|
||||
git clone [repository-url]
|
||||
cd FetchApply
|
||||
|
||||
# 2. Review configuration
|
||||
cat ProjectCode/SetupNewSystem.sh
|
||||
|
||||
# 3. Execute with manual review
|
||||
cd ProjectCode
|
||||
sudo bash -x SetupNewSystem.sh # Debug mode
|
||||
```
|
||||
|
||||
## Deployment Process
|
||||
|
||||
### Phase 1: Framework Initialization
|
||||
1. **Environment Setup**
|
||||
- Load framework variables
|
||||
- Source framework includes
|
||||
- Initialize logging system
|
||||
|
||||
2. **System Detection**
|
||||
- Detect physical vs virtual hardware
|
||||
- Identify operating system
|
||||
- Check for existing users
|
||||
|
||||
### Phase 2: Base System Configuration
|
||||
1. **Package Installation**
|
||||
- Update package repositories
|
||||
- Install essential packages
|
||||
- Configure package sources
|
||||
|
||||
2. **User Management**
|
||||
- Create required user accounts
|
||||
- Configure SSH access
|
||||
- Set up sudo permissions
|
||||
|
||||
### Phase 3: Security Hardening
|
||||
1. **SSH Configuration**
|
||||
- Deploy hardened SSH configuration
|
||||
- Install SSH keys
|
||||
- Disable password authentication
|
||||
|
||||
2. **System Hardening**
|
||||
- Configure firewall rules
|
||||
- Enable audit logging
|
||||
- Install security tools
|
||||
|
||||
### Phase 4: Monitoring and Management
|
||||
1. **Monitoring Agents**
|
||||
- Deploy LibreNMS agents
|
||||
- Configure SNMP
|
||||
- Set up system monitoring
|
||||
|
||||
2. **Management Tools**
|
||||
- Install Cockpit dashboard
|
||||
- Configure remote access
|
||||
- Set up maintenance scripts
|
||||
|
||||
## Post-Deployment Verification
|
||||
|
||||
### 1. Security Validation
|
||||
```bash
|
||||
# Run security tests
|
||||
./Project-Tests/run-tests.sh security
|
||||
|
||||
# Verify SSH configuration
|
||||
ssh -T [server-ip] # Should work with key authentication
|
||||
```
|
||||
|
||||
### 2. Service Status Check
|
||||
```bash
|
||||
# Check critical services
|
||||
sudo systemctl status ssh
|
||||
sudo systemctl status auditd
|
||||
sudo systemctl status snmpd
|
||||
```
|
||||
|
||||
### 3. Network Connectivity
|
||||
```bash
|
||||
# Test internal services
|
||||
curl -k https://localhost:9090 # Cockpit
|
||||
snmpwalk -v2c -c public localhost system
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### 1. Permission Denied Errors
|
||||
```bash
|
||||
# Solution: Run with sudo
|
||||
sudo bash SetupNewSystem.sh
|
||||
```
|
||||
|
||||
#### 2. Network Connectivity Issues
|
||||
```bash
|
||||
# Check DNS resolution
|
||||
nslookup archive.ubuntu.com
|
||||
|
||||
# Test direct IP access
|
||||
curl -I 91.189.91.26 # Ubuntu archive IP
|
||||
```
|
||||
|
||||
#### 3. Package Installation Failures
|
||||
```bash
|
||||
# Update package cache
|
||||
sudo apt-get update
|
||||
|
||||
# Fix broken packages
|
||||
sudo apt-get -f install
|
||||
```
|
||||
|
||||
#### 4. SSH Key Issues
|
||||
```bash
|
||||
# Verify key permissions
|
||||
ls -la ~/.ssh/
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
chmod 644 ~/.ssh/id_rsa.pub
|
||||
```
|
||||
|
||||
### Debug Mode
|
||||
```bash
|
||||
# Enable debug logging
|
||||
export DEBUG=1
|
||||
bash -x SetupNewSystem.sh
|
||||
```
|
||||
|
||||
### Log Analysis
|
||||
```bash
|
||||
# Check deployment logs
|
||||
tail -f /var/log/fetchapply/deployment.log
|
||||
|
||||
# Review system logs
|
||||
journalctl -u ssh
|
||||
journalctl -u auditd
|
||||
```
|
||||
|
||||
## Environment-Specific Configurations
|
||||
|
||||
### Physical Dell Servers
|
||||
- **OMSA Installation:** Dell OpenManage Server Administrator
|
||||
- **Hardware Monitoring:** iDRAC configuration
|
||||
- **Performance Tuning:** CPU and memory optimizations
|
||||
|
||||
### Virtual Machines
|
||||
- **Guest Additions:** VMware tools or VirtualBox additions
|
||||
- **Resource Limits:** Memory and CPU constraints
|
||||
- **Network Configuration:** Bridge vs NAT settings
|
||||
|
||||
### Development Environments
|
||||
- **SSH Configuration:** Less restrictive settings
|
||||
- **Development Tools:** Additional packages for development
|
||||
- **Testing Access:** Enhanced logging and debugging
|
||||
|
||||
## Maintenance and Updates
|
||||
|
||||
### Regular Maintenance
|
||||
```bash
|
||||
# Update system packages
|
||||
sudo apt-get update && sudo apt-get upgrade
|
||||
|
||||
# Update monitoring scripts
|
||||
cd /usr/local/bin
|
||||
sudo wget https://[repository]/scripts/up2date.sh
|
||||
sudo chmod +x up2date.sh
|
||||
```
|
||||
|
||||
### Security Updates
|
||||
```bash
|
||||
# Check for security updates
|
||||
sudo apt-get update
|
||||
sudo apt list --upgradable | grep -i security
|
||||
|
||||
# Apply security patches
|
||||
sudo apt-get upgrade
|
||||
```
|
||||
|
||||
### Configuration Updates
|
||||
```bash
|
||||
# Update FetchApply
|
||||
cd FetchApply
|
||||
git pull origin main
|
||||
|
||||
# Re-run specific modules
|
||||
cd ProjectCode/Modules/Security
|
||||
sudo bash secharden-ssh.sh
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Pre-Deployment
|
||||
- Always test in non-production environment first
|
||||
- Review all scripts before execution
|
||||
- Validate network connectivity
|
||||
- Ensure proper backup procedures
|
||||
|
||||
### 2. During Deployment
|
||||
- Monitor deployment progress
|
||||
- Check for errors and warnings
|
||||
- Document any customizations
|
||||
- Validate each phase completion
|
||||
|
||||
### 3. Post-Deployment
|
||||
- Run full security test suite
|
||||
- Verify all services are running
|
||||
- Test remote access
|
||||
- Document deployment specifics
|
||||
|
||||
### 4. Ongoing Operations
|
||||
- Regular security updates
|
||||
- Monitor system performance
|
||||
- Review audit logs
|
||||
- Maintain deployment documentation
|
||||
|
||||
## Support and Resources
|
||||
|
||||
### Documentation
|
||||
- **README.md:** Basic usage instructions
|
||||
- **SECURITY.md:** Security architecture and guidelines
|
||||
- **Project-Tests/README.md:** Testing framework documentation
|
||||
|
||||
### Community Support
|
||||
- **Issues:** https://projects.knownelement.com/project/reachableceo-vptechnicaloperations/timeline
|
||||
- **Discussion:** https://community.turnsys.com/c/chieftechnologyandproductofficer/26
|
||||
|
||||
### Professional Support
|
||||
- **Technical Support:** [Contact information to be added]
|
||||
- **Consulting Services:** [Contact information to be added]
|
||||
|
||||
## Deployment Checklist
|
||||
|
||||
### Pre-Deployment
|
||||
- [ ] System requirements validated
|
||||
- [ ] Network connectivity tested
|
||||
- [ ] Backup procedures in place
|
||||
- [ ] Security review completed
|
||||
|
||||
### Deployment
|
||||
- [ ] Repository cloned successfully
|
||||
- [ ] Pre-deployment tests passed
|
||||
- [ ] Deployment executed without errors
|
||||
- [ ] Post-deployment verification completed
|
||||
|
||||
### Post-Deployment
|
||||
- [ ] Security tests passed
|
||||
- [ ] All services running
|
||||
- [ ] Remote access verified
|
||||
- [ ] Documentation updated
|
||||
|
||||
### Maintenance
|
||||
- [ ] Update schedule established
|
||||
- [ ] Monitoring configured
|
||||
- [ ] Backup procedures tested
|
||||
- [ ] Incident response plan activated
|
||||
|
||||
## Version History
|
||||
|
||||
- **v1.0:** Initial deployment framework
|
||||
- **v1.1:** Added security hardening and secrets management
|
||||
- **v1.2:** Enhanced testing framework and documentation
|
||||
|
||||
Last updated: July 14, 2025
|
||||
@@ -1,406 +0,0 @@
|
||||
# TSYS FetchApply Development Guidelines
|
||||
|
||||
## Overview
|
||||
|
||||
This document contains development standards and best practices for the TSYS FetchApply infrastructure provisioning system.
|
||||
|
||||
## Package Management Best Practices
|
||||
|
||||
### Combine apt-get Install Commands
|
||||
|
||||
**Rule:** Always combine multiple package installations into a single `apt-get install` command for performance.
|
||||
|
||||
**Rationale:** Single command execution is significantly faster than multiple separate commands due to:
|
||||
- Reduced package cache processing
|
||||
- Single dependency resolution
|
||||
- Fewer network connections
|
||||
- Optimized package download ordering
|
||||
|
||||
#### ✅ Correct Implementation
|
||||
```bash
|
||||
# Install all packages in one command
|
||||
apt-get install -y package1 package2 package3 package4
|
||||
|
||||
# Real example from 2FA script
|
||||
apt-get install -y libpam-google-authenticator qrencode
|
||||
```
|
||||
|
||||
#### ❌ Incorrect Implementation
|
||||
```bash
|
||||
# Don't use separate commands for each package
|
||||
apt-get install -y package1
|
||||
apt-get install -y package2
|
||||
apt-get install -y package3
|
||||
```
|
||||
|
||||
#### Complex Package Installation Pattern
|
||||
```bash
|
||||
function install_security_packages() {
|
||||
print_info "Installing security packages..."
|
||||
|
||||
# Update package cache once
|
||||
apt-get update
|
||||
|
||||
# Install all packages in single command
|
||||
apt-get install -y \
|
||||
auditd \
|
||||
fail2ban \
|
||||
libpam-google-authenticator \
|
||||
lynis \
|
||||
rkhunter \
|
||||
aide \
|
||||
chkrootkit \
|
||||
clamav \
|
||||
clamav-daemon
|
||||
|
||||
print_success "Security packages installed successfully"
|
||||
}
|
||||
```
|
||||
|
||||
## Script Development Standards
|
||||
|
||||
### Error Handling
|
||||
- Always use `set -euo pipefail` at script start
|
||||
- Implement proper error trapping
|
||||
- Use framework error handling functions
|
||||
- Return appropriate exit codes
|
||||
|
||||
### Function Structure
|
||||
```bash
|
||||
function function_name() {
|
||||
print_info "Description of what function does..."
|
||||
|
||||
# Local variables
|
||||
local var1="value"
|
||||
local var2="value"
|
||||
|
||||
# Function logic
|
||||
if [[ condition ]]; then
|
||||
print_success "Success message"
|
||||
return 0
|
||||
else
|
||||
print_error "Error message"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
### Framework Integration
|
||||
- Source framework includes at script start
|
||||
- Use framework logging and pretty print functions
|
||||
- Follow existing patterns for consistency
|
||||
- Include proper PROJECT_ROOT path resolution
|
||||
|
||||
```bash
|
||||
# Standard framework sourcing pattern
|
||||
PROJECT_ROOT="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../.."
|
||||
source "$PROJECT_ROOT/Framework-Includes/PrettyPrint.sh"
|
||||
source "$PROJECT_ROOT/Framework-Includes/Logging.sh"
|
||||
source "$PROJECT_ROOT/Framework-Includes/ErrorHandling.sh"
|
||||
```
|
||||
|
||||
## Code Quality Standards
|
||||
|
||||
### ShellCheck Compliance
|
||||
- All scripts must pass shellcheck validation
|
||||
- Address shellcheck warnings appropriately
|
||||
- Use proper quoting for variables
|
||||
- Handle edge cases and error conditions
|
||||
|
||||
### Variable Naming
|
||||
- Use UPPERCASE for global constants
|
||||
- Use lowercase for local variables
|
||||
- Use descriptive names
|
||||
- Quote all variable expansions
|
||||
|
||||
```bash
|
||||
# Global constants
|
||||
declare -g BACKUP_DIR="/root/backup"
|
||||
declare -g CONFIG_FILE="/etc/ssh/sshd_config"
|
||||
|
||||
# Local variables
|
||||
local user_name="localuser"
|
||||
local temp_file="/tmp/config.tmp"
|
||||
|
||||
# Proper quoting
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
cp "$CONFIG_FILE" "$BACKUP_DIR/"
|
||||
fi
|
||||
```
|
||||
|
||||
### Function Documentation
|
||||
- Include purpose description
|
||||
- Document parameters if any
|
||||
- Document return values
|
||||
- Include usage examples for complex functions
|
||||
|
||||
```bash
|
||||
# Configure SSH hardening settings
|
||||
# Parameters: none
|
||||
# Returns: 0 on success, 1 on failure
|
||||
# Usage: configure_ssh_hardening
|
||||
function configure_ssh_hardening() {
|
||||
print_info "Configuring SSH hardening..."
|
||||
# Implementation
|
||||
}
|
||||
```
|
||||
|
||||
## Testing Requirements
|
||||
|
||||
### Test Coverage
|
||||
- Every new module must include corresponding tests
|
||||
- Test both success and failure scenarios
|
||||
- Validate configurations after changes
|
||||
- Include integration tests for complex workflows
|
||||
|
||||
### Test Categories
|
||||
1. **Unit Tests:** Individual function validation
|
||||
2. **Integration Tests:** Module interaction testing
|
||||
3. **Security Tests:** Security configuration validation
|
||||
4. **Validation Tests:** System requirement checking
|
||||
|
||||
### Test Implementation Pattern
|
||||
```bash
|
||||
function test_function_name() {
|
||||
echo "🔍 Testing specific functionality..."
|
||||
|
||||
local failed=0
|
||||
|
||||
# Test implementation
|
||||
if [[ condition ]]; then
|
||||
echo "✅ Test passed"
|
||||
else
|
||||
echo "❌ Test failed"
|
||||
((failed++))
|
||||
fi
|
||||
|
||||
return $failed
|
||||
}
|
||||
```
|
||||
|
||||
## Security Standards
|
||||
|
||||
### Configuration Backup
|
||||
- Always backup configurations before modification
|
||||
- Use timestamped backup directories
|
||||
- Provide restore instructions
|
||||
- Test backup/restore procedures
|
||||
|
||||
### Service Management
|
||||
- Test configurations before restarting services
|
||||
- Provide rollback procedures
|
||||
- Validate service status after changes
|
||||
- Include service dependency handling
|
||||
|
||||
### User Safety
|
||||
- Use `nullok` for gradual 2FA rollout
|
||||
- Provide clear setup instructions
|
||||
- Include emergency access procedures
|
||||
- Test all access methods before enforcement
|
||||
|
||||
## Documentation Standards
|
||||
|
||||
### Script Headers
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# TSYS Module Name - Brief Description
|
||||
# Longer description of what this script does
|
||||
# Author: TSYS Development Team
|
||||
# Version: 1.0
|
||||
# Last Updated: YYYY-MM-DD
|
||||
|
||||
set -euo pipefail
|
||||
```
|
||||
|
||||
### Inline Documentation
|
||||
- Comment complex logic
|
||||
- Explain non-obvious decisions
|
||||
- Document external dependencies
|
||||
- Include troubleshooting notes
|
||||
|
||||
### User Documentation
|
||||
- Create comprehensive guides for complex features
|
||||
- Include step-by-step procedures
|
||||
- Provide troubleshooting sections
|
||||
- Include examples and use cases
|
||||
|
||||
## Performance Optimization
|
||||
|
||||
### Package Management
|
||||
- Single apt-get commands (as noted above)
|
||||
- Cache package lists appropriately
|
||||
- Use specific package versions when stability required
|
||||
- Clean up package cache when appropriate
|
||||
|
||||
### Network Operations
|
||||
- Use connection timeouts for external requests
|
||||
- Implement retry logic with backoff
|
||||
- Cache downloaded resources when possible
|
||||
- Validate download integrity
|
||||
|
||||
### File Operations
|
||||
- Use efficient file processing tools
|
||||
- Minimize file system operations
|
||||
- Use appropriate file permissions
|
||||
- Clean up temporary files
|
||||
|
||||
## Version Control Practices
|
||||
|
||||
### Commit Messages
|
||||
- Use descriptive commit messages
|
||||
- Include scope of changes
|
||||
- Reference related issues/requirements
|
||||
- Follow established commit message format
|
||||
|
||||
### Branch Management
|
||||
- Test changes in feature branches
|
||||
- Use pull requests for review
|
||||
- Maintain clean commit history
|
||||
- Tag releases appropriately
|
||||
|
||||
### Code Review Requirements
|
||||
- All changes require review
|
||||
- Security changes require security team review
|
||||
- Test coverage must be maintained
|
||||
- Documentation must be updated
|
||||
|
||||
## Deployment Practices
|
||||
|
||||
### Pre-Deployment
|
||||
- Run full test suite
|
||||
- Validate in test environment
|
||||
- Review security implications
|
||||
- Update documentation
|
||||
|
||||
### Deployment Process
|
||||
- Use configuration validation
|
||||
- Implement gradual rollout when possible
|
||||
- Monitor for issues during deployment
|
||||
- Have rollback procedures ready
|
||||
|
||||
### Post-Deployment
|
||||
- Validate deployment success
|
||||
- Monitor system performance
|
||||
- Update operational documentation
|
||||
- Gather feedback for improvements
|
||||
|
||||
## Example Implementation
|
||||
|
||||
### Complete Module Template
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# TSYS Security Module - Template
|
||||
# Template for creating new security modules
|
||||
# Author: TSYS Development Team
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Source framework functions
|
||||
PROJECT_ROOT="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../.."
|
||||
source "$PROJECT_ROOT/Framework-Includes/PrettyPrint.sh"
|
||||
source "$PROJECT_ROOT/Framework-Includes/Logging.sh"
|
||||
source "$PROJECT_ROOT/Framework-Includes/ErrorHandling.sh"
|
||||
|
||||
# Module configuration
|
||||
BACKUP_DIR="/root/backup/module-$(date +%Y%m%d-%H%M%S)"
|
||||
CONFIG_FILE="/etc/example.conf"
|
||||
|
||||
# Create backup directory
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
print_header "TSYS Module Template"
|
||||
|
||||
function backup_configs() {
|
||||
print_info "Creating configuration backup..."
|
||||
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
cp "$CONFIG_FILE" "$BACKUP_DIR/"
|
||||
print_success "Configuration backed up"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_packages() {
|
||||
print_info "Installing required packages..."
|
||||
|
||||
# Update package cache
|
||||
apt-get update
|
||||
|
||||
# Install all packages in single command
|
||||
apt-get install -y package1 package2 package3
|
||||
|
||||
print_success "Packages installed successfully"
|
||||
}
|
||||
|
||||
function configure_module() {
|
||||
print_info "Configuring module..."
|
||||
|
||||
# Configuration logic here
|
||||
|
||||
print_success "Module configured successfully"
|
||||
}
|
||||
|
||||
function validate_configuration() {
|
||||
print_info "Validating configuration..."
|
||||
|
||||
local failed=0
|
||||
|
||||
# Validation logic here
|
||||
|
||||
if [[ $failed -eq 0 ]]; then
|
||||
print_success "Configuration validation passed"
|
||||
return 0
|
||||
else
|
||||
print_error "Configuration validation failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function main() {
|
||||
# Check if running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
print_error "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute module steps
|
||||
backup_configs
|
||||
install_packages
|
||||
configure_module
|
||||
validate_configuration
|
||||
|
||||
print_success "Module setup completed successfully!"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
```
|
||||
|
||||
## Continuous Improvement
|
||||
|
||||
### Regular Reviews
|
||||
- Review guidelines quarterly
|
||||
- Update based on lessons learned
|
||||
- Incorporate new best practices
|
||||
- Gather team feedback
|
||||
|
||||
### Tool Updates
|
||||
- Keep development tools current
|
||||
- Adopt new security practices
|
||||
- Update testing frameworks
|
||||
- Improve automation
|
||||
|
||||
### Knowledge Sharing
|
||||
- Document lessons learned
|
||||
- Share best practices
|
||||
- Provide training materials
|
||||
- Maintain knowledge base
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** July 14, 2025
|
||||
**Version:** 1.0
|
||||
**Author:** TSYS Development Team
|
||||
|
||||
**Note:** These guidelines are living documents and should be updated as the project evolves and new best practices are identified.
|
||||
@@ -1,534 +0,0 @@
|
||||
# Code Refactoring Examples
|
||||
|
||||
This document provides specific examples of how to apply the code review findings to improve performance, security, and reliability.
|
||||
|
||||
## Package Installation Optimization
|
||||
|
||||
### Before (Current - Multiple Commands)
|
||||
```bash
|
||||
# Line 27 in SetupNewSystem.sh
|
||||
apt-get -y install git sudo dmidecode curl
|
||||
|
||||
# Lines 117-183 (later in script)
|
||||
DEBIAN_FRONTEND="noninteractive" apt-get -qq --yes -o Dpkg::Options::="--force-confold" install \
|
||||
virt-what \
|
||||
auditd \
|
||||
aide \
|
||||
# ... many more packages
|
||||
```
|
||||
|
||||
### After (Optimized - Single Command)
|
||||
```bash
|
||||
function install_all_packages() {
|
||||
print_info "Installing all required packages..."
|
||||
|
||||
# All packages in logical groups for better readability
|
||||
local packages=(
|
||||
# Core system tools
|
||||
git sudo dmidecode curl wget net-tools htop
|
||||
|
||||
# Security and auditing
|
||||
auditd aide fail2ban lynis rkhunter
|
||||
|
||||
# Monitoring and SNMP
|
||||
snmpd snmp-mibs-downloader libsnmp-dev
|
||||
|
||||
# Virtualization detection
|
||||
virt-what
|
||||
|
||||
# System utilities
|
||||
rsyslog logrotate ntp ntpdate
|
||||
cockpit cockpit-ws cockpit-system
|
||||
|
||||
# Development and debugging
|
||||
build-essential dkms
|
||||
|
||||
# Network services
|
||||
openssh-server ufw
|
||||
)
|
||||
|
||||
# Single package installation command with retry logic
|
||||
local max_attempts=3
|
||||
local attempt=1
|
||||
|
||||
while [[ $attempt -le $max_attempts ]]; do
|
||||
if DEBIAN_FRONTEND="noninteractive" apt-get -qq --yes -o Dpkg::Options::="--force-confold" install "${packages[@]}"; then
|
||||
print_success "All packages installed successfully"
|
||||
return 0
|
||||
else
|
||||
print_warning "Package installation attempt $attempt failed"
|
||||
if [[ $attempt -lt $max_attempts ]]; then
|
||||
print_info "Retrying in 10 seconds..."
|
||||
sleep 10
|
||||
apt-get update # Refresh package cache before retry
|
||||
fi
|
||||
((attempt++))
|
||||
fi
|
||||
done
|
||||
|
||||
print_error "Package installation failed after $max_attempts attempts"
|
||||
return 1
|
||||
}
|
||||
```
|
||||
|
||||
## Safe Download Implementation
|
||||
|
||||
### Before (Current - Unsafe Downloads)
|
||||
```bash
|
||||
# Lines 61-63 in SetupNewSystem.sh
|
||||
curl --silent ${DL_ROOT}/ProjectCode/ConfigFiles/ZSH/tsys-zshrc >/etc/zshrc
|
||||
curl --silent ${DL_ROOT}/ProjectCode/ConfigFiles/SMTP/aliases >/etc/aliases
|
||||
curl --silent ${DL_ROOT}/ProjectCode/ConfigFiles/Syslog/rsyslog.conf >/etc/rsyslog.conf
|
||||
```
|
||||
|
||||
### After (Safe Downloads with Error Handling)
|
||||
```bash
|
||||
function download_system_configs() {
|
||||
print_info "Downloading system configuration files..."
|
||||
|
||||
# Source the safe download framework
|
||||
source "$PROJECT_ROOT/Framework-Includes/SafeDownload.sh"
|
||||
|
||||
# Define configuration downloads with checksums (optional)
|
||||
declare -A config_downloads=(
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/ZSH/tsys-zshrc"]="/etc/zshrc"
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/SMTP/aliases"]="/etc/aliases"
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/Syslog/rsyslog.conf"]="/etc/rsyslog.conf"
|
||||
["${DL_ROOT}/ProjectCode/ConfigFiles/SSH/Configs/tsys-sshd-config"]="/etc/ssh/sshd_config.tsys"
|
||||
)
|
||||
|
||||
# Validate all URLs are accessible before starting
|
||||
local urls=()
|
||||
for url in "${!config_downloads[@]}"; do
|
||||
urls+=("$url")
|
||||
done
|
||||
|
||||
if ! validate_required_urls "${urls[@]}"; then
|
||||
print_error "Some configuration URLs are not accessible"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Perform batch download with backup
|
||||
local failed_downloads=0
|
||||
for url in "${!config_downloads[@]}"; do
|
||||
local dest="${config_downloads[$url]}"
|
||||
if ! safe_config_download "$url" "$dest"; then
|
||||
((failed_downloads++))
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $failed_downloads -eq 0 ]]; then
|
||||
print_success "All configuration files downloaded successfully"
|
||||
return 0
|
||||
else
|
||||
print_error "$failed_downloads configuration downloads failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
## Variable Quoting Fixes
|
||||
|
||||
### Before (Unsafe Variable Usage)
|
||||
```bash
|
||||
# Line 244 in SetupNewSystem.sh
|
||||
chsh -s $(which zsh) root
|
||||
|
||||
# Multiple instances throughout codebase
|
||||
if [ -f $CONFIG_FILE ]; then
|
||||
cp $CONFIG_FILE $BACKUP_DIR
|
||||
fi
|
||||
```
|
||||
|
||||
### After (Proper Variable Quoting)
|
||||
```bash
|
||||
# Safe variable usage with proper quoting
|
||||
chsh -s "$(which zsh)" root
|
||||
|
||||
# Consistent quoting pattern
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
cp "$CONFIG_FILE" "$BACKUP_DIR/"
|
||||
fi
|
||||
|
||||
# Function parameter handling
|
||||
function configure_service() {
|
||||
local service_name="$1"
|
||||
local config_file="$2"
|
||||
|
||||
if [[ -z "$service_name" || -z "$config_file" ]]; then
|
||||
print_error "configure_service: service name and config file required"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_info "Configuring service: $service_name"
|
||||
# Safe operations with quoted variables
|
||||
}
|
||||
```
|
||||
|
||||
## Service Management with Error Handling
|
||||
|
||||
### Before (Basic Service Operations)
|
||||
```bash
|
||||
# Current pattern in various modules
|
||||
systemctl restart snmpd
|
||||
systemctl enable snmpd
|
||||
```
|
||||
|
||||
### After (Robust Service Management)
|
||||
```bash
|
||||
function safe_service_restart() {
|
||||
local service="$1"
|
||||
local config_test_cmd="${2:-}"
|
||||
|
||||
if [[ -z "$service" ]]; then
|
||||
print_error "safe_service_restart: service name required"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_info "Managing service: $service"
|
||||
|
||||
# Test configuration if test command provided
|
||||
if [[ -n "$config_test_cmd" ]]; then
|
||||
print_info "Testing $service configuration..."
|
||||
if ! eval "$config_test_cmd"; then
|
||||
print_error "$service configuration test failed"
|
||||
return 1
|
||||
fi
|
||||
print_success "$service configuration test passed"
|
||||
fi
|
||||
|
||||
# Check if service exists
|
||||
if ! systemctl list-unit-files "$service.service" >/dev/null 2>&1; then
|
||||
print_error "Service $service does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Stop service if running
|
||||
if systemctl is-active "$service" >/dev/null 2>&1; then
|
||||
print_info "Stopping $service..."
|
||||
if ! systemctl stop "$service"; then
|
||||
print_error "Failed to stop $service"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start and enable service
|
||||
print_info "Starting and enabling $service..."
|
||||
if systemctl start "$service" && systemctl enable "$service"; then
|
||||
print_success "$service started and enabled successfully"
|
||||
|
||||
# Verify service is running
|
||||
sleep 2
|
||||
if systemctl is-active "$service" >/dev/null 2>&1; then
|
||||
print_success "$service is running properly"
|
||||
return 0
|
||||
else
|
||||
print_error "$service failed to start properly"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print_error "Failed to start or enable $service"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Usage examples
|
||||
safe_service_restart "sshd" "sshd -t"
|
||||
safe_service_restart "snmpd"
|
||||
safe_service_restart "rsyslog"
|
||||
```
|
||||
|
||||
## Batch Configuration Deployment
|
||||
|
||||
### Before (Individual File Operations)
|
||||
```bash
|
||||
# Lines 66-77 in secharden-scap-stig.sh
|
||||
curl --silent ${DL_ROOT}/ProjectCode/ConfigFiles/ModProbe/usb_storage.conf > /etc/modprobe.d/usb_storage.conf
|
||||
curl --silent ${DL_ROOT}/ProjectCode/ConfigFiles/ModProbe/dccp.conf > /etc/modprobe.d/dccp.conf
|
||||
curl --silent ${DL_ROOT}/ProjectCode/ConfigFiles/ModProbe/rds.conf > /etc/modprobe.d/rds.conf
|
||||
# ... 12 more individual downloads
|
||||
```
|
||||
|
||||
### After (Batch Operations with Error Handling)
|
||||
```bash
|
||||
function deploy_modprobe_configs() {
|
||||
print_info "Deploying modprobe security configurations..."
|
||||
|
||||
source "$PROJECT_ROOT/Framework-Includes/SafeDownload.sh"
|
||||
|
||||
local modprobe_configs=(
|
||||
"usb_storage" "dccp" "rds" "sctp" "tipc"
|
||||
"cramfs" "freevxfs" "hfs" "hfsplus"
|
||||
"jffs2" "squashfs" "udf"
|
||||
)
|
||||
|
||||
# Create download map
|
||||
declare -A config_downloads=()
|
||||
for config in "${modprobe_configs[@]}"; do
|
||||
local url="${DL_ROOT}/ProjectCode/ConfigFiles/ModProbe/${config}.conf"
|
||||
local dest="/etc/modprobe.d/${config}.conf"
|
||||
config_downloads["$url"]="$dest"
|
||||
done
|
||||
|
||||
# Validate URLs first
|
||||
local urls=()
|
||||
for url in "${!config_downloads[@]}"; do
|
||||
urls+=("$url")
|
||||
done
|
||||
|
||||
if ! validate_required_urls "${urls[@]}"; then
|
||||
print_error "Some modprobe configuration URLs are not accessible"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Perform batch download
|
||||
if batch_download config_downloads; then
|
||||
print_success "All modprobe configurations deployed"
|
||||
|
||||
# Update initramfs to apply changes
|
||||
if update-initramfs -u; then
|
||||
print_success "Initramfs updated with new module configurations"
|
||||
else
|
||||
print_warning "Failed to update initramfs - reboot may be required"
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "Failed to deploy some modprobe configurations"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
## Input Validation and Error Handling
|
||||
|
||||
### Before (Minimal Validation)
|
||||
```bash
|
||||
# pi-detect.sh current implementation
|
||||
function pi-detect() {
|
||||
print_info Now running "$FUNCNAME"....
|
||||
if [ -f /sys/firmware/devicetree/base/model ] ; then
|
||||
export IS_RASPI="1"
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
### After (Comprehensive Validation)
|
||||
```bash
|
||||
function pi-detect() {
|
||||
print_info "Now running $FUNCNAME..."
|
||||
|
||||
# Initialize variables with default values
|
||||
export IS_RASPI="0"
|
||||
export PI_MODEL=""
|
||||
export PI_REVISION=""
|
||||
|
||||
# Check for Raspberry Pi detection file
|
||||
local device_tree_model="/sys/firmware/devicetree/base/model"
|
||||
local cpuinfo_file="/proc/cpuinfo"
|
||||
|
||||
if [[ -f "$device_tree_model" ]]; then
|
||||
# Try device tree method first (most reliable)
|
||||
local model_info
|
||||
model_info=$(tr -d '\0' < "$device_tree_model" 2>/dev/null)
|
||||
|
||||
if [[ "$model_info" =~ [Rr]aspberry.*[Pp]i ]]; then
|
||||
export IS_RASPI="1"
|
||||
export PI_MODEL="$model_info"
|
||||
print_success "Raspberry Pi detected via device tree: $PI_MODEL"
|
||||
fi
|
||||
elif [[ -f "$cpuinfo_file" ]]; then
|
||||
# Fallback to cpuinfo method
|
||||
if grep -qi "raspberry" "$cpuinfo_file"; then
|
||||
export IS_RASPI="1"
|
||||
PI_MODEL=$(grep "^Model" "$cpuinfo_file" | cut -d: -f2 | sed 's/^[[:space:]]*//' 2>/dev/null || echo "Unknown Pi Model")
|
||||
PI_REVISION=$(grep "^Revision" "$cpuinfo_file" | cut -d: -f2 | sed 's/^[[:space:]]*//' 2>/dev/null || echo "Unknown")
|
||||
export PI_MODEL
|
||||
export PI_REVISION
|
||||
print_success "Raspberry Pi detected via cpuinfo: $PI_MODEL (Rev: $PI_REVISION)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$IS_RASPI" == "1" ]]; then
|
||||
print_info "Raspberry Pi specific optimizations will be applied"
|
||||
else
|
||||
print_info "Standard x86/x64 system detected"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
```
|
||||
|
||||
## Function Framework Integration
|
||||
|
||||
### Before (Inconsistent Framework Usage)
|
||||
```bash
|
||||
# Mixed patterns throughout codebase
|
||||
function some_function() {
|
||||
echo "Doing something..."
|
||||
command_that_might_fail
|
||||
echo "Done"
|
||||
}
|
||||
```
|
||||
|
||||
### After (Standardized Framework Integration)
|
||||
```bash
|
||||
function some_function() {
|
||||
print_info "Now running $FUNCNAME..."
|
||||
|
||||
# Local variables
|
||||
local config_file="/etc/example.conf"
|
||||
local backup_dir="/root/backup"
|
||||
local failed=0
|
||||
|
||||
# Validate prerequisites
|
||||
if [[ ! -d "$backup_dir" ]]; then
|
||||
if ! mkdir -p "$backup_dir"; then
|
||||
print_error "Failed to create backup directory: $backup_dir"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Backup existing configuration
|
||||
if [[ -f "$config_file" ]]; then
|
||||
if cp "$config_file" "$backup_dir/$(basename "$config_file").bak.$(date +%Y%m%d-%H%M%S)"; then
|
||||
print_info "Backed up existing configuration"
|
||||
else
|
||||
print_error "Failed to backup existing configuration"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Perform main operation with error handling
|
||||
if command_that_might_fail; then
|
||||
print_success "Operation completed successfully"
|
||||
else
|
||||
print_error "Operation failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_success "Completed $FUNCNAME"
|
||||
return 0
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Monitoring Integration
|
||||
|
||||
### Enhanced Deployment with Metrics
|
||||
```bash
|
||||
function deploy_with_metrics() {
|
||||
local start_time end_time duration
|
||||
local operation_name="$1"
|
||||
shift
|
||||
local operation_function="$1"
|
||||
shift
|
||||
|
||||
print_info "Starting $operation_name..."
|
||||
start_time=$(date +%s)
|
||||
|
||||
# Execute the operation
|
||||
if "$operation_function" "$@"; then
|
||||
end_time=$(date +%s)
|
||||
duration=$((end_time - start_time))
|
||||
|
||||
print_success "$operation_name completed in ${duration}s"
|
||||
|
||||
# Log performance metrics
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - $operation_name: ${duration}s" >> /var/log/fetchapply-performance.log
|
||||
|
||||
# Alert if operation took too long
|
||||
case "$operation_name" in
|
||||
"Package Installation")
|
||||
if [[ $duration -gt 300 ]]; then
|
||||
print_warning "Package installation took longer than expected (${duration}s > 300s)"
|
||||
fi
|
||||
;;
|
||||
"Configuration Download")
|
||||
if [[ $duration -gt 120 ]]; then
|
||||
print_warning "Configuration download took longer than expected (${duration}s > 120s)"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
else
|
||||
end_time=$(date +%s)
|
||||
duration=$((end_time - start_time))
|
||||
|
||||
print_error "$operation_name failed after ${duration}s"
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - $operation_name: FAILED after ${duration}s" >> /var/log/fetchapply-performance.log
|
||||
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Usage example
|
||||
deploy_with_metrics "Package Installation" install_all_packages
|
||||
deploy_with_metrics "Configuration Download" download_system_configs
|
||||
deploy_with_metrics "SSH Hardening" configure_ssh_hardening
|
||||
```
|
||||
|
||||
## Testing Integration
|
||||
|
||||
### Comprehensive Validation Function
|
||||
```bash
|
||||
function validate_deployment() {
|
||||
print_header "Deployment Validation"
|
||||
|
||||
local validation_failures=0
|
||||
|
||||
# Test package installation
|
||||
local required_packages=("git" "curl" "wget" "snmpd" "auditd" "fail2ban")
|
||||
for package in "${required_packages[@]}"; do
|
||||
if dpkg -l | grep -q "^ii.*$package"; then
|
||||
print_success "Package installed: $package"
|
||||
else
|
||||
print_error "Package missing: $package"
|
||||
((validation_failures++))
|
||||
fi
|
||||
done
|
||||
|
||||
# Test service status
|
||||
local required_services=("sshd" "snmpd" "auditd" "rsyslog")
|
||||
for service in "${required_services[@]}"; do
|
||||
if systemctl is-active "$service" >/dev/null 2>&1; then
|
||||
print_success "Service running: $service"
|
||||
else
|
||||
print_error "Service not running: $service"
|
||||
((validation_failures++))
|
||||
fi
|
||||
done
|
||||
|
||||
# Test configuration files
|
||||
local required_configs=("/etc/ssh/sshd_config" "/etc/snmp/snmpd.conf" "/etc/rsyslog.conf")
|
||||
for config in "${required_configs[@]}"; do
|
||||
if [[ -f "$config" && -s "$config" ]]; then
|
||||
print_success "Configuration exists: $(basename "$config")"
|
||||
else
|
||||
print_error "Configuration missing or empty: $(basename "$config")"
|
||||
((validation_failures++))
|
||||
fi
|
||||
done
|
||||
|
||||
# Run security tests
|
||||
if command -v lynis >/dev/null 2>&1; then
|
||||
print_info "Running basic security audit..."
|
||||
if lynis audit system --quick --quiet; then
|
||||
print_success "Security audit completed"
|
||||
else
|
||||
print_warning "Security audit found issues"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Summary
|
||||
if [[ $validation_failures -eq 0 ]]; then
|
||||
print_success "All deployment validation checks passed"
|
||||
return 0
|
||||
else
|
||||
print_error "$validation_failures deployment validation checks failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
These refactoring examples demonstrate how to apply the code review findings to create more robust, performant, and maintainable infrastructure provisioning scripts.
|
||||
@@ -1,190 +0,0 @@
|
||||
# TSYS FetchApply Security Documentation
|
||||
|
||||
## Security Architecture
|
||||
|
||||
The TSYS FetchApply infrastructure provisioning system is designed with security-first principles, implementing multiple layers of protection for server deployment and management.
|
||||
|
||||
## Current Security Features
|
||||
|
||||
### 1. Secure Deployment Method ✅
|
||||
- **Git-based deployment:** Uses `git clone` instead of `curl | bash`
|
||||
- **Local execution:** Scripts run locally after inspection
|
||||
- **Version control:** Full audit trail of changes
|
||||
- **Code review:** Changes require explicit approval
|
||||
|
||||
### 2. HTTPS Enforcement ✅
|
||||
- **All downloads use HTTPS:** Eliminates man-in-the-middle attacks
|
||||
- **SSL certificate validation:** Automatic certificate checking
|
||||
- **Secure repositories:** Ubuntu archive, Dell, Proxmox all use HTTPS
|
||||
- **No HTTP fallbacks:** No insecure download methods
|
||||
|
||||
### 3. SSH Hardening
|
||||
- **Key-only authentication:** Password login disabled
|
||||
- **Secure ciphers:** Modern encryption algorithms only
|
||||
- **Fail2ban protection:** Automated intrusion prevention
|
||||
- **Custom SSH configuration:** Hardened sshd_config
|
||||
|
||||
### 4. System Security
|
||||
- **Firewall configuration:** Automated iptables rules
|
||||
- **Audit logging:** auditd with custom rules
|
||||
- **SIEM integration:** Wazuh agent deployment
|
||||
- **Compliance scanning:** SCAP-STIG automated checks
|
||||
|
||||
### 5. Error Handling
|
||||
- **Bash strict mode:** `set -euo pipefail` prevents errors
|
||||
- **Centralized logging:** All operations logged with timestamps
|
||||
- **Graceful failures:** Proper cleanup on errors
|
||||
- **Line-level debugging:** Error reporting with line numbers
|
||||
|
||||
## Security Testing
|
||||
|
||||
### Automated Security Validation
|
||||
```bash
|
||||
# Run security test suite
|
||||
./Project-Tests/run-tests.sh security
|
||||
|
||||
# Specific security tests
|
||||
./Project-Tests/security/https-enforcement.sh
|
||||
```
|
||||
|
||||
### Security Test Categories
|
||||
1. **HTTPS Enforcement:** Validates all URLs use HTTPS
|
||||
2. **Deployment Security:** Checks for secure deployment methods
|
||||
3. **SSL Certificate Validation:** Tests certificate authenticity
|
||||
4. **Permission Validation:** Verifies proper file permissions
|
||||
|
||||
## Threat Model
|
||||
|
||||
### Mitigated Threats
|
||||
- **Supply Chain Attacks:** Git-based deployment with review
|
||||
- **Man-in-the-Middle:** HTTPS-only downloads
|
||||
- **Privilege Escalation:** Proper permission models
|
||||
- **Unauthorized Access:** SSH hardening and key management
|
||||
|
||||
### Remaining Risks
|
||||
- **Secrets in Repository:** SSH keys stored in git (planned for removal)
|
||||
- **No Integrity Verification:** Downloads lack checksum validation
|
||||
- **No Backup/Recovery:** No rollback capability implemented
|
||||
|
||||
## Security Recommendations
|
||||
|
||||
### High Priority
|
||||
1. **Implement Secrets Management**
|
||||
- Remove SSH keys from repository
|
||||
- Use Bitwarden/Vault for secret storage
|
||||
- Implement key rotation procedures
|
||||
|
||||
2. **Add Download Integrity Verification**
|
||||
- SHA256 checksum validation for all downloads
|
||||
- GPG signature verification where available
|
||||
- Fail-safe on integrity check failures
|
||||
|
||||
3. **Enhance Audit Logging**
|
||||
- Centralized log collection
|
||||
- Real-time security monitoring
|
||||
- Automated threat detection
|
||||
|
||||
### Medium Priority
|
||||
1. **Configuration Backup**
|
||||
- System state snapshots before changes
|
||||
- Rollback capability for failed deployments
|
||||
- Configuration drift detection
|
||||
|
||||
2. **Network Security**
|
||||
- VPN-based deployment (where applicable)
|
||||
- Network segmentation for management
|
||||
- Encrypted communication channels
|
||||
|
||||
## Compliance
|
||||
|
||||
### Security Standards
|
||||
- **CIS Benchmarks:** Automated compliance checking
|
||||
- **STIG Guidelines:** SCAP-based validation
|
||||
- **Industry Best Practices:** Following NIST cybersecurity framework
|
||||
|
||||
### Audit Requirements
|
||||
- **Change Tracking:** All modifications logged
|
||||
- **Access Control:** Permission-based system access
|
||||
- **Vulnerability Management:** Regular security assessments
|
||||
|
||||
## Incident Response
|
||||
|
||||
### Security Event Handling
|
||||
1. **Detection:** Automated monitoring and alerting
|
||||
2. **Containment:** Immediate isolation procedures
|
||||
3. **Investigation:** Log analysis and forensics
|
||||
4. **Recovery:** System restoration procedures
|
||||
5. **Lessons Learned:** Process improvement
|
||||
|
||||
### Contact Information
|
||||
- **Security Team:** [To be defined]
|
||||
- **Incident Response:** [To be defined]
|
||||
- **Escalation Path:** [To be defined]
|
||||
|
||||
## Security Development Lifecycle
|
||||
|
||||
### Code Review Process
|
||||
1. **Static Analysis:** Automated security scanning
|
||||
2. **Peer Review:** Manual code inspection
|
||||
3. **Security Testing:** Automated security test suite
|
||||
4. **Approval:** Security team sign-off
|
||||
|
||||
### Deployment Security
|
||||
1. **Pre-deployment Validation:** Security test execution
|
||||
2. **Secure Deployment:** Authorized personnel only
|
||||
3. **Post-deployment Verification:** Security configuration validation
|
||||
4. **Monitoring:** Continuous security monitoring
|
||||
|
||||
## Security Tools and Integrations
|
||||
|
||||
### Current Tools
|
||||
- **Wazuh:** SIEM and security monitoring
|
||||
- **Lynis:** Security auditing
|
||||
- **auditd:** System call auditing
|
||||
- **Fail2ban:** Intrusion prevention
|
||||
|
||||
### Planned Integrations
|
||||
- **Vault/Bitwarden:** Secrets management
|
||||
- **OSSEC:** Host-based intrusion detection
|
||||
- **Nessus/OpenVAS:** Vulnerability scanning
|
||||
- **ELK Stack:** Log aggregation and analysis
|
||||
|
||||
## Vulnerability Management
|
||||
|
||||
### Vulnerability Scanning
|
||||
- **Regular scans:** Monthly vulnerability assessments
|
||||
- **Automated patching:** Security update automation
|
||||
- **Exception handling:** Risk-based patch management
|
||||
- **Reporting:** Executive security dashboards
|
||||
|
||||
### Disclosure Process
|
||||
1. **Internal Discovery:** Report to security team
|
||||
2. **Assessment:** Risk and impact evaluation
|
||||
3. **Remediation:** Patch development and testing
|
||||
4. **Deployment:** Coordinated security updates
|
||||
5. **Verification:** Post-patch validation
|
||||
|
||||
## Security Metrics
|
||||
|
||||
### Key Performance Indicators
|
||||
- **Deployment Success Rate:** Percentage of successful secure deployments
|
||||
- **Vulnerability Response Time:** Time to patch critical vulnerabilities
|
||||
- **Security Test Coverage:** Percentage of code covered by security tests
|
||||
- **Incident Response Time:** Time to detect and respond to security events
|
||||
|
||||
### Monitoring and Reporting
|
||||
- **Real-time Dashboards:** Security status monitoring
|
||||
- **Executive Reports:** Monthly security summaries
|
||||
- **Compliance Reports:** Quarterly compliance assessments
|
||||
- **Trend Analysis:** Security posture improvement tracking
|
||||
|
||||
## Contact and Support
|
||||
|
||||
For security-related questions or incidents:
|
||||
- **Repository Issues:** https://projects.knownelement.com/project/reachableceo-vptechnicaloperations/timeline
|
||||
- **Community Discussion:** https://community.turnsys.com/c/chieftechnologyandproductofficer/26
|
||||
- **Security Team:** [Contact information to be added]
|
||||
|
||||
## Security Updates
|
||||
|
||||
This document is updated as security features are implemented and threats evolve. Last updated: July 14, 2025.
|
||||
@@ -1,329 +0,0 @@
|
||||
# TSYS Two-Factor Authentication Implementation Guide
|
||||
|
||||
## Overview
|
||||
|
||||
This guide provides complete instructions for implementing and managing two-factor authentication (2FA) on TSYS servers using Google Authenticator (TOTP).
|
||||
|
||||
## What This Implementation Provides
|
||||
|
||||
### Services Protected by 2FA
|
||||
- **SSH Access:** Requires SSH key + 2FA token
|
||||
- **Cockpit Web Interface:** Requires password + 2FA token
|
||||
- **Webmin Administration:** Requires password + 2FA token (if installed)
|
||||
|
||||
### Security Features
|
||||
- **Time-based One-Time Passwords (TOTP):** Standard 6-digit codes
|
||||
- **Backup Codes:** Emergency access codes
|
||||
- **Gradual Rollout:** Optional nullok mode for phased deployment
|
||||
- **Configuration Backup:** Automatic backup of all configs
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Step 1: Run the 2FA Setup Script
|
||||
```bash
|
||||
# Navigate to the security modules directory
|
||||
cd ProjectCode/Modules/Security
|
||||
|
||||
# Run the 2FA setup script as root
|
||||
sudo bash secharden-2fa.sh
|
||||
```
|
||||
|
||||
### Step 2: Validate Installation
|
||||
```bash
|
||||
# Run 2FA validation tests
|
||||
./Project-Tests/security/2fa-validation.sh
|
||||
|
||||
# Run specific 2FA security test
|
||||
./Project-Tests/run-tests.sh security
|
||||
```
|
||||
|
||||
### Step 3: Setup Individual Users
|
||||
For each user that needs 2FA access:
|
||||
|
||||
```bash
|
||||
# Check setup instructions
|
||||
cat /home/username/2fa-setup-instructions.txt
|
||||
|
||||
# Run user setup script
|
||||
sudo /tmp/setup-2fa-username.sh
|
||||
```
|
||||
|
||||
### Step 4: Test 2FA Access
|
||||
1. **Test SSH access** from another terminal
|
||||
2. **Test Cockpit access** via web browser
|
||||
3. **Test Webmin access** if installed
|
||||
|
||||
## User Setup Process
|
||||
|
||||
### Installing Authenticator Apps
|
||||
Users need one of these apps on their phone:
|
||||
- **Google Authenticator** (Android/iOS)
|
||||
- **Authy** (Android/iOS)
|
||||
- **Microsoft Authenticator** (Android/iOS)
|
||||
- **1Password** (with TOTP support)
|
||||
|
||||
### Setting Up 2FA for a User
|
||||
1. **Run setup script:**
|
||||
```bash
|
||||
sudo /tmp/setup-2fa-username.sh
|
||||
```
|
||||
|
||||
2. **Follow prompts:**
|
||||
- Answer "y" to update time-based token
|
||||
- Scan QR code with authenticator app
|
||||
- Save emergency backup codes securely
|
||||
- Answer "y" to remaining security questions
|
||||
|
||||
3. **Test immediately:**
|
||||
```bash
|
||||
# Test SSH from another terminal
|
||||
ssh username@server-ip
|
||||
# You'll be prompted for 6-digit code
|
||||
```
|
||||
|
||||
## Configuration Details
|
||||
|
||||
### SSH Configuration Changes
|
||||
File: `/etc/ssh/sshd_config`
|
||||
```
|
||||
ChallengeResponseAuthentication yes
|
||||
UsePAM yes
|
||||
AuthenticationMethods publickey,keyboard-interactive
|
||||
```
|
||||
|
||||
### PAM Configuration
|
||||
File: `/etc/pam.d/sshd`
|
||||
```
|
||||
auth required pam_google_authenticator.so nullok
|
||||
```
|
||||
|
||||
### Cockpit Configuration
|
||||
File: `/etc/cockpit/cockpit.conf`
|
||||
```
|
||||
[WebService]
|
||||
LoginTitle = TSYS Server Management
|
||||
LoginTo = 300
|
||||
RequireHost = true
|
||||
|
||||
[Session]
|
||||
Banner = /etc/cockpit/issue.cockpit
|
||||
IdleTimeout = 15
|
||||
```
|
||||
|
||||
### Webmin Configuration
|
||||
File: `/etc/webmin/miniserv.conf`
|
||||
```
|
||||
twofactor_provider=totp
|
||||
twofactor=1
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Gradual vs Strict Enforcement
|
||||
|
||||
#### Gradual Enforcement (Default)
|
||||
- Uses `nullok` option in PAM
|
||||
- Users without 2FA can still log in
|
||||
- Allows phased rollout
|
||||
- Good for initial deployment
|
||||
|
||||
#### Strict Enforcement
|
||||
- Remove `nullok` from PAM configuration
|
||||
- All users must have 2FA configured
|
||||
- Immediate security enforcement
|
||||
- Risk of lockout if misconfigured
|
||||
|
||||
### Backup and Recovery
|
||||
|
||||
#### Emergency Access
|
||||
- **Backup codes:** Generated during setup
|
||||
- **Root access:** Can disable 2FA if needed
|
||||
- **Console access:** Physical/virtual console bypasses SSH
|
||||
|
||||
#### Configuration Backup
|
||||
- Automatic backup to `/root/backup/2fa-TIMESTAMP/`
|
||||
- Includes all modified configuration files
|
||||
- Can be restored if needed
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### 1. User Cannot Generate QR Code
|
||||
```bash
|
||||
# Ensure qrencode is installed
|
||||
sudo apt-get install qrencode
|
||||
|
||||
# Re-run user setup
|
||||
sudo /tmp/setup-2fa-username.sh
|
||||
```
|
||||
|
||||
#### 2. SSH Connection Fails
|
||||
```bash
|
||||
# Check SSH service status
|
||||
sudo systemctl status sshd
|
||||
|
||||
# Test SSH configuration
|
||||
sudo sshd -t
|
||||
|
||||
# Check logs
|
||||
sudo journalctl -u sshd -f
|
||||
```
|
||||
|
||||
#### 3. 2FA Code Not Accepted
|
||||
- **Check time synchronization** on server and phone
|
||||
- **Verify app setup** - rescan QR code if needed
|
||||
- **Try backup codes** if available
|
||||
|
||||
#### 4. Locked Out of Server
|
||||
```bash
|
||||
# Access via console (physical/virtual)
|
||||
# Disable 2FA temporarily
|
||||
sudo cp /root/backup/2fa-*/pam.d.bak/sshd /etc/pam.d/sshd
|
||||
sudo systemctl restart sshd
|
||||
```
|
||||
|
||||
### Debug Commands
|
||||
|
||||
```bash
|
||||
# Check 2FA status
|
||||
./Project-Tests/security/2fa-validation.sh
|
||||
|
||||
# Check SSH configuration
|
||||
sudo sshd -T | grep -E "(Challenge|PAM|Authentication)"
|
||||
|
||||
# Check PAM configuration
|
||||
cat /etc/pam.d/sshd | grep google-authenticator
|
||||
|
||||
# Check user 2FA status
|
||||
ls -la ~/.google_authenticator
|
||||
```
|
||||
|
||||
## Management and Maintenance
|
||||
|
||||
### Adding New Users
|
||||
1. Ensure user account exists
|
||||
2. Run setup script for new user
|
||||
3. Provide setup instructions
|
||||
4. Test access
|
||||
|
||||
### Removing User 2FA
|
||||
```bash
|
||||
# Remove user's 2FA configuration
|
||||
sudo rm /home/username/.google_authenticator
|
||||
|
||||
# User will need to re-setup 2FA
|
||||
```
|
||||
|
||||
### Disabling 2FA System-Wide
|
||||
```bash
|
||||
# Restore original configurations
|
||||
sudo cp /root/backup/2fa-*/sshd_config.bak /etc/ssh/sshd_config
|
||||
sudo cp /root/backup/2fa-*/pam.d.bak/sshd /etc/pam.d/sshd
|
||||
sudo systemctl restart sshd
|
||||
```
|
||||
|
||||
### Updating 2FA Configuration
|
||||
```bash
|
||||
# Re-run setup script
|
||||
sudo bash secharden-2fa.sh
|
||||
|
||||
# Validate changes
|
||||
./Project-Tests/security/2fa-validation.sh
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Deployment Strategy
|
||||
1. **Test in non-production** environment first
|
||||
2. **Enable gradual rollout** (nullok) initially
|
||||
3. **Train users** on 2FA setup process
|
||||
4. **Test emergency procedures** before strict enforcement
|
||||
5. **Monitor logs** for authentication issues
|
||||
|
||||
### Security Recommendations
|
||||
- **Enforce strict mode** after successful rollout
|
||||
- **Regular backup code rotation**
|
||||
- **Monitor failed authentication attempts**
|
||||
- **Document emergency procedures**
|
||||
- **Regular security audits**
|
||||
|
||||
### User Training
|
||||
- **Provide clear instructions**
|
||||
- **Demonstrate setup process**
|
||||
- **Explain backup code importance**
|
||||
- **Test login process with users**
|
||||
- **Establish support procedures**
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
### Authentication Logs
|
||||
```bash
|
||||
# SSH authentication logs
|
||||
sudo journalctl -u sshd | grep -i "authentication"
|
||||
|
||||
# PAM authentication logs
|
||||
sudo journalctl | grep -i "pam_google_authenticator"
|
||||
|
||||
# Failed login attempts
|
||||
sudo journalctl | grep -i "failed"
|
||||
```
|
||||
|
||||
### Security Monitoring
|
||||
- Monitor for repeated failed 2FA attempts
|
||||
- Alert on successful logins without 2FA (during gradual rollout)
|
||||
- Track user 2FA setup completion
|
||||
- Monitor for emergency access usage
|
||||
|
||||
## Integration with Existing Systems
|
||||
|
||||
### LDAP/Active Directory
|
||||
- 2FA works with existing authentication systems
|
||||
- Users still need local 2FA setup
|
||||
- Consider centralized 2FA solutions for large deployments
|
||||
|
||||
### Monitoring Systems
|
||||
- LibreNMS: Will continue to work with SNMP
|
||||
- Wazuh: Will log 2FA authentication events
|
||||
- Cockpit: Enhanced with 2FA protection
|
||||
|
||||
### Backup Systems
|
||||
- Ensure backup procedures account for 2FA
|
||||
- Test restore procedures with 2FA enabled
|
||||
- Document emergency access procedures
|
||||
|
||||
## Support and Resources
|
||||
|
||||
### Files Created by Setup
|
||||
- `/tmp/setup-2fa-*.sh` - User setup scripts
|
||||
- `/home/*/2fa-setup-instructions.txt` - User instructions
|
||||
- `/root/backup/2fa-*/` - Configuration backups
|
||||
|
||||
### Validation Tools
|
||||
- `./Project-Tests/security/2fa-validation.sh` - Complete 2FA validation
|
||||
- `./Project-Tests/run-tests.sh security` - Security test suite
|
||||
|
||||
### Emergency Contacts
|
||||
- System Administrator: [Contact Info]
|
||||
- Security Team: [Contact Info]
|
||||
- 24/7 Support: [Contact Info]
|
||||
|
||||
## Compliance and Audit
|
||||
|
||||
### Security Benefits
|
||||
- Significantly reduces risk of unauthorized access
|
||||
- Meets multi-factor authentication requirements
|
||||
- Provides audit trail of authentication events
|
||||
- Complies with security frameworks (NIST, ISO 27001)
|
||||
|
||||
### Audit Trail
|
||||
- All authentication attempts logged
|
||||
- 2FA setup events recorded
|
||||
- Configuration changes tracked
|
||||
- Emergency access documented
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** July 14, 2025
|
||||
**Version:** 1.0
|
||||
**Author:** TSYS Security Team
|
||||
@@ -1,117 +0,0 @@
|
||||
# Charles TODO - TSYS FetchApply Security Improvements
|
||||
|
||||
**Priority Order:** High → Medium → Low
|
||||
**Target:** Address security vulnerabilities and operational improvements
|
||||
|
||||
## 🚨 HIGH PRIORITY (Security Critical)
|
||||
|
||||
### ✅ 1. Replace Insecure Deployment Method - RESOLVED
|
||||
**Previous Issue:** `curl https://dl.knownelement.com/KNEL/FetchApply/SetupNewSystem.sh | bash`
|
||||
**Status:** Fixed in README.md - now uses secure git clone approach
|
||||
**Current Method:** `git clone this repo` → `cd FetchApply/ProjectCode` → `bash SetupNewSystem.sh`
|
||||
|
||||
**Remaining considerations:**
|
||||
- Consider implementing GPG signature verification for tagged releases
|
||||
- Add cryptographic checksums for external downloads within scripts
|
||||
|
||||
### ✅ 2. Enforce HTTPS for All Downloads - RESOLVED
|
||||
**Previous Issue:** HTTP URLs in Dell OMSA and some repository setups
|
||||
**Status:** All HTTP URLs converted to HTTPS across:
|
||||
- `ProjectCode/Dell/Server/omsa.sh` - Ubuntu archive and Dell repo URLs
|
||||
- `ProjectCode/legacy/prox7.sh` - Proxmox download URLs
|
||||
- `ProjectCode/Modules/RandD/sslStackFromSource.sh` - Apache source URLs
|
||||
|
||||
**Remaining considerations:**
|
||||
- SSL certificate validation is enabled by default in wget/curl
|
||||
- Consider adding retry logic for certificate failures
|
||||
|
||||
### 3. Implement Secrets Management
|
||||
**Current Issue:** SSH keys committed to repository, no secrets rotation
|
||||
**Action Required:**
|
||||
- Deploy Bitwarden CLI or HashiCorp Vault integration
|
||||
- Remove SSH public keys from repository
|
||||
- Create secure key distribution mechanism
|
||||
- Implement key rotation procedures
|
||||
- Add environment variable support for sensitive data
|
||||
|
||||
**Files to secure:**
|
||||
- `ProjectCode/ConfigFiles/SSH/AuthorizedKeys/` (entire directory)
|
||||
- Hard-coded hostnames in various scripts
|
||||
|
||||
## 🔶 MEDIUM PRIORITY (Operational Security)
|
||||
|
||||
### 4. Add Script Integrity Verification
|
||||
**Action Required:**
|
||||
- Generate SHA256 checksums for all scripts
|
||||
- Create checksum verification function in Framework-Includes
|
||||
- Add signature verification for external downloads
|
||||
- Implement rollback capability on verification failure
|
||||
|
||||
### 5. Enhanced Error Recovery
|
||||
**Action Required:**
|
||||
- Add state tracking for partial deployments
|
||||
- Implement resume functionality for interrupted installations
|
||||
- Create system restoration points before major changes
|
||||
- Add dependency checking before module execution
|
||||
|
||||
### 6. Security Testing Framework
|
||||
**Action Required:**
|
||||
- Create integration tests for security configurations
|
||||
- Add compliance validation (CIS benchmarks, STIG)
|
||||
- Implement automated security scanning post-deployment
|
||||
- Create test environments for validation
|
||||
|
||||
### 7. Configuration Validation
|
||||
**Action Required:**
|
||||
- Add pre-flight checks for system compatibility
|
||||
- Validate network connectivity to required services
|
||||
- Check for conflicting software before installation
|
||||
- Verify sufficient disk space and system resources
|
||||
|
||||
## 🔹 LOW PRIORITY (Quality Improvements)
|
||||
|
||||
### 8. Documentation Enhancement
|
||||
**Action Required:**
|
||||
- Create detailed security architecture documentation
|
||||
- Add troubleshooting guides for common issues
|
||||
- Document security implications of each module
|
||||
- Create deployment runbooks for different environments
|
||||
|
||||
### 9. Monitoring and Alerting
|
||||
**Action Required:**
|
||||
- Add deployment success/failure reporting
|
||||
- Implement centralized logging for all installations
|
||||
- Create dashboards for deployment status
|
||||
- Add alerting for security configuration drift
|
||||
|
||||
### 10. User Experience Improvements
|
||||
**Action Required:**
|
||||
- Create web-based deployment interface
|
||||
- Add progress indicators for long-running operations
|
||||
- Implement dry-run mode for testing configurations
|
||||
- Add interactive configuration selection
|
||||
|
||||
## Implementation Timeline
|
||||
|
||||
**✅ COMPLETED:** Item 1 (Secure deployment method)
|
||||
**✅ COMPLETED:** Item 2 (HTTPS enforcement)
|
||||
**Week 1:** Item 3 (Secrets management)
|
||||
**Week 2-3:** Items 4-5 (Operational improvements)
|
||||
**Month 2:** Items 6-10 (Quality and monitoring)
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- [ ] No plaintext secrets in repository
|
||||
- [x] All downloads use HTTPS with verification ✅
|
||||
- [x] Deployment method is cryptographically secure ✅
|
||||
- [ ] Automated testing validates security configurations
|
||||
- [ ] Rollback capability exists for all changes
|
||||
- [ ] Comprehensive documentation covers security implications
|
||||
|
||||
## Resources Needed
|
||||
|
||||
- Access to package repository for signed distributions
|
||||
- GPG key infrastructure for signing
|
||||
- Secrets management service (Vault/Bitwarden)
|
||||
- Test environment infrastructure
|
||||
- Security scanning tools integration
|
||||
@@ -1,162 +0,0 @@
|
||||
# Claude TODO - TSYS FetchApply Automation Tasks
|
||||
|
||||
**Purpose:** Actionable items optimized for AI assistant implementation
|
||||
**Priority:** Critical → High → Medium → Low
|
||||
|
||||
## 🚨 CRITICAL (Immediate Security Fixes)
|
||||
|
||||
### ✅ RESOLVED: Secure Deployment Method
|
||||
**Previous Issue:** `curl | bash` deployment method
|
||||
**Status:** Fixed in README.md - now uses `git clone` + local script execution
|
||||
|
||||
### ✅ RESOLVED: Replace HTTP URLs with HTTPS
|
||||
**Files modified:**
|
||||
- `ProjectCode/Dell/Server/omsa.sh` - Converted 11 HTTP URLs to HTTPS (Ubuntu archive, Dell repo)
|
||||
- `ProjectCode/legacy/prox7.sh` - Converted 2 HTTP URLs to HTTPS (Proxmox downloads)
|
||||
- `ProjectCode/Modules/RandD/sslStackFromSource.sh` - Converted 3 HTTP URLs to HTTPS (Apache sources)
|
||||
|
||||
**Status:** All HTTP URLs in active scripts converted to HTTPS. Only remaining HTTP references are in comments and LibreNMS agent files (external dependencies).
|
||||
|
||||
### TASK-002: Add Download Integrity Verification
|
||||
**Create new function in:** `Framework-Includes/VerifyDownload.sh`
|
||||
**Function to implement:**
|
||||
```bash
|
||||
function verify_download() {
|
||||
local url="$1"
|
||||
local expected_hash="$2"
|
||||
local output_file="$3"
|
||||
|
||||
curl -fsSL "$url" -o "$output_file"
|
||||
local actual_hash=$(sha256sum "$output_file" | cut -d' ' -f1)
|
||||
|
||||
if [ "$actual_hash" != "$expected_hash" ]; then
|
||||
print_error "Hash verification failed for $output_file"
|
||||
rm -f "$output_file"
|
||||
return 1
|
||||
fi
|
||||
print_info "Download verified: $output_file"
|
||||
}
|
||||
```
|
||||
|
||||
### TASK-003: Create Secure Deployment Script
|
||||
**Create:** `ProjectCode/SecureSetupNewSystem.sh`
|
||||
**Features to implement:**
|
||||
- GPG signature verification
|
||||
- SHA256 checksum validation
|
||||
- HTTPS-only downloads
|
||||
- Rollback capability
|
||||
|
||||
## 🔶 HIGH (Security Enhancements)
|
||||
|
||||
### TASK-004: Remove Hardcoded SSH Keys
|
||||
**Files to modify:**
|
||||
- `ProjectCode/ConfigFiles/SSH/AuthorizedKeys/root-ssh-authorized-keys`
|
||||
- `ProjectCode/ConfigFiles/SSH/AuthorizedKeys/localuser-ssh-authorized-keys`
|
||||
- `ProjectCode/Modules/Security/secharden-ssh.sh:31,40,51`
|
||||
|
||||
**Implementation approach:**
|
||||
1. Create environment variable support: `SSH_KEYS_URL` or `SSH_KEYS_VAULT_PATH`
|
||||
2. Modify secharden-ssh.sh to fetch keys from secure source
|
||||
3. Add key validation before deployment
|
||||
|
||||
### TASK-005: Add Secrets Management Framework
|
||||
**Create:** `Framework-Includes/SecretsManager.sh`
|
||||
**Functions to implement:**
|
||||
```bash
|
||||
function get_secret() { } # Retrieve secret from vault
|
||||
function validate_secret() { } # Validate secret format
|
||||
function rotate_secret() { } # Trigger secret rotation
|
||||
```
|
||||
|
||||
### TASK-006: Enhanced Preflight Checks
|
||||
**Modify:** `Framework-Includes/PreflightCheck.sh`
|
||||
**Add checks for:**
|
||||
- Network connectivity to required hosts
|
||||
- Disk space requirements
|
||||
- Existing conflicting software
|
||||
- Required system capabilities
|
||||
|
||||
## 🔹 MEDIUM (Operational Improvements)
|
||||
|
||||
### TASK-007: Add Configuration Backup
|
||||
**Create:** `Framework-Includes/ConfigBackup.sh`
|
||||
**Functions:**
|
||||
```bash
|
||||
function backup_config() { } # Create timestamped backup
|
||||
function restore_config() { } # Restore from backup
|
||||
function list_backups() { } # Show available backups
|
||||
```
|
||||
|
||||
### TASK-008: Implement State Tracking
|
||||
**Create:** `Framework-Includes/StateManager.sh`
|
||||
**Track:**
|
||||
- Deployment progress
|
||||
- Module completion status
|
||||
- Rollback points
|
||||
- System changes made
|
||||
|
||||
### TASK-009: Add Retry Logic
|
||||
**Enhance existing scripts with:**
|
||||
- Configurable retry attempts for network operations
|
||||
- Exponential backoff for failed operations
|
||||
- Circuit breaker for repeatedly failing services
|
||||
|
||||
## 🔸 LOW (Quality of Life)
|
||||
|
||||
### TASK-010: Enhanced Logging
|
||||
**Modify:** `Framework-Includes/Logging.sh`
|
||||
**Add:**
|
||||
- Structured logging (JSON format option)
|
||||
- Log levels (DEBUG, INFO, WARN, ERROR)
|
||||
- Remote logging capability
|
||||
- Log rotation management
|
||||
|
||||
### TASK-011: Progress Indicators
|
||||
**Add to:** `Framework-Includes/PrettyPrint.sh`
|
||||
```bash
|
||||
function show_progress() { } # Display progress bar
|
||||
function update_status() { } # Update current operation
|
||||
```
|
||||
|
||||
### TASK-012: Dry Run Mode
|
||||
**Add to:** `ProjectCode/SetupNewSystem.sh`
|
||||
**Implementation:**
|
||||
- `--dry-run` flag support
|
||||
- Preview of changes without execution
|
||||
- Dependency analysis output
|
||||
|
||||
## Implementation Order for Claude
|
||||
|
||||
**Updated Priority After Security Fix (July 14, 2025):**
|
||||
1. **Start with TASK-001** (HTTPS enforcement - simple find/replace operations)
|
||||
2. **Create framework functions** (TASK-002, TASK-005, TASK-007)
|
||||
3. **Enhance existing modules** (TASK-004, TASK-006)
|
||||
4. **Add operational features** (TASK-008, TASK-009)
|
||||
5. **Improve user experience** (TASK-010, TASK-011, TASK-012)
|
||||
|
||||
**Note:** Major deployment security risk resolved - remaining tasks focus on hardening internal operations.
|
||||
|
||||
## File Location Patterns
|
||||
|
||||
- **Framework components:** `Framework-Includes/*.sh`
|
||||
- **Security modules:** `ProjectCode/Modules/Security/*.sh`
|
||||
- **Configuration files:** `ProjectCode/ConfigFiles/*/`
|
||||
- **Main entry point:** `ProjectCode/SetupNewSystem.sh`
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
For each task:
|
||||
1. Create backup of original files
|
||||
2. Implement changes incrementally
|
||||
3. Test with `bash -n` for syntax validation
|
||||
4. Verify functionality with controlled test runs
|
||||
5. Document changes made
|
||||
|
||||
## Error Handling Requirements
|
||||
|
||||
All new functions must:
|
||||
- Use `set -euo pipefail` compatibility
|
||||
- Integrate with existing error handling framework
|
||||
- Log errors to `$LOGFILENAME`
|
||||
- Return appropriate exit codes
|
||||
- Clean up temporary files on failure
|
||||
@@ -1,217 +0,0 @@
|
||||
# Tailscale vs. Managed DNS — Architecture Analysis
|
||||
|
||||
> **Status:** analysis for review. No code decisions are final. Read the
|
||||
> "Known issues" section before acting on the managed-resolv.conf change.
|
||||
|
||||
## 1. Executive summary
|
||||
|
||||
Every host in this build runs the Tailscale client, and Tailscale — by default —
|
||||
**manages `/etc/resolv.conf` itself**, pointing it at `100.100.100.100`
|
||||
(Tailscale's MagicDNS resolver). This directly conflicts with the managed
|
||||
`resolv.conf` (pointing at `192.168.3.252`/`192.168.3.253`) that
|
||||
`SetupNewSystem.sh` deploys: whichever runs last wins, and Tailscale's daemon
|
||||
re-wins on every `tailscale up` and on reboot.
|
||||
|
||||
Worse, a probe of the live network shows that **knel.net device records only
|
||||
resolve through the Tailscale 100.100.100.100 path** — querying the LAN IPs of
|
||||
the DNS servers directly returns NXDOMAIN for current hostnames (the Technitium
|
||||
`knel.net` zone has the SOA but is stale/empty of actual records). So pointing
|
||||
`resolv.conf` at the LAN IPs would break resolution of the very names this
|
||||
project's modules depend on (`tsys-nsm.knel.net`, `tsys-cloudron.knel.net`,
|
||||
`tsys-librenms.knel.net`).
|
||||
|
||||
This document lays out the options and a recommended path forward.
|
||||
|
||||
## 2. How name resolution actually works today (as measured)
|
||||
|
||||
Probed from `sectestbed-sandbox` (192.168.3.50):
|
||||
|
||||
| Query path | External name (`github.com`) | knel.net device name (`pfv-netinfra-01.knel.net`) |
|
||||
|---|---|---|
|
||||
| Via current resolver = `100.100.100.100` (Tailscale) | resolves | **resolves** → `100.70.181.72` (Tailscale CGNAT) |
|
||||
| Direct `dig @192.168.3.252` (Technitium, LAN) | resolves (recurses) | **NXDOMAIN** (SOA present, no record) |
|
||||
| Direct `dig @192.168.3.253` (Pi-hole, LAN) | resolves (recurses) | **NXDOMAIN** (SOA present, no record) |
|
||||
|
||||
Other measured facts:
|
||||
|
||||
- `dig @192.168.3.252 knel.net SOA` → `NOERROR`, returns
|
||||
`knel.net. 900 IN SOA dns.knel.net. hostadmin.knel.net. 2025062313 …`
|
||||
(serial dated **2025-06-23** — the zone exists but is stale).
|
||||
- NTP on both `.252` and `.253` answers time queries (stratum 2/3).
|
||||
- The live `/etc/resolv.conf` on a deployed host reads:
|
||||
```
|
||||
# resolv.conf(5) file generated by tailscale
|
||||
# DO NOT EDIT THIS FILE BY HAND -- CHANGES WILL BE OVERWRITTEN
|
||||
nameserver 100.100.100.100
|
||||
nameserver fd7a:115c:a1e0::53
|
||||
search knel.net
|
||||
```
|
||||
|
||||
**Interpretation:** the `knel.net` device→Tailscale-IP mappings are synthesised
|
||||
by Tailscale's MagicDNS from the tailnet device registry (every device that
|
||||
joins the tailnet gets `hostname.knel.net` → its `100.x.x.x` address). The
|
||||
Technitium `knel.net` zone is a separate, manually-maintained zone that has
|
||||
fallen out of date. The two are not the same source of truth.
|
||||
|
||||
## 3. The core tension
|
||||
|
||||
| Goal | Who provides it today |
|
||||
|---|---|
|
||||
| Resolve `*.knel.net` device names (→ Tailscale IPs) | Tailscale MagicDNS via `100.100.100.100` |
|
||||
| Resolve external names with ad-blocking | Pi-hole (`.253`), reachable via Tailscale → Technitium → Pi-hole chain |
|
||||
| Redundant, low-latency, tunnel-independent DNS | LAN resolvers `.252`/`.253` — **but these lack knel.net records** |
|
||||
| Authoritative time | NTP on `.252`/`.253` (works on either path) |
|
||||
|
||||
The conflict: you cannot simply point `resolv.conf` at the LAN resolvers,
|
||||
because they do not know about the current `knel.net` device records, and
|
||||
several modules in this project resolve `knel.net` hostnames at runtime
|
||||
(wazuh manager, postfix relay, syslog target). You also cannot ignore Tailscale,
|
||||
because it is the only thing that resolves those names today.
|
||||
|
||||
## 4. Options
|
||||
|
||||
### Option A — Let Tailscale own DNS (status quo, `accept-dns=true`)
|
||||
|
||||
Leave the default. Tailscale writes `100.100.100.100` to `resolv.conf`; the
|
||||
control-plane forwarding (`100.100.100.100` → Technitium → Pi-hole) handles
|
||||
external names and ad-blocking; MagicDNS handles `knel.net` device names.
|
||||
|
||||
| Pros | Cons |
|
||||
|---|---|
|
||||
| Zero per-host config; new machines "just work" on `tailscale up` | **All DNS depends on the Tailscale daemon being up.** If `tailscaled` dies, every name lookup fails — including the ones you need to SSH in and fix it. |
|
||||
| MagicDNS + knel.net names resolve automatically | Latency: every query goes host→tailscaled→100.100.100.100→(tunnel)→Technitium→Pi-hole→upstream |
|
||||
| Ad-blocking preserved (via the Pi-hole hop) | Overwrites the managed `resolv.conf` — the `.252`/`.253` redundancy is lost |
|
||||
| Centralised in the Tailscale admin console | Single resolver in `resolv.conf` (`100.100.100.100`); no glibc-level failover |
|
||||
| | Boot-order risk: early-boot processes have no DNS until `tailscaled` is up |
|
||||
|
||||
### Option B — Pin resolv.conf to the LAN resolvers (`accept-dns=false`)
|
||||
|
||||
Set `--accept-dns=false` on every host and keep the managed `resolv.conf`
|
||||
pointing at `.252`/`.253`.
|
||||
|
||||
| Pros | Cons |
|
||||
|---|---|
|
||||
| DNS independent of Tailscale — survives `tailscaled` outages | **`*.knel.net` device names break (NXDOMAIN)** because the LAN resolvers' knel.net zone is stale. This breaks wazuh/postfix/syslog hostname resolution. |
|
||||
| Lowest latency, full glibc-level failover across two servers | MagicDNS names (`*.ts.net`) do not resolve |
|
||||
| Managed `resolv.conf` wins uncontested | Requires fixing the Technitium/Pi-hole `knel.net` zone to mirror the Tailscale device records before this is viable |
|
||||
| Boot-time DNS works immediately | Off-LAN hosts (laptops) can't reach `.252`/`.253` without the tunnel — back to needing Tailscale |
|
||||
|
||||
> **Not recommended as-is.** Only viable **after** the `knel.net` zone on
|
||||
> `.252`/`.253` is repopulated with current device records (see §6).
|
||||
|
||||
### Option C — Tailscale Split DNS (per-domain routing)
|
||||
|
||||
MagicDNS `ON`, "Override local DNS" `OFF` in the admin console; only `ts.net`
|
||||
(and explicitly split domains) route to `100.100.100.100`, everything else stays
|
||||
on the system resolver.
|
||||
|
||||
| Pros | Cons |
|
||||
|---|---|
|
||||
| Best of both worlds: MagicDNS names resolve AND general queries go direct | Requires `systemd-resolved` (or NetworkManager `dns=dnsmasq`) for per-domain routing. These hosts use a **plain `/etc/resolv.conf`** — on which Tailscale **cannot** do per-domain split; it replaces the whole file. |
|
||||
| Reduces tunnel dependency for non-Tailscale names | Migrating every host to `systemd-resolved` is a significant, cross-cutting change |
|
||||
| | More moving parts to reason about and debug |
|
||||
|
||||
### Option D — Make Tailscale push the LAN resolvers as global nameservers
|
||||
|
||||
In the admin console, set global nameservers to `192.168.3.252`/`192.168.3.253`,
|
||||
keep `accept-dns=true`.
|
||||
|
||||
| Pros | Cons |
|
||||
|---|---|
|
||||
| Clients get the LAN resolvers via Tailscale config (consistent) | Tailscale still overwrites `resolv.conf` |
|
||||
| MagicDNS still works (100.100.100.100 added for `ts.net`/`knel.net`) | On-LAN hosts don't need Tailscale to find `.252`/`.253` — pure indirection |
|
||||
| Centralised management | Still depends on `tailscaled` for DNS |
|
||||
| | `knel.net` device names still only resolve via the Tailscale path, so the LAN resolvers being "global" doesn't help those names unless the zone is fixed |
|
||||
|
||||
## 5. Recommendation
|
||||
|
||||
**Short term (unblock now): Option A — let Tailscale own DNS.** Revert/disable
|
||||
the managed-`resolv.conf` deployment so provisioning stops fighting Tailscale.
|
||||
Today, `knel.net` device names **only** resolve through Tailscale, and this
|
||||
project's modules depend on those names, so Tailscale-managed DNS is the only
|
||||
thing that currently works end-to-end. Keep the NTP change (LAN IPs, no DNS
|
||||
dependency) — that part is safe and beneficial regardless.
|
||||
|
||||
**Medium term (the real fix): populate the `knel.net` zone on the LAN
|
||||
resolvers**, then choose B or C. Concretely:
|
||||
|
||||
1. Make Technitium (`.252`) authoritative for `knel.net` **with current records**
|
||||
(mirror the Tailscale device→IP mappings, or enable a zone-transfer/sync from
|
||||
the Tailscale device registry, or use Technitium's "Tailscale" DNS app if
|
||||
available). Confirm `dig @192.168.3.252 pfv-netinfra-01.knel.net` returns an
|
||||
answer, not NXDOMAIN.
|
||||
2. Make Pi-hole (`.253`) forward `knel.net` to Technitium (or also serve the
|
||||
zone), so both resolvers in the pair can answer internal names — otherwise
|
||||
glibc failover to `.253` would silently break knel.net lookups.
|
||||
3. *Then* pin `resolv.conf` to `.252`/`.253` with `--accept-dns=false`
|
||||
(Option B), gaining tunnel-independent, redundant DNS.
|
||||
|
||||
**Long term (optional, if per-domain routing is wanted): Option C** — adopt
|
||||
`systemd-resolved` and configure Tailscale Split DNS so `ts.net`/`knel.net` go
|
||||
to MagicDNS and everything else goes direct. Only worth the migration cost if
|
||||
you specifically need `*.ts.net` short-name resolution alongside direct LAN DNS.
|
||||
|
||||
### Why not just force `.252`/`.253` today?
|
||||
|
||||
Because it regresses name resolution for the hostnames this project already
|
||||
uses. Concretely, with `resolv.conf` pinned to the LAN resolvers the following
|
||||
would fail to resolve:
|
||||
|
||||
- `ProjectCode/Modules/Security/secharden-wazuh.sh` → `WAZUH_MANAGER="tsys-nsm.knel.net"`
|
||||
- `ProjectCode/SetupNewSystem.sh` → `postconf -e "relayhost = tsys-cloudron.knel.net"`
|
||||
- `ProjectCode/ConfigFiles/Syslog/rsyslog.conf` → `*.* @tsys-librenms.knel.net:514`
|
||||
|
||||
All three resolve cleanly via `100.100.100.100` today and return NXDOMAIN via
|
||||
`.252`/`.253`. Pinning the LAN resolvers before the zone is fixed would break
|
||||
wazuh, mail relay, and syslog.
|
||||
|
||||
## 6. Known issues / action items
|
||||
|
||||
1. **Technitium `knel.net` zone is stale.** SOA serial `2025062313`
|
||||
(2025-06-23); current device names return NXDOMAIN from the LAN interface.
|
||||
Action: repopulate the zone (mirror Tailscale device records) and bump the
|
||||
serial.
|
||||
2. **Pi-hole (`.253`) has no `knel.net` device records either.** For the pair
|
||||
to be truly redundant for internal names, `.253` must either serve the same
|
||||
zone or conditional-forward `knel.net` to `.252`. Action: configure Pi-hole
|
||||
to forward `knel.net` to Technitium.
|
||||
3. **The managed-`resolv.conf` change (commit f010fa9) conflicts with
|
||||
Tailscale.** As written, `SetupNewSystem.sh` writes `resolv.conf` with
|
||||
`.252`/`.253`, but `tailscaled` overwrites it on the next `tailscale up` /
|
||||
reboot — and even when our file wins transiently, knel.net names break. See
|
||||
§5 for the recommended handling.
|
||||
4. **NTP change is safe and good.** `ntp.conf` now uses LAN IPs
|
||||
(`192.168.3.252`/`192.168.3.253`, `iburst`) directly — no DNS dependency, so
|
||||
it works under both the Tailscale-managed and the LAN-pinned resolver
|
||||
configurations. Keep this regardless of the DNS decision.
|
||||
5. **Split-horizon possibility (unconfirmed).** It is possible Technitium serves
|
||||
a richer `knel.net` zone on its Tailscale interface (`100.x`) than on its LAN
|
||||
interface (`192.168.3.252`). If so, the fix is to make the LAN view match the
|
||||
Tailscale view. Worth confirming with `dig @<technitium-tailscale-ip> knel.net host`.
|
||||
|
||||
## 7. Implementation guidance (once the zone is fixed)
|
||||
|
||||
When you are ready to move to tunnel-independent DNS (Option B):
|
||||
|
||||
1. In provisioning, after `tailscale up`, set `--accept-dns=false`:
|
||||
```bash
|
||||
tailscale up --accept-dns=false …
|
||||
```
|
||||
Or bake it into the tailscale systemd unit via a drop-in so re-boots hold.
|
||||
2. *Then* deploy the managed `resolv.conf` (`.252`/`.253`). Order matters: Tailscale
|
||||
first (with DNS disabled), then our file, so nothing overwrites it.
|
||||
3. Add a watchdog (timer) that restores `resolv.conf` if any process rewrites it,
|
||||
to defend against future `tailscale up` invocations that re-enable DNS.
|
||||
4. Validate with `Project-Tests/validation/dns-ntp-redundancy.sh` — and extend
|
||||
its probe to assert `*.knel.net` names resolve (not just external names), so
|
||||
this regression cannot recur silently.
|
||||
|
||||
## 8. TL;DR
|
||||
|
||||
- **DNS**: don't fight Tailscale yet. Today `knel.net` names only resolve via
|
||||
Tailscale, and this project depends on them. Fix the Technitium/Pi-hole
|
||||
`knel.net` zone first, *then* pin the LAN resolvers.
|
||||
- **NTP**: the LAN-IP change is correct and safe; keep it.
|
||||
- **The managed `resolv.conf` (`.252`/`.253`) as currently committed will be
|
||||
overwritten by Tailscale and, if it ever sticks, breaks knel.net resolution —
|
||||
see §5/§6 before relying on it.**
|
||||
@@ -1,21 +1,10 @@
|
||||
# KNEL FetchApply
|
||||
# README.md
|
||||
|
||||
## Repo Issues
|
||||
https://projects.knownelement.com/project/reachableceo-vptechnicaloperations/timeline
|
||||
|
||||
## Repo Discussion
|
||||
https://community.turnsys.com/c/chieftechnologyandproductofficer/26
|
||||
|
||||
|
||||
## Repo discription
|
||||
Known Element Enterprises (the entity serving as the TSYS Group management company) (through it’s executive leader, the COO) provides core IT/back office systems/services/support on a hands off/fully delegated authortity basis to the CCO and the orgs/members.
|
||||
|
||||
One of those functions is the provisoning of Linux servers. This repository is the Infrastructure As Code (IAC) repository for TSYS.
|
||||
|
||||
In the future it will be used via FetchApply https://github.com/P5vc/fetch-apply
|
||||
|
||||
## Usage
|
||||
|
||||
git clone this repo
|
||||
cd FetchApply/ProjectCode
|
||||
bash SetupNewSystem.sh
|
||||
> **Documentation moved to Discourse — the canonical source of truth.**
|
||||
>
|
||||
> **Project overview, architecture, quick start**
|
||||
>
|
||||
> **Read it here:** https://community.turnsys.com/t/296
|
||||
>
|
||||
> *Migrated 2026-08-06. This file is kept as a pointer for git-browsing context.
|
||||
> Do not update content here — edit the Discourse wiki topic instead.*
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# STATUS.md
|
||||
|
||||
> **Documentation moved to Discourse — the canonical source of truth.**
|
||||
>
|
||||
> **Ticket index + infrastructure summary**
|
||||
>
|
||||
> **Read it here:** https://community.turnsys.com/t/297
|
||||
>
|
||||
> *Migrated 2026-08-06. This file is kept as a pointer for git-browsing context.
|
||||
> Do not update content here — edit the Discourse wiki topic instead.*
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
# WORKING.md — Active Session Tracker
|
||||
|
||||
Agent work only. The human decides when it's done.
|
||||
A commit is blocked while any task below remains unchecked.
|
||||
|
||||
## Current Tasks
|
||||
|
||||
(all done — session complete)
|
||||
|
||||
- [x] Add ticket-gate Crush hook (blocks work without active ticket)
|
||||
- [x] Document active-ticket workflow in AGENTS.md + meta template
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/bash
|
||||
# access-matrix.sh — definitive access verification across all Linux Tailscale nodes.
|
||||
# Uses the correct SSH user(s) per system type, checks sudo where applicable.
|
||||
# Routes through remote.sh (the only allowed ssh path).
|
||||
set -u
|
||||
cd /home/reachableceo/projects/PFVCluster || exit 1
|
||||
|
||||
# Policy-excluded systems (never attempt access)
|
||||
EXCLUDE=':tsys-cloudron:pfv-bms:tsys-umbrel:tsys-ucs-01:tsys-ucs-02:stlpc-bizoffice:ultix-highside:'
|
||||
|
||||
# Determine the SSH user(s) for a given hostname and whether sudo is expected.
|
||||
# Returns "user1:user2:...:sudoflag" where sudoflag is "yes" or "no".
|
||||
users_for() {
|
||||
local name="$1"
|
||||
case "$name" in
|
||||
pfv-tsys[0-9]) echo "root:no" ;;
|
||||
*-proxmox-datacenter) echo "root:no" ;;
|
||||
*-proxmox-pve) echo "root:no" ;;
|
||||
*-proxmox-pbs) echo "root:no" ;;
|
||||
*-proxmox-mailgw*) echo "root:no" ;;
|
||||
*-proxmox-backup*) echo "root:no" ;;
|
||||
tsys-ucs-*) echo "root:no" ;;
|
||||
ultix-streaming) echo "root:no" ;;
|
||||
stlpc-*) echo "root:labuser:no" ;;
|
||||
ultix-field) echo "ultixfield:yes" ;;
|
||||
subopi*) echo "subodev:yes" ;;
|
||||
*) echo "localuser:yes" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_user() {
|
||||
local ip="$1" user="$2" expect_sudo="$3"
|
||||
local out sudo
|
||||
out=$(VM_IP="$ip" VM_USER="$user" bash tests/remote.sh vm 'echo SSHOK; id -un' </dev/null 2>&1 | grep -oE 'SSHOK|keyboard-interactive|Connection refused' | head -1)
|
||||
case "$out" in
|
||||
SSHOK)
|
||||
if [ "$expect_sudo" = "yes" ]; then
|
||||
sudo=$(VM_IP="$ip" VM_USER="$user" bash tests/remote.sh vm 'sudo -n true 2>/dev/null && echo SUDOOK || echo SUDONO' </dev/null 2>&1 | grep -oE 'SUDOOK|SUDONO' | head -1)
|
||||
printf '%s(%s)' "$user" "${sudo:-?}"
|
||||
else
|
||||
printf '%s(ok)' "$user"
|
||||
fi
|
||||
;;
|
||||
keyboard-interactive) printf '%s(2FA)' "$user" ;;
|
||||
'Connection refused') printf '%s(NOSSH)' "$user" ;;
|
||||
*) printf '%s(NOKEY)' "$user" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
printf '%-32s %-16s %s\n' "NAME" "TS-IP" "ACCESS"
|
||||
printf '%-32s %-16s %s\n' "----" "-----" "------"
|
||||
|
||||
tailscale status 2>/dev/null | awk '$4=="linux" {print $2, $1}' | sort | while read -r name ip; do
|
||||
[ -n "$name" ] || continue
|
||||
case "$EXCLUDE" in *":$name:"*) printf '%-32s %-16s %s\n' "$name" "$ip" "EXCLUDED"; continue;; esac
|
||||
|
||||
map=$(users_for "$name")
|
||||
expect_sudo="${map##*:}"
|
||||
users="${map%:*}"
|
||||
result=""
|
||||
IFS=':' read -ra user_list <<< "$users"
|
||||
for u in "${user_list[@]}"; do
|
||||
r=$(check_user "$ip" "$u" "$expect_sudo")
|
||||
[ -z "$result" ] && result="$r" || result="$result $r"
|
||||
done
|
||||
printf '%-32s %-16s %s\n' "$name" "$ip" "$result"
|
||||
done
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
# agent-bootstrap.sh
|
||||
#
|
||||
# Run INSIDE a guest (via SSH, console, or guest-agent) to bring the
|
||||
# system fully under agent management in one shot:
|
||||
# 1. install + enable qemu-guest-agent (VMs only, skipped on bare metal)
|
||||
# 2. push the agent SSH key to root + AGENT_USER (+ labuser if present)
|
||||
# 3. grant AGENT_USER passwordless sudo
|
||||
#
|
||||
# AGENT_USER defaults to "localuser". Override for systems with a different
|
||||
# unprivileged agent user:
|
||||
# AGENT_USER=subodev bash agent-bootstrap.sh
|
||||
#
|
||||
# After this runs once, the agent has SSH+sudo immediately.
|
||||
#
|
||||
# Usage (from a root shell in the guest):
|
||||
# bash agent-bootstrap.sh
|
||||
# AGENT_USER=subodev bash agent-bootstrap.sh
|
||||
|
||||
set -eu
|
||||
|
||||
KEY='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIWms/uCXnjjo4KyxHBcYI2TDHe8OZ2wle6W/0hSRQLu reachableceo@ultix-streaming'
|
||||
AGENT_USER="${AGENT_USER:-localuser}"
|
||||
|
||||
# 1. guest-agent (skip on bare metal — no virtio-serial device)
|
||||
if command -v systemd-detect-virt >/dev/null 2>&1 && \
|
||||
[ "$(systemd-detect-virt --vm 2>/dev/null || echo none)" != "none" ]; then
|
||||
if ! command -v qemu-ga >/dev/null 2>&1; then
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y qemu-guest-agent
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
dnf install -y qemu-guest-agent
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
yum install -y qemu-guest-agent
|
||||
else
|
||||
echo "WARN: no supported package manager; skipping agent install" >&2
|
||||
fi
|
||||
fi
|
||||
systemctl enable --now qemu-guest-agent 2>/dev/null || \
|
||||
systemctl enable --now qemu-ga 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 2. SSH key for root + AGENT_USER + labuser (if present)
|
||||
for u in root "$AGENT_USER" labuser; do
|
||||
if ! getent passwd "$u" >/dev/null 2>&1; then continue; fi
|
||||
H=$(getent passwd "$u" | cut -d: -f6)
|
||||
mkdir -p "$H/.ssh"; chmod 700 "$H/.ssh"
|
||||
AK="$H/.ssh/authorized_keys"; touch "$AK"; chmod 600 "$AK"
|
||||
grep -qF "$KEY" "$AK" || echo "$KEY" >> "$AK"
|
||||
chown -R "$u": "$H/.ssh"
|
||||
done
|
||||
|
||||
# 3. passwordless sudo for AGENT_USER only
|
||||
if getent passwd "$AGENT_USER" >/dev/null 2>&1 && [ -d /etc/sudoers.d ]; then
|
||||
echo "${AGENT_USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/010-agent
|
||||
chmod 440 /etc/sudoers.d/010-agent
|
||||
fi
|
||||
|
||||
echo BOOTSTRAP-DONE
|
||||
@@ -0,0 +1,23 @@
|
||||
# PFV NFS tuning sysctl overrides
|
||||
#
|
||||
# Applied AFTER tuned via pfv-nfs-tuning.service (systemd oneshot).
|
||||
# These override tuned's network-throughput/virtual-host 16MB TCP buffer
|
||||
# caps with 128MB for high-BDP NFS over 1-4 GbE LACP links.
|
||||
#
|
||||
# Install on ALL Proxmox hosts:
|
||||
# cp 99-pfv-nfs.conf /etc/sysctl.d/99-pfv-nfs.conf
|
||||
# cp pfv-nfs-tuning.service /etc/systemd/system/pfv-nfs-tuning.service
|
||||
# systemctl daemon-reload && systemctl enable --now pfv-nfs-tuning.service
|
||||
#
|
||||
# Created: 2026-07-31
|
||||
# Deployed: tsys1, tsys3, tsys4, tsys5, tsys6, tsys7, tsys9
|
||||
|
||||
net.core.rmem_max = 134217728
|
||||
net.core.wmem_max = 134217728
|
||||
net.core.rmem_default = 26214400
|
||||
net.core.wmem_default = 26214400
|
||||
net.core.netdev_max_backlog = 250000
|
||||
net.core.somaxconn = 65535
|
||||
net.ipv4.tcp_rmem = 4096 87380 134217728
|
||||
net.ipv4.tcp_wmem = 4096 65536 134217728
|
||||
net.ipv4.tcp_max_syn_backlog = 4096
|
||||
@@ -0,0 +1,28 @@
|
||||
# PFV NFS tuning service
|
||||
#
|
||||
# Systemd oneshot that runs AFTER tuned.service to apply TCP buffer
|
||||
# overrides. The tuned daemon's profiles (network-throughput for storage
|
||||
# hosts, virtual-host for compute hosts) set 16MB TCP buffer caps which
|
||||
# are too small for high-BDP NFS over LACP links. This service force-
|
||||
# applies 128MB buffers after tuned has finished its configuration.
|
||||
#
|
||||
# Install:
|
||||
# cp pfv-nfs-tuning.service /etc/systemd/system/pfv-nfs-tuning.service
|
||||
# systemctl daemon-reload
|
||||
# systemctl enable --now pfv-nfs-tuning.service
|
||||
#
|
||||
# Created: 2026-07-31
|
||||
# Deployed: all 7 Proxmox hosts (tsys1/3/4/5/6/7/9)
|
||||
|
||||
[Unit]
|
||||
Description=PFV NFS tuning (override tuned TCP buffer caps)
|
||||
After=tuned.service
|
||||
Requires=tuned.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/sysctl -p /etc/sysctl.d/99-pfv-nfs.conf
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -5,17 +5,18 @@
|
||||
#magic to detect main int
|
||||
echo "Determining management interface..."
|
||||
#export MAIN_INT=$(brctl show $(netstat -rn|grep 0.0.0.0|head -n1|awk '{print $NF}') | awk '{print $NF}'|tail -1|awk -F '.' '{print $1}')
|
||||
export MAIN_INT=$(brctl show|grep vmbr0|awk '{print $NF}'|awk -F '.' '{print $1}')
|
||||
MAIN_INT=$(brctl show|grep vmbr0|awk '{print $NF}'|awk -F '.' '{print $1}')
|
||||
export MAIN_INT
|
||||
|
||||
echo "Management interface is: $MAIN_INT"
|
||||
|
||||
#fix the issue
|
||||
echo "Fixing management interface..."
|
||||
ethtool -K $MAIN_INT tso off
|
||||
ethtool -K $MAIN_INT gro off
|
||||
ethtool -K $MAIN_INT gso off
|
||||
ethtool -K $MAIN_INT tx off
|
||||
ethtool -K $MAIN_INT rx off
|
||||
ethtool -K "$MAIN_INT" tso off
|
||||
ethtool -K "$MAIN_INT" gro off
|
||||
ethtool -K "$MAIN_INT" gso off
|
||||
ethtool -K "$MAIN_INT" tx off
|
||||
ethtool -K "$MAIN_INT" rx off
|
||||
|
||||
#https://forum.proxmox.com/threads/e1000-driver-hang.58284/
|
||||
#https://serverfault.com/questions/616485/e1000e-reset-adapter-unexpectedly-detected-hardware-unit-hang
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# auth-cloudron-ldap.sh — placeholder module (Cloudron LDAP auth integration).
|
||||
# Intentionally empty; populated when the auth stack is deployed.
|
||||
true
|
||||
+1
-1
@@ -12,7 +12,7 @@ export KNELShellFrameworkRoot
|
||||
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
|
||||
|
||||
export AGENTS_PATH
|
||||
AGENTS_PATH="$PROJECT_ROOT_PATH/ProjectCode/Agents"
|
||||
AGENTS_PATH="$PROJECT_ROOT_PATH/provisioning/Agents"
|
||||
|
||||
source "$KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars"
|
||||
|
||||
+13
-12
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC2103 # legacy R&D build script; cd/cd- sequence is intentional
|
||||
|
||||
#Made from instructions at https://www.tunetheweb.com/performance/http2/
|
||||
|
||||
@@ -24,17 +25,17 @@ CURL_FILE="curl-7.60.0.tar.gz"
|
||||
#Download and install latest version of openssl
|
||||
wget $OPENSSL_URL_BASE/$OPENSSL_FILE
|
||||
tar xzf $OPENSSL_FILE
|
||||
cd openssl-1.1.0h
|
||||
cd openssl-1.1.0h || exit
|
||||
./config enable-weak-ssl-ciphers shared zlib-dynamic -DOPENSSL_TLS_SECURITY_LEVEL=0 --prefix=/usr/local/custom-ssl/openssl-1.1.0h ; make ; make install
|
||||
ln -s /usr/local/custom-ssl/openssl-1.1.0h /usr/local/openssl
|
||||
cd -
|
||||
cd - || exit
|
||||
|
||||
#Download and install nghttp2 (needed for mod_http2).
|
||||
wget $NGHTTP_URL_BASE/$NGHTTP_FILE
|
||||
tar xzf $NGHTTP_FILE
|
||||
cd nghttp2-1.31.0
|
||||
cd nghttp2-1.31.0 || exit
|
||||
./configure --prefix=/usr/local/custom-ssl/nghttp ; make ; make install
|
||||
cd -
|
||||
cd - || exit
|
||||
|
||||
#Updated ldconfig so curl build
|
||||
|
||||
@@ -48,34 +49,34 @@ ldconfig
|
||||
#Download and install curl
|
||||
wget $CURL_URL_BASE/$CURL_FILE
|
||||
tar xzf curl-7.60.0.tar.gz
|
||||
cd curl-7.60.0
|
||||
cd curl-7.60.0 || exit
|
||||
./configure --prefix=/usr/local/custom-ssl/curl --with-nghttp2=/usr/local/custom-ssl/nghttp/ --with-ssl=/usr/local/custom-ssl/openssl-1.1.0h/ ; make ; make install
|
||||
cd -
|
||||
cd - || exit
|
||||
|
||||
|
||||
#Download and install latest apr
|
||||
wget $APR_URL_BASE/$APR_FILE
|
||||
tar xzf $APR_FILE
|
||||
cd apr-1.6.3
|
||||
cd apr-1.6.3 || exit
|
||||
./configure --prefix=/usr/local/custom-ssl/apr ; make ; make install
|
||||
cd -
|
||||
cd - || exit
|
||||
|
||||
#Download and install latest apr-util
|
||||
wget $APR_UTIL_URL_BASE/$APR_UTIL_FILE
|
||||
tar xzf apr-util-1.6.1.tar.gz
|
||||
cd apr-util-1.6.1
|
||||
cd apr-util-1.6.1 || exit
|
||||
./configure --prefix=/usr/local/custom-ssl/apr-util --with-apr=/usr/local/custom-ssl/apr ; make; make install
|
||||
cd -
|
||||
cd - || exit
|
||||
|
||||
#Download and install apache
|
||||
wget $APACHE_URL_BASE/$APACHE_FILE
|
||||
tar xzf httpd-2.4.33.tar.gz
|
||||
cd httpd-2.4.33
|
||||
cd httpd-2.4.33 || exit
|
||||
cp -r ../apr-1.6.3 srclib/apr
|
||||
cp -r ../apr-util-1.6.1 srclib/apr-util
|
||||
./configure --prefix=/usr/local/custom-ssl/apache --with-ssl=/usr/local/custom-ssl/openssl-1.1.0h/ --with-pcre=/usr/bin/pcre-config --enable-unique-id --enable-ssl --enable-so --with-included-apr --enable-http2 --with-nghttp2=/usr/local/custom-ssl/nghttp/
|
||||
make
|
||||
make install
|
||||
ln -s /usr/local/custom-ssl/apache /usr/local/apache
|
||||
cd -
|
||||
cd - || exit
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ export KNELShellFrameworkRoot
|
||||
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
|
||||
|
||||
export CONFIGFILES_PATH
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/ProjectCode/ConfigFiles"
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/provisioning/ConfigFiles"
|
||||
|
||||
source "$KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ export KNELShellFrameworkRoot
|
||||
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
|
||||
|
||||
export CONFIGFILES_PATH
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/ProjectCode/ConfigFiles"
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/provisioning/ConfigFiles"
|
||||
|
||||
source "$KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars"
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ export KNELShellFrameworkRoot
|
||||
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
|
||||
|
||||
export CONFIGFILES_PATH
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/ProjectCode/ConfigFiles"
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/provisioning/ConfigFiles"
|
||||
|
||||
source "$KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars"
|
||||
|
||||
@@ -79,7 +79,7 @@ if [ "$SUBODEV_CHECK" = 1 ]; then
|
||||
fi
|
||||
|
||||
export DEV_WORKSTATION_CHECK
|
||||
DEV_WORKSTATION_CHECK="$(hostname | egrep -c 'subopi-dev|CharlesDevServer' || true)"
|
||||
DEV_WORKSTATION_CHECK="$(hostname | grep -Ec 'subopi-dev|CharlesDevServer' || true)"
|
||||
|
||||
if [ "$DEV_WORKSTATION_CHECK" -eq 0 ]; then
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export user_check
|
||||
user_check="$(echo "$curr_user" | grep -c root)"
|
||||
|
||||
|
||||
if [ $user_check -ne 1 ]; then
|
||||
if [ "$user_check" -ne 1 ]; then
|
||||
print_error "Must run as root."
|
||||
error_out
|
||||
fi
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
# shellcheck shell=bash disable=SC2148 # sourced function file (no shebang by design)
|
||||
function pi-detect()
|
||||
{
|
||||
print_info Now running "$FUNCNAME"....
|
||||
print_info Now running "${FUNCNAME[0]}"....
|
||||
if [ -f /sys/firmware/devicetree/base/model ] ; then
|
||||
export IS_RASPI="1"
|
||||
fi
|
||||
@@ -9,5 +9,5 @@ fi
|
||||
if [ ! -f /sys/firmware/devicetree/base/model ] ; then
|
||||
export IS_RASPI="0"
|
||||
fi
|
||||
print_info Completed running "$FUNCNAME"
|
||||
print_info Completed running "${FUNCNAME[0]}"
|
||||
}
|
||||
@@ -17,13 +17,13 @@ export KNELShellFrameworkRoot
|
||||
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
|
||||
|
||||
export CONFIGFILES_PATH
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/ProjectCode/ConfigFiles"
|
||||
CONFIGFILES_PATH="$PROJECT_ROOT_PATH/provisioning/ConfigFiles"
|
||||
|
||||
export MODULES_PATH
|
||||
MODULES_PATH="$PROJECT_ROOT_PATH/ProjectCode/Modules"
|
||||
MODULES_PATH="$PROJECT_ROOT_PATH/provisioning/Modules"
|
||||
|
||||
export SCRIPTS_PATH
|
||||
SCRIPTS_PATH="$PROJECT_ROOT_PATH/ProjectCode/scripts"
|
||||
SCRIPTS_PATH="$PROJECT_ROOT_PATH/provisioning/scripts"
|
||||
|
||||
source "$KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars"
|
||||
|
||||
@@ -60,18 +60,18 @@ LOCALUSER_CHECK="$(getent passwd | grep -c localuser || true)"
|
||||
#######################
|
||||
|
||||
function global-oam() {
|
||||
print_info "Now running $FUNCNAME...."
|
||||
print_info "Now running ${FUNCNAME[0]}...."
|
||||
|
||||
cat "$SCRIPTS_PATH/up2date.sh" >/usr/local/bin/up2date.sh && chmod +x /usr/local/bin/up2date.sh
|
||||
|
||||
bash "$MODULES_PATH/OAM/oam-librenms.sh"
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
|
||||
}
|
||||
|
||||
function global-systemServiceConfigurationFiles() {
|
||||
print_info "Now running $FUNCNAME...."
|
||||
print_info "Now running ${FUNCNAME[0]}...."
|
||||
|
||||
cat "$CONFIGFILES_PATH/ZSH/tsys-zshrc" >/etc/zshrc
|
||||
cat "$CONFIGFILES_PATH/SMTP/aliases" >/etc/aliases
|
||||
@@ -79,11 +79,11 @@ function global-systemServiceConfigurationFiles() {
|
||||
|
||||
newaliases
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function global-installPackages() {
|
||||
print_info "Now running $FUNCNAME...."
|
||||
print_info "Now running ${FUNCNAME[0]}...."
|
||||
|
||||
# Setup webmin repo, used for RBAC/2fa PAM
|
||||
|
||||
@@ -195,7 +195,7 @@ function global-installPackages() {
|
||||
VIRT_TYPE="$(virt-what)"
|
||||
|
||||
export IS_VIRT_GUEST
|
||||
IS_VIRT_GUEST="$(echo "$VIRT_TYPE" | egrep -c 'hyperv|kvm' || true)"
|
||||
IS_VIRT_GUEST="$(echo "$VIRT_TYPE" | grep -Ec 'hyperv|kvm' || true)"
|
||||
|
||||
export IS_KVM_GUEST
|
||||
IS_KVM_GUEST="$(echo "$VIRT_TYPE" | grep -c 'kvm' || true)"
|
||||
@@ -227,12 +227,12 @@ function global-installPackages() {
|
||||
|
||||
# vault cli
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function global-postPackageConfiguration() {
|
||||
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
|
||||
systemctl --now enable auditd
|
||||
|
||||
@@ -253,7 +253,7 @@ function global-postPackageConfiguration() {
|
||||
#This is under test/dev and may fail
|
||||
echo "hi from root to root" | mail -s "hi directly to root from $(hostname)" root
|
||||
|
||||
chsh -s $(which zsh) root
|
||||
chsh -s "$(which zsh)" root
|
||||
|
||||
if [ "$LOCALUSER_CHECK" -gt 0 ]; then
|
||||
chsh -s "$(which zsh)" localuser
|
||||
@@ -312,7 +312,7 @@ function global-postPackageConfiguration() {
|
||||
fi
|
||||
|
||||
export NTP_SERVER_CHECK
|
||||
NTP_SERVER_CHECK="$(hostname | egrep -c 'pfv-netboot|pfvsvrpi|pfv-netinfra' || true)"
|
||||
NTP_SERVER_CHECK="$(hostname | grep -Ec 'pfv-netboot|pfvsvrpi|pfv-netinfra' || true)"
|
||||
|
||||
if [ "$NTP_SERVER_CHECK" -eq 0 ]; then
|
||||
|
||||
@@ -341,7 +341,7 @@ function global-postPackageConfiguration() {
|
||||
tuned-adm profile virtual-guest
|
||||
fi
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
@@ -355,41 +355,41 @@ function global-postPackageConfiguration() {
|
||||
# SSH
|
||||
|
||||
function secharden-ssh() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
|
||||
bash "$MODULES_PATH/Security/secharden-ssh.sh"
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-wazuh() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-wazuh.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-2fa() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-2fa.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-scap-stig() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-scap-stig.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-agents() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-audit-agents.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-auto-upgrades() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
#curl --silent ${DL_ROOT}/Modules/Security/secharden-ssh.sh|$(which bash)
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
|
||||
@@ -400,16 +400,16 @@ function secharden-auto-upgrades() {
|
||||
####################################################################################################
|
||||
|
||||
function auth-cloudron-ldap() {
|
||||
print_info "Now running "$FUNCNAME""
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
#curl --silent ${DL_ROOT}/Modules/Auth/auth-cloudron-ldap.sh|$(which bash)
|
||||
print_info "Completed running "$FUNCNAME""
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
# RUn the various functions in the correct order
|
||||
####################################################################################################
|
||||
|
||||
echo >$LOGFILENAME
|
||||
echo >"$LOGFILENAME"
|
||||
|
||||
print_info "Execution starting at $CURRENT_TIMESTAMP..."
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user