# WP DevOps Dashboard
**Contributors:** tlloancy
**Tags:** ansible, docker, ssh, server-management, devops
**Requires at least:** 5.0
**Tested up to:** 7.0
**Requires PHP:** 8.2
**Stable tag:** 2.2.0
**License:** GPL-2.0+
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html

A WordPress DevOps dashboard: manage system packages, run Ansible playbooks, control Docker containers, and monitor your server — all via SSH.

## Description

WP DevOps Dashboard turns your WordPress admin into a full server orchestration panel. Connect once via SSH and get a live, React-powered interface to manage your Linux server without ever leaving the dashboard.

### Why WP DevOps Dashboard?

The key differentiator is its **forkable playbook catalog**. The plugin does not ship a fixed list of automation scripts — it pulls a live catalog from a GitHub repository you control. Fork the [Official Playbook Repository](https://github.com/elestranobaron/wp-package-installator-playbooks), add your own `manifest.json + info.json + main.yml` bundles, and the dashboard picks them up automatically on the next sync. No plugin code to touch. No pull requests to submit. Your infrastructure, your catalog.

### Key Features

* **Forkable Automation Catalog**: Point the plugin at any GitHub repository. The catalog format (`manifest.json` + per-service `info.json` + `main.yml`) is documented in the official repo. GitHub Actions auto-generates new entries. Fork once, own your automation library forever.
* **Ansible Orchestrator**: Run playbooks directly from WordPress with real-time log streaming via xterm.js. Long-running tasks execute in the background via `nohup` and stream output back as they run.
* **Multi-distro Package Manager**: Install and remove system packages on Debian, Ubuntu, Red Hat, Fedora, Arch Linux, and SUSE — `apt`, `yum`, `dnf`, `pacman`, and `zypper` are all supported.
* **Docker Integration**: List all containers, start, stop, and restart them securely from the dashboard.
* **Server Monitoring (Cockpit)**: Live CPU, RAM, and disk usage pulled in a single SSH round-trip via the unified REST endpoint (`/wp-json/wpkginst/v1/full-status`).
* **SSH Terminal**: A browser-based root command executor with password re-authentication gate and full command audit log.
* **Zero External Dependencies**: React 18, Axios, xterm.js, react-select, and phpseclib3 are all bundled. No Composer or npm required on the WordPress server.
* **Modern React UI**: Searchable tables, animated progress bars, live terminal output, and real-time SSH status indicator.

### Architecture Overview

```
GitHub Repo (your fork)
  └── manifest.json          ← catalog index (auto-generated by GitHub Actions)
  └── services/
        └── my-service/
              ├── info.json  ← display name, description, icon
              └── main.yml   ← Ansible playbook
```

The plugin clones the repository to the remote server via SSH, reads `manifest.json`, and builds the playbook list dynamically. Change the repository URL in SSH Settings to point at your own fork — no other configuration needed.

## Installation

1. Upload the plugin to `/wp-content/plugins/package-installator/` or install it directly via the WordPress plugin screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Navigate to **WP DevOps Dashboard > SSH Settings** and configure your SSH credentials (host, port, username, and either a private key or password).
4. Use the **Test Connection** button to verify SSH access.
5. Optionally, replace the default playbook repository URL with the URL of your own fork.

### File Permissions (if installing manually)

```bash
sudo chown -R www-data:www-data /var/www/html/wordpress/wp-content/plugins/package-installator
sudo chmod -R 755 /var/www/html/wordpress/wp-content/plugins/package-installator
```

## Dependencies

All runtime dependencies are bundled — React 18, Axios, xterm.js, react-select, and phpseclib3. No Composer or npm installation required.

## Frequently Asked Questions

### Which Linux distributions are supported?

Debian, Ubuntu, Red Hat, CentOS, Fedora, Arch Linux, and SUSE are all supported. The plugin detects the distribution and selects the correct package manager (`apt`, `yum`, `dnf`, `pacman`, or `zypper`) automatically.

### How do I use my own playbook catalog?

Fork the [Official Playbook Repository](https://github.com/elestranobaron/wp-package-installator-playbooks) and read its README for the full catalog format specification. Then go to **WP DevOps Dashboard > SSH Settings**, paste your fork's `.git` URL into the **GitHub Repository URL** field, and save. The plugin will clone your fork to the remote server and display your custom playbooks.

### Does Ansible need to be installed on the WordPress server?

No. Ansible runs on the **remote server** (the one you connect to via SSH), not on the server hosting WordPress. The WordPress server only needs PHP 8.2+ and outbound SSH access.

### Is it safe to use in production?

Read the security warnings section below carefully before deploying in any environment. The plugin executes privileged commands on a remote server. A compromised WordPress admin account means full server access. Follow all hardening steps and test on a staging environment first.

### What if a package is already installed?

The plugin queries the package manager for current status before taking any action. Already-installed packages are shown with a 100% progress indicator and an "Installed" status badge.

### Can I add packages beyond the default PHP extension list?

Yes. Edit the `$php_packages` array in `includes/ajax-handlers.php` to add any system package available in your distribution's repositories.

## Screenshots

1. **DevOps Dashboard**: Unified view showing server stats (CPU/RAM/disk), Docker containers, package status, and Ansible playbook catalog with real-time SSH status indicator.
2. **SSH Settings**: Configure SSH host, port, username, authentication type (private key or password), and playbook repository URL, with a live connection test button.

## Changelog

### 2.2.0 — May 28, 2026 — 15:30 UTC+2

* Plugin display name changed to "WP DevOps Dashboard". The WP.org slug (`package-installator`) is permanent and unchanged — only the visible name in the admin menu and plugin list is updated.
* SSH Settings page no longer blocks on load. The page previously made a live SSH connection before sending any HTML to the browser, causing a 5–7 second delay. The connection test is now async: the page renders instantly and tests the connection in the background after load.
* New: animated "Test Connection" button on the SSH Settings page with live status badge (green glow on success, red on failure). No page reload required.
* SSH Settings page redesigned: card-based layout with separate sections for SSH Credentials and Automation Catalog, consistent with the main dashboard aesthetic.
* Performance: the package status query (20 SSH checks) is now lazy-loaded. It only runs when the user opens the package accordion, not on every background poll. The 35-second polling cycle now only fetches server stats, Docker containers, and Ansible catalog.
* Performance: `wpkginst_get_automation_readiness()` (Ansible, Docker Compose, Git detection) result is now cached in a WordPress transient for 2 minutes. Subsequent dashboard loads within that window are instant. The cache is invalidated automatically when a tool is installed via the FIX button.
* The script and style enqueue function is now split: the settings page only loads CSS; the React app and all SSH readiness calls are restricted to the main dashboard page.
* Full English UI: all user-visible French strings in the React interface replaced with English (status labels, button text, placeholders, empty states, console messages).
* Dashboard polling reduced from 5 sequential SSH connections to 1. Stats, Docker container list, and Ansible catalog are now fetched in a single SSH exec via a sectioned mega-command. The automation catalog no longer performs a `git fetch` on every poll — git sync only happens when the user explicitly clicks "Sync Ansible Catalog".
* Removed the redundant `whoami` SSH call on each REST poll; SSH connection status is now derived from the stats command result.
* SSH status indicator shows a distinct yellow pulsing state with an explicit "Establishing SSH connection…" message during the initial load.

### 2.1.2 — April 2026

* Arch Linux and SUSE are now supported, bringing distribution coverage to approximately 99% of common Linux server environments.
* Package installation now uses `nohup` for background execution, consistent with the rest of the plugin.

### 2.1.0 — April 2026

* SSH "One-Shot" Engine: system metrics (CPU, RAM, disk, distro detection) are now collected in a single SSH session instead of multiple separate connections — significant performance improvement and reduced load on the remote server.
* REST API migration: replaced fragmented AJAX polling with a single centralized REST route (`/wp-json/wpkginst/v1/full-status`), reducing HTTP requests by approximately 80%.
* Double-nonce architecture: hybrid token system to isolate data read flows (REST) from privileged system actions (AJAX).
* Strengthened `permission_callback` enforcement on all REST and AJAX endpoints.
* React lifecycle refactor: simultaneous update of all UI components (Docker, Packages, Stats) for a latency-free experience, with removal of redundant `useEffect` calls.
* Improved error feedback on API connection loss or SSH authentication failure.

### 2.0.0 — April 2026

* Major milestone: transition from a simple package manager to a full DevOps orchestrator.
* New: Ansible core — run playbooks directly from the WordPress dashboard.
* New: Forkable automation catalog — point the plugin at any GitHub repository following the `manifest.json` spec.
* New: Background processing — long-running tasks execute via `nohup` over SSH.
* New: Real-time streaming — live log output for Ansible playbooks and package installations.
* Security hardening: stricter nonce validation and path sanitization throughout.
* Full rewrite of AJAX polling logic to handle high-concurrency background tasks.

### 1.4.0

* New: Cockpit dashboard with real-time system resource monitoring (CPU, RAM, disk).

### 1.3.0 — April 2026

* Security audit and refactoring co-authored with Gemini (Google AI).
* Hardened SQL queries and input sanitization.
* Docker integration: list, start, stop, and restart containers via SSH.

### 1.2.1 — March 2026

* PHP session is now opened only on the Terminal and Log pages via a conditional check in the `admin_init` hook.
* `session_write_close()` called systematically after every session usage.
* Terminal authentication persists correctly across page refreshes without blocking REST API or loopback requests.
* Fixed "Access denied — Session expired" error when running commands after a page refresh.
* Removed global session lock that caused Site Health failures (active PHP session + REST API timeout).

### 1.2.0 — March 2026

* Complete overhaul of PHP session management to resolve Site Health warnings (REST API timeout and active session detection).

### 1.1.0 — December 2025

* Full internationalization (i18n) support with French and English translations.
* Command history logging with dedicated database table.
* Non-interactive root command executor (SSH Terminal page).
* Improved session handling and security hardening.
* WordPress 6.9 compatibility.

### 1.0.0

* Initial release: React UI, SSH-based package management, support for Debian-based systems.
* Animated progress bars, expandable command output, and SSH status indicator.

## Upgrade Notice

### 2.2.0
Performance and UX release. No database changes. Safe to update directly.

### 2.0.0
Major architectural change. Back up your database before upgrading. SSH credentials and settings are preserved.

### 1.1.0
Major update with translations, command logging, and safer execution mode. Back up your database before upgrading.

### 1.0.0
Initial release. Configure SSH settings before managing packages. Ensure the SSH user has `sudo` privileges.

## Important Security Warnings

* This plugin executes **root-level commands** on a remote server via SSH from within WordPress.
* A single security breach — XSS exploit, stolen admin session, or compromised administrator account — could result in full server takeover.
* **Do NOT use in production without all of the following**:
  * HTTPS enforced site-wide
  * Two-factor authentication on all administrator accounts
  * IP restriction on the WordPress admin area
  * Regular backups (files and database)
* **Test on a staging environment first.**

## Future Plans

* Playbook editor: create and edit `main.yml` files directly from the WordPress UI without needing to push to GitHub.
* Multi-server support: manage multiple remote servers from a single dashboard, switchable via a server selector.
* SFTP file browser: browse and edit remote files from the dashboard without requiring a separate SSH key configuration.
* WP-CLI integration: run WP-CLI commands on the remote WordPress installation from the dashboard.

## Contact

For contributions or issues, contact Tlloancy at [tlloancy@deter-mi.net].
