Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
efb3cfe
feat: Add installation templates system for common development stacks
aliraza556 Nov 18, 2025
5f2dff3
fix: Address security and installation issues in template system
aliraza556 Nov 19, 2025
ea9c9fa
fix: Security and installation fixes for template system
aliraza556 Nov 19, 2025
bfaa85b
feat: Add installation templates system for common development stacks
aliraza556 Nov 19, 2025
a9e1b58
Merge remote-tracking branch 'origin' into feat/installation-templates
aliraza556 Nov 28, 2025
0698ae0
fix unit tests
aliraza556 Nov 28, 2025
89eef8d
git Merge remote-tracking branch 'origin' into feat/installation-temp…
aliraza556 Dec 11, 2025
f36f6f2
Merge remote-tracking branch 'origin' into feat/installation-templates
aliraza556 Dec 17, 2025
885b4e3
Merge remote-tracking branch 'origin' into feat/installation-templates
aliraza556 Dec 20, 2025
8eb269f
refomattrf files
aliraza556 Dec 20, 2025
176c17a
again refomattrf files
aliraza556 Dec 20, 2025
b0bc267
refomattrf files
aliraza556 Dec 20, 2025
50453df
again refomattrf files
aliraza556 Dec 20, 2025
9dfb1c9
Merge branch 'main' into feat/installation-templates
aliraza556 Dec 20, 2025
eea8f48
fix unit tests
aliraza556 Dec 20, 2025
c34534b
Merge remote-tracking branch 'origin' into feat/installation-templates
aliraza556 Dec 25, 2025
a13d092
refactor: rename template system to stack and add comprehensive help …
aliraza556 Dec 26, 2025
8837947
fix lint error
aliraza556 Dec 26, 2025
aa390a6
reformatted file
aliraza556 Dec 26, 2025
9638c33
rerun SonarQube Cloud service
aliraza556 Dec 26, 2025
d7f81b4
Merge remote-tracking branch 'origin' into feat/installation-templates
aliraza556 Jan 6, 2026
9461220
fix(templates): add sudo prefix and fix import validation for PR #201
aliraza556 Jan 6, 2026
73cf8d7
Merge branch 'main' into feat/installation-templates
aliraza556 Jan 6, 2026
3502553
fix(cli): remove non-existent user_preferences import blocking tests
aliraza556 Jan 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
778 changes: 707 additions & 71 deletions cortex/cli.py

Large diffs are not rendered by default.

605 changes: 605 additions & 0 deletions cortex/templates.py

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions cortex/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Installation Templates

This directory contains built-in installation templates for common development stacks.

## Available Templates

- **lamp.yaml** - LAMP Stack (Linux, Apache, MySQL, PHP)
- **mean.yaml** - MEAN Stack (MongoDB, Express.js, Angular, Node.js)
- **mern.yaml** - MERN Stack (MongoDB, Express.js, React, Node.js)
- **ml-ai.yaml** - Machine Learning / AI Stack
- **devops.yaml** - DevOps Stack (Docker, Kubernetes, Terraform, etc.)

## Usage

```bash
# List all templates
cortex template list

# Install from template
cortex install --template lamp --execute

# Create custom template
cortex template create my-stack

# Import template
cortex template import my-template.yaml

# Export template
cortex template export lamp my-lamp.yaml
```

## Template Format

Templates are defined in YAML format with the following structure:

```yaml
name: Template Name
description: Template description
version: 1.0.0
author: Author Name (optional)

packages:
- package1
- package2

steps:
- command: apt update
description: Update packages
requires_root: true
rollback: (optional)

hardware_requirements:
min_ram_mb: 2048
min_cores: 2
min_storage_mb: 10240

post_install:
- echo "Installation complete"

verification_commands:
- package --version
```

See [TEMPLATES.md](../../docs/TEMPLATES.md) for complete documentation.

