{
  "id": "7p3d4ltVk0ICrNbX",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automate Full DevOps Infrastructure Setup on Linux Server in Just 10 Seconds",
  "tags": [],
  "nodes": [
    {
      "id": "a0973093-3fba-485a-8100-ae3e54c9dc5f",
      "name": "Start DevOps Setup",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "83e1e3a0-ef2f-45d7-bf73-a37f430ca622",
      "name": "Configure Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        0
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "server_host",
              "value": "={{ $json.server_host || '192.168.1.100' }}"
            },
            {
              "name": "server_user",
              "value": "{{ $json.server_user || 'root' }}"
            },
            {
              "name": "server_password",
              "value": "{{ $json.server_password || 'your_password' }}"
            },
            {
              "name": "docker_version",
              "value": "{{ $json.docker_version || 'latest' }}"
            },
            {
              "name": "k8s_version",
              "value": "{{ $json.k8s_version || '1.28' }}"
            },
            {
              "name": "devops_user",
              "value": "{{ $json.devops_user || 'devops' }}"
            },
            {
              "name": "user_password",
              "value": "{{ $json.user_password || 'devops123' }}"
            },
            {
              "name": "cluster_name",
              "value": "{{ $json.cluster_name || 'devops-cluster' }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "8f11ab98-149b-4192-8345-b278532d12ab",
      "name": "System Preparation",
      "type": "n8n-nodes-base.ssh",
      "position": [
        660,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83d\ude80 DevOps Stack Setup - System Preparation\"\necho \"YOUR_AWS_SECRET_KEY_HERE==\"\n\n# Update system\napt update -y && apt upgrade -y\n\n# Install essential packages\napt install -y curl wget git vim nano build-essential software-properties-common \\\n    apt-transport-https ca-certificates gnupg lsb-release jq unzip tree htop \\\n    net-tools python3 python3-pip openssh-server ufw\n\n# Install Python packages for automation\npip3 install ansible boto3 kubernetes docker-compose\n\necho \"\u2705 System preparation completed!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "150157b9-6b02-4953-aa60-192f526d9f9a",
      "name": "Install Docker",
      "type": "n8n-nodes-base.ssh",
      "position": [
        880,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83d\udc33 Installing Docker & Docker Compose\"\necho \"====================================\"\n\n# Add Docker GPG key\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg\n\n# Add Docker repository\necho \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\" | tee /etc/apt/sources.list.d/docker.list > /dev/null\n\n# Install Docker\napt update && apt install -y docker-ce docker-ce-cli containerd.io\n\n# Install Docker Compose\ncurl -L \"https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose\nchmod +x /usr/local/bin/docker-compose\n\n# Start Docker service\nsystemctl start docker && systemctl enable docker\n\necho \"Docker version: $(docker --version)\"\necho \"Docker Compose version: $(docker-compose --version)\"\necho \"\u2705 Docker installation completed!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8e450cfb-3075-4d36-96bf-2a342e04dd87",
      "name": "Install Kubernetes",
      "type": "n8n-nodes-base.ssh",
      "position": [
        1100,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\u2638\ufe0f Installing Kubernetes (K3s)\"\necho \"==============================\"\n\n# Install K3s (lightweight Kubernetes)\ncurl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=\"v{{ $json.k8s_version }}.0+k3s1\" sh -\n\n# Install kubectl\ncurl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\"\ninstall -o root -g root -m 0755 kubectl /usr/local/bin/kubectl\n\n# Install Helm\ncurl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash\n\n# Install k9s (Kubernetes CLI management tool)\ncurl -sS https://webinstall.dev/k9s | bash\n\n# Wait for K3s to be ready\nsleep 30\n\necho \"Kubernetes version: $(kubectl version --client --short)\"\necho \"Helm version: $(helm version --short)\"\necho \"\u2705 Kubernetes installation completed!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8fccf05b-3eb2-401f-bbfb-96b3d1b9aa5f",
      "name": "Install Jenkins",
      "type": "n8n-nodes-base.ssh",
      "position": [
        1320,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83d\udd27 Installing Jenkins\"\necho \"====================\"\n\n# Add Jenkins repository\nwget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | apt-key add -\necho \"deb https://pkg.jenkins.io/debian-stable binary/\" | tee /etc/apt/sources.list.d/jenkins.list\n\n# Install Java (required for Jenkins)\napt update && apt install -y openjdk-11-jdk\n\n# Install Jenkins\napt install -y jenkins\n\n# Start Jenkins\nsystemctl start jenkins && systemctl enable jenkins\n\n# Install Jenkins plugins via CLI (optional)\nwget http://localhost:8080/jnlpJars/jenkins-cli.jar\n\n# Create Jenkins Docker integration\nusermod -aG docker jenkins\n\necho \"Jenkins installed! Access at: http://$(hostname -I | awk '{print $1}'):8080\"\necho \"Initial admin password: $(cat /var/YOUR_AWS_SECRET_KEY_HERE)\"\necho \"\u2705 Jenkins installation completed!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "668996d6-413b-4467-8ad0-600a5d3162cf",
      "name": "Install Monitoring",
      "type": "n8n-nodes-base.ssh",
      "position": [
        1540,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83d\udcca Installing Prometheus & Grafana\"\necho \"==================================\"\n\n# Create monitoring namespace\nkubectl create namespace monitoring\n\n# Add Prometheus Helm repository\nhelm repo add prometheus-community https://prometheus-community.github.io/helm-charts\nhelm repo add grafana https://grafana.github.io/helm-charts\nhelm repo update\n\n# Install Prometheus using Helm\nhelm install prometheus prometheus-community/kube-prometheus-stack \\\n    --namespace monitoring \\\n    --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \\\n    --set prometheus.prometheusSpec.retention=30d\n\n# Install Grafana using Helm\nhelm install grafana grafana/grafana \\\n    --namespace monitoring \\\n    --set persistence.enabled=true \\\n    --set persistence.size=10Gi \\\n    --set adminPassword=admin123\n\n# Expose services\nkubectl patch svc prometheus-kube-prometheus-prometheus -n monitoring -p '{\"spec\":{\"type\":\"NodePort\"}}'\nkubectl patch svc grafana -n monitoring -p '{\"spec\":{\"type\":\"NodePort\"}}'\n\necho \"Prometheus & Grafana installed!\"\necho \"Prometheus: http://$(hostname -I | awk '{print $1}'):$(kubectl get svc prometheus-kube-prometheus-prometheus -n monitoring -o jsonpath='{.spec.ports[0].nodePort}')\"\necho \"Grafana: http://$(hostname -I | awk '{print $1}'):$(kubectl get svc grafana -n monitoring -o jsonpath='{.spec.ports[0].nodePort}')\"\necho \"Grafana admin password: admin123\"\necho \"\u2705 Monitoring stack installation completed!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7d88a242-654b-4dee-8642-84366b4eacb9",
      "name": "Create DevOps User",
      "type": "n8n-nodes-base.ssh",
      "position": [
        1760,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83d\udc64 Creating DevOps User & Configuration\"\necho \"======================================\"\n\n# Create DevOps user\nuseradd -m -s /bin/bash {{ $json.devops_user }}\necho \"{{ $json.devops_user }}:{{ $json.user_password }}\" | chpasswd\n\n# Add to groups\nusermod -aG sudo,docker {{ $json.devops_user }}\n\n# Create directories\nsu - {{ $json.devops_user }} -c \"mkdir -p ~/projects/{docker-files,k8s-manifests,jenkins-pipelines,monitoring,scripts}\"\n\n# Copy kubeconfig\ncp /etc/rancher/k3s/k3s.yaml /home/{{ $json.devops_user }}/.kube/config\nchown -R {{ $json.devops_user }}:{{ $json.devops_user }} /home/{{ $json.devops_user }}/.kube\n\n# Generate SSH key\nsu - {{ $json.devops_user }} -c \"ssh-keygen -t rsa -b 4096 -C '{{ $json.devops_user }}@devops-server' -N '' -f ~/.ssh/id_rsa\"\n\n# Configure Git\nsu - {{ $json.devops_user }} -c \"git config --global user.name '{{ $json.devops_user }}'\"\nsu - {{ $json.devops_user }} -c \"git config --global user.email '{{ $json.devops_user }}@devops.local'\"\n\necho \"\u2705 DevOps user created successfully!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fcb8d5c7-c333-4bbc-ac49-3fc3e782bd46",
      "name": "Security Configuration",
      "type": "n8n-nodes-base.ssh",
      "position": [
        1980,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83d\udd12 Security & Firewall Configuration\"\necho \"===================================\"\n\n# Configure UFW firewall\nufw --force enable\nufw allow 22/tcp      # SSH\nufw allow 80/tcp      # HTTP\nufw allow 443/tcp     # HTTPS\nufw allow 8080/tcp    # Jenkins\nufw allow 9090/tcp    # Prometheus\nufw allow 3000/tcp    # Grafana\nufw allow 6443/tcp    # Kubernetes API\n\n# Install additional DevOps tools\nsnap install code --classic\nsnap install helm --classic\nsnap install terraform --classic\n\n# Install AWS CLI\ncurl \"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\" -o \"awscliv2.zip\"\nunzip awscliv2.zip && ./aws/install\n\n# Install Azure CLI\ncurl -sL https://aka.ms/InstallAzureCLIDeb | bash\n\n# Install Google Cloud SDK\necho \"deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main\" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list\ncurl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -\napt update && apt install -y google-cloud-cli\n\necho \"\u2705 Security configuration completed!\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b2c7b3cc-d9fd-4931-9c1a-9c2168eef699",
      "name": "Final Configuration",
      "type": "n8n-nodes-base.ssh",
      "position": [
        2200,
        0
      ],
      "parameters": {
        "command": "#!/bin/bash\n\necho \"\ud83c\udfaf Final DevOps Stack Configuration\"\necho \"===================================\"\n\n# Create sample DevOps project structure\ncat > /home/{{ $json.devops_user }}/projects/docker-compose.yml << 'EOF'\nversion: '3.8'\nservices:\n  app:\n    build: .\n    ports:\n      - \"3000:3000\"\n    environment:\n      - NODE_ENV=production\n  \n  redis:\n    image: redis:alpine\n    ports:\n      - \"6379:6379\"\n      \n  postgres:\n    image: postgres:13\n    environment:\n      - POSTGRES_DB=myapp\n      - POSTGRES_USER=user\n      - POSTGRES_PASSWORD=password\n    volumes:\n      - postgres_data:/var/lib/postgresql/data\n      \nvolumes:\n  postgres_data:\nEOF\n\n# Create sample Kubernetes deployment\ncat > /home/{{ $json.devops_user }}/projects/k8s-manifests/deployment.yaml << 'EOF'\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: sample-app\n  namespace: default\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: sample-app\n  template:\n    metadata:\n      labels:\n        app: sample-app\n    spec:\n      containers:\n      - name: app\n        image: nginx:alpine\n        ports:\n        - containerPort: 80\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: sample-app-service\nspec:\n  selector:\n    app: sample-app\n  ports:\n    - protocol: TCP\n      port: 80\n      targetPort: 80\n  type: LoadBalancer\nEOF\n\n# Create sample Jenkins pipeline\ncat > /home/{{ $json.devops_user }}/projects/jenkins-pipelines/Jenkinsfile << 'EOF'\npipeline {\n    agent any\n    \n    stages {\n        stage('Build') {\n            steps {\n                echo 'Building application...'\n                sh 'docker build -t myapp:${BUILD_NUMBER} .'\n            }\n        }\n        \n        stage('Test') {\n            steps {\n                echo 'Running tests...'\n                sh 'docker run --rm myapp:${BUILD_NUMBER} npm test'\n            }\n        }\n        \n        stage('Deploy') {\n            steps {\n                echo 'Deploying to Kubernetes...'\n                sh 'kubectl apply -f k8s-manifests/'\n            }\n        }\n    }\n}\nEOF\n\n# Set proper ownership\nchown -R {{ $json.devops_user }}:{{ $json.devops_user }} /home/{{ $json.devops_user }}/projects/\n\n# Display summary\necho \"\ud83c\udf89 DevOps Stack Setup Complete!\"\necho \"==============================\"\necho \"\ud83d\udcca Installation Summary:\"\necho \"\u2022 Docker: $(docker --version)\"\necho \"\u2022 Kubernetes: $(kubectl version --client --short)\"\necho \"\u2022 Helm: $(helm version --short)\"\necho \"\u2022 Jenkins: http://$(hostname -I | awk '{print $1}'):8080\"\necho \"\u2022 Prometheus: http://$(hostname -I | awk '{print $1}'):9090\"\necho \"\u2022 Grafana: http://$(hostname -I | awk '{print $1}'):3000\"\necho \"\u2022 DevOps User: {{ $json.devops_user }}\"\necho \"\u2022 Password: {{ $json.user_password }}\"\necho \"\u2022 Project Directory: /home/{{ $json.devops_user }}/projects/\"\necho \"\"\necho \"\ud83d\ude80 Your DevOps environment is ready for CI/CD!\"\necho \"Happy DevOps! \ud83c\udfaf\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3f1ef253-89df-4073-9295-0698b0f347cd",
      "name": "Setup Complete",
      "type": "n8n-nodes-base.set",
      "position": [
        2420,
        0
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "setup_status",
              "value": "\u2705 DevOps Stack Setup Complete!"
            },
            {
              "name": "server_info",
              "value": "Host: {{ $('Configure Parameters').item.json.server_host }}"
            },
            {
              "name": "devops_user",
              "value": "Username: {{ $('Configure Parameters').item.json.devops_user }}"
            },
            {
              "name": "user_password",
              "value": "Password: {{ $('Configure Parameters').item.json.user_password }}"
            },
            {
              "name": "tools_installed",
              "value": "Docker, Kubernetes, Jenkins, Prometheus, Grafana, Helm, Terraform"
            },
            {
              "name": "jenkins_url",
              "value": "http://{{ $('Configure Parameters').item.json.server_host }}:8080"
            },
            {
              "name": "grafana_url",
              "value": "http://{{ $('Configure Parameters').item.json.server_host }}:3000"
            },
            {
              "name": "prometheus_url",
              "value": "http://{{ $('Configure Parameters').item.json.server_host }}:9090"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "e8c31a96-3853-4ee6-9870-b73d0ba528e1",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        440,
        0
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "9e38d276-b2e5-4a4b-8038-209a5dcbccf3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        -500
      ],
      "parameters": {
        "color": 4,
        "width": 620,
        "height": 280,
        "content": "## Main Components\n- **Configure Parameters** - Defines server details, tool versions, and credentials\n- **System Preparation** - Updates the system and installs base packages\n- **Install Docker** - Deploys Docker Engine and Docker Compose\n- **Install Kubernetes** - Sets up K3s cluster with kubectl, Helm, and k9s\n- **Install Jenkins** - Configures Jenkins CI/CD server with Docker integration\n- **Install Monitoring** - Deploys Prometheus and Grafana using Helm charts\n- **Create DevOps User** - Establishes a dedicated user with appropriate permissions\n- **Security Configuration** - Implements firewall, VS Code, and Terraform\n- **Final Configuration** - Sets up sample projects and configuration files\n- **Setup Complete** - Provides a summary and access details"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f83e2551-7393-4aec-aba1-d43449ed9961",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "System Preparation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Install Docker": {
      "main": [
        [
          {
            "node": "Install Kubernetes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Install Jenkins": {
      "main": [
        [
          {
            "node": "Install Monitoring",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create DevOps User": {
      "main": [
        [
          {
            "node": "Security Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Install Kubernetes": {
      "main": [
        [
          {
            "node": "Install Jenkins",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Install Monitoring": {
      "main": [
        [
          {
            "node": "Create DevOps User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start DevOps Setup": {
      "main": [
        [
          {
            "node": "Configure Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "System Preparation": {
      "main": [
        [
          {
            "node": "Install Docker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Final Configuration": {
      "main": [
        [
          {
            "node": "Setup Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Parameters": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Security Configuration": {
      "main": [
        [
          {
            "node": "Final Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}