start od deployment
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
## Quick context for AI coding agents
|
||||
|
||||
This repository contains simple Ansible playbooks and Nagios check scripts.
|
||||
Keep guidance tightly focused on discoverable patterns so contributors can be productive immediately.
|
||||
|
||||
Key files and layout
|
||||
- `site.yml` — the top-level Ansible play that applies the `pips` role to hosts.
|
||||
- `roles/pips/files/` — place for executable check scripts (e.g. `memory_usage.py`).
|
||||
- `roles/pips/tasks/main.yml` — role tasks (currently empty); add tasks here to deploy and configure scripts.
|
||||
- `roles/pips/vars/main.yml` — role-scoped variables (currently empty).
|
||||
- `README.md` — short Dutch summary: "Scripts voor nagios services".
|
||||
|
||||
Big-picture architecture
|
||||
- This repo is a small Ansible-based deployment of Nagios/NRPE checks. The pattern is:
|
||||
1. Author a script under `roles/pips/files/` (executable, Python3-friendly).
|
||||
2. Add Ansible tasks in `roles/pips/tasks/main.yml` to copy/install the script on target hosts and ensure runtime deps (e.g. `psutil`) are present.
|
||||
3. Configure Nagios/NRPE on the host to call the deployed script.
|
||||
|
||||
-Project-specific conventions
|
||||
- Keep scripts in `roles/pips/files/`. Scripts should include a shebang (for example, use `/usr/bin/env python3` on the first line) and be executable.
|
||||
- Use `roles/pips/tasks/main.yml` for deployment tasks; do not add ad-hoc tasks at the repo root.
|
||||
- Put per-role variables in `roles/pips/vars/main.yml`.
|
||||
|
||||
Dependencies & integration points
|
||||
- `roles/pips/files/memory_usage.py` imports `psutil`. Ensure `python3` and the `psutil` package are installed on target hosts (via distro package `python3-psutil` or `pip3 install psutil`).
|
||||
- Scripts are intended to be run by Nagios or NRPE; be mindful of expected stdout/exit codes for Nagios plugins (0 OK, 1 WARNING, 2 CRITICAL, 3 UNKNOWN).
|
||||
|
||||
Example actionable tasks (add to `roles/pips/tasks/main.yml`):
|
||||
|
||||
```yaml
|
||||
- name: Deploy memory_usage check
|
||||
copy:
|
||||
src: memory_usage.py
|
||||
dest: /usr/local/bin/memory_usage.py
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Ensure psutil is installed (Debian/Ubuntu)
|
||||
apt:
|
||||
name: python3-psutil
|
||||
state: present
|
||||
become: yes
|
||||
```
|
||||
|
||||
Debugging & developer workflows
|
||||
- Run the Ansible playbook locally against an inventory: `ansible-playbook -i <hosts> site.yml -u <user> --ask-become-pass`.
|
||||
- To test a script locally on a host, run `python3 roles/pips/files/memory_usage.py` (or copy it to the host and run it with the same python interpreter Nagios will use).
|
||||
- If adding or changing a script, ensure it's executable and returns Nagios-compatible exit codes and concise output.
|
||||
|
||||
What to avoid / common mistakes
|
||||
- Don’t add runtime installation tasks outside `roles/pips/tasks/main.yml` — keep role self-contained.
|
||||
- Don’t assume `psutil` exists on the host; document and/or install it in the role tasks.
|
||||
|
||||
When merging or extending
|
||||
- If a `.github/copilot-instructions.md` already exists, preserve any project-specific notes and only append or update sections that are stale.
|
||||
- Keep instructions concise (20–50 lines). Use exact filenames and short code snippets (as above) to illustrate patterns.
|
||||
|
||||
If anything is unclear about runtime expectations (NRPE config, target paths, or packaging), ask a human: indicate the host OS and desired plugin location and the agent will propose exact task snippets.
|
||||
|
||||
Files referenced while drafting these instructions: `README.md`, `site.yml`, `roles/pips/files/memory_usage.py`, `roles/pips/tasks/main.yml`, `roles/pips/vars/main.yml`.
|
||||
|
||||
Next step: I can merge this into the repo now. Tell me if you want different default install paths (e.g. `/usr/lib/nagios/plugins`) or an explicit `requirements.txt` for script dependencies.
|
||||
Reference in New Issue
Block a user