93 changes: 93 additions & 0 deletions cortex/templates/devops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: DevOps Stack
description: Complete DevOps toolchain with Docker, Kubernetes, Terraform, Ansible, and CI/CD tools
version: 1.0.0
author: Cortex Linux
packages:
- docker.io
- docker-compose
- kubectl
- git
- curl
- wget
- ansible
- terraform
- jenkins
- gitlab-runner

steps:
- command: apt update
description: Update package lists
requires_root: true
- command: apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
description: Install prerequisites for Docker
requires_root: true
- command: install -m 0755 -d /etc/apt/keyrings
description: Create keyrings directory
requires_root: true
- command: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
description: Add Docker GPG key
requires_root: true
- command: chmod a+r /etc/apt/keyrings/docker.gpg
description: Set key permissions
requires_root: true
- command: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
description: Add Docker repository
requires_root: true
- command: apt update
description: Update package lists with Docker repo
requires_root: true
- command: apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
description: Install Docker
requires_root: true
- command: systemctl start docker
description: Start Docker service
requires_root: true
rollback: systemctl stop docker
- command: systemctl enable docker
description: Enable Docker on boot
requires_root: true
rollback: systemctl disable docker
- command: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
description: Download kubectl
requires_root: false
- command: install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
description: Install kubectl
requires_root: true
- command: rm kubectl
description: Clean up kubectl download
requires_root: false
- command: apt install -y ansible terraform git
description: Install Ansible, Terraform, and Git
requires_root: true

hardware_requirements:
min_ram_mb: 4096
min_cores: 4
min_storage_mb: 20480

post_install:
- echo "DevOps stack installed successfully"
- echo "Docker version: $(docker --version)"
- echo "Kubernetes: $(kubectl version --client --short 2>/dev/null || echo 'installed')"
- echo "Terraform: $(terraform --version | head -n1)"
- echo "Ansible: $(ansible --version | head -n1)"

verification_commands:
- docker --version
- docker ps
- kubectl version --client
- terraform --version
- ansible --version
- git --version
- systemctl is-active docker

metadata:
category: devops
tags:
- docker
- kubernetes
- terraform
- ansible
- ci-cd
- infrastructure

77 changes: 77 additions & 0 deletions cortex/templates/lamp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: LAMP Stack
description: Linux, Apache, MySQL, PHP stack for web development
version: 1.0.0
author: Cortex Linux
packages:
- apache2
- mysql-server
- mysql-client
- php
- php-mysql
- php-mbstring
- php-xml
- php-curl
- phpmyadmin
- libapache2-mod-php

steps:
- command: apt update
description: Update package lists
requires_root: true
- command: echo "mysql-server mysql-server/root_password password temp_password" | debconf-set-selections && echo "mysql-server mysql-server/root_password_again password temp_password" | debconf-set-selections
description: Pre-configure MySQL root password
requires_root: true
- command: DEBIAN_FRONTEND=noninteractive apt install -y apache2 mysql-server mysql-client php php-mysql php-mbstring php-xml php-curl libapache2-mod-php
description: Install LAMP stack packages
requires_root: true
- command: echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections && echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections && DEBIAN_FRONTEND=noninteractive apt install -y phpmyadmin
description: Install and configure phpMyAdmin for Apache
requires_root: true
- command: ln -sf /usr/share/phpmyadmin /var/www/html/phpmyadmin
description: Create phpMyAdmin symlink
requires_root: true
- command: systemctl start apache2
description: Start Apache web server
requires_root: true
rollback: systemctl stop apache2
- command: systemctl enable apache2
description: Enable Apache on boot
requires_root: true
rollback: systemctl disable apache2
- command: systemctl start mysql
description: Start MySQL service
requires_root: true
rollback: systemctl stop mysql
- command: systemctl enable mysql
description: Enable MySQL on boot
requires_root: true
rollback: systemctl disable mysql

hardware_requirements:
min_ram_mb: 1024
min_cores: 2
min_storage_mb: 5120

post_install:
- echo "LAMP stack installed successfully"
- echo "SECURITY: Run 'mysql_secure_installation' to secure MySQL"
- echo "SECURITY: Configure firewall rules for production use"
- echo "Apache: http://localhost"
- echo "phpMyAdmin: http://localhost/phpmyadmin"
- echo "SECURITY: Change default MySQL passwords before production use"

verification_commands:
- apache2 -v
- mysql --version
- php -v
- systemctl is-active apache2
- systemctl is-active mysql

metadata:
category: web-development
tags:
- web
- server
- database
- php

73 changes: 73 additions & 0 deletions cortex/templates/mean.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: MEAN Stack
description: MongoDB, Express.js, Angular, Node.js stack for modern web applications
version: 1.0.0
author: Cortex Linux
packages:
- nodejs
- npm
- mongodb
- git
- curl

steps:
- command: apt update
description: Update package lists
requires_root: true
- command: curl -fsSL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh && bash /tmp/nodesource_setup.sh && rm /tmp/nodesource_setup.sh
description: Download and add Node.js repository
requires_root: true
- command: apt install -y nodejs
description: Install Node.js
requires_root: true
- command: npm install -g @angular/cli express-generator
description: Install Angular CLI and Express generator globally
requires_root: true
- command: curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
description: Import MongoDB GPG key
requires_root: true
- command: echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list
description: Add MongoDB official apt repository
requires_root: true
- command: apt update
description: Update package lists
requires_root: true
- command: apt install -y mongodb-org
description: Install MongoDB from official repository
requires_root: true
- command: systemctl start mongod
description: Start MongoDB service
requires_root: true
rollback: systemctl stop mongod
- command: systemctl enable mongod
description: Enable MongoDB on boot
requires_root: true
rollback: systemctl disable mongod

hardware_requirements:
min_ram_mb: 2048
min_cores: 2
min_storage_mb: 10240

post_install:
- echo "MEAN stack installed successfully"
- echo "Node.js version: $(node --version)"
- echo "npm version: $(npm --version)"
- echo "Angular CLI: $(ng version 2>/dev/null || echo 'installed')"
- echo "MongoDB: mongodb://localhost:27017"

verification_commands:
- node --version
- npm --version
- mongosh --version || mongo --version
- systemctl is-active mongod
- ng version

metadata:
category: web-development
tags:
- javascript
- nodejs
- mongodb
- angular
- express

73 changes: 73 additions & 0 deletions cortex/templates/mern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: MERN Stack
description: MongoDB, Express.js, React, Node.js stack for full-stack JavaScript development
version: 1.0.0
author: Cortex Linux
packages:
- nodejs
- npm
- mongodb
- git
- curl

steps:
- command: apt update
description: Update package lists
requires_root: true
- command: curl -fsSL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh && bash /tmp/nodesource_setup.sh && rm /tmp/nodesource_setup.sh
description: Download and add Node.js repository
requires_root: true
- command: apt install -y nodejs
description: Install Node.js
requires_root: true
- command: npm install -g create-react-app express-generator
description: Install React and Express generators globally
requires_root: true
- command: curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
description: Import MongoDB GPG key
requires_root: true
- command: echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list
description: Add MongoDB official apt repository
requires_root: true
- command: apt update
description: Update package lists
requires_root: true
- command: apt install -y mongodb-org
description: Install MongoDB from official repository
requires_root: true
- command: systemctl start mongod
description: Start MongoDB service
requires_root: true
rollback: systemctl stop mongod
- command: systemctl enable mongod
description: Enable MongoDB on boot
requires_root: true
rollback: systemctl disable mongod

hardware_requirements:
min_ram_mb: 2048
min_cores: 2
min_storage_mb: 10240

post_install:
- echo "MERN stack installed successfully"
- echo "Node.js version: $(node --version)"
- echo "npm version: $(npm --version)"
- echo "React: Create apps with 'npx create-react-app'"
- echo "MongoDB: mongodb://localhost:27017"

verification_commands:
- node --version
- npm --version
- mongosh --version || mongo --version
- systemctl is-active mongod
- npx create-react-app --version

metadata:
category: web-development
tags:
- javascript
- nodejs
- mongodb
- react
- express

Loading
Loading