{"id":24430847,"url":"https://github.com/engineermichael/project-2-devops-automation","last_synced_at":"2026-02-09T19:09:17.277Z","repository":{"id":273289229,"uuid":"919222357","full_name":"EngineerMichael/Project-2-DevOps-Automation","owner":"EngineerMichael","description":"A collection of scripts and configurations to automate CI/CD pipelines, infrastructure provisioning, and monitoring.","archived":false,"fork":false,"pushed_at":"2025-01-20T01:42:22.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-23T14:02:35.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EngineerMichael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-20T01:41:45.000Z","updated_at":"2025-01-20T01:43:48.000Z","dependencies_parsed_at":"2025-01-20T02:39:28.239Z","dependency_job_id":"fcfd4806-dcf8-4935-91b5-0e60f4ee03c7","html_url":"https://github.com/EngineerMichael/Project-2-DevOps-Automation","commit_stats":null,"previous_names":["engineermichael/project-2-devops-automation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EngineerMichael/Project-2-DevOps-Automation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineerMichael%2FProject-2-DevOps-Automation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineerMichael%2FProject-2-DevOps-Automation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineerMichael%2FProject-2-DevOps-Automation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineerMichael%2FProject-2-DevOps-Automation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EngineerMichael","download_url":"https://codeload.github.com/EngineerMichael/Project-2-DevOps-Automation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineerMichael%2FProject-2-DevOps-Automation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29278180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T19:05:41.198Z","status":"ssl_error","status_checked_at":"2026-02-09T19:05:37.449Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-20T14:58:02.186Z","updated_at":"2026-02-09T19:09:11.582Z","avatar_url":"https://github.com/EngineerMichael.png","language":null,"readme":"# Project-2-DevOps-Automation\nA collection of scripts and configurations to automate CI/CD pipelines, infrastructure provisioning, and monitoring.\nSure! Below is the source code for a **DevOps Automation** project that demonstrates how to automate CI/CD pipelines, infrastructure provisioning, and monitoring. This project will use the following tools:\n\n1. **CI/CD Pipeline**: GitHub Actions (or any other CI tool like Jenkins or GitLab CI) for automating build, test, and deployment processes.\n2. **Infrastructure Provisioning**: Terraform to automate the creation of cloud infrastructure (AWS example).\n3. **Monitoring**: Prometheus and Grafana for monitoring infrastructure and applications.\n\n### **Project Structure Overview**\n\n```plaintext\ndevops-automation/\n│\n├── .github/\n│   └── workflows/\n│       └── ci-cd-pipeline.yml          # GitHub Actions CI/CD pipeline configuration\n│\n├── terraform/\n│   ├── main.tf                         # Terraform configuration to provision infrastructure\n│   ├── variables.tf                    # Variables for Terraform\n│   ├── outputs.tf                      # Terraform outputs\n│   └── provider.tf                     # Cloud provider configuration (AWS in this case)\n│\n├── monitoring/\n│   ├── prometheus.yml                  # Prometheus configuration for monitoring\n│   ├── docker-compose.yml              # Docker Compose file to spin up Prometheus and Grafana\n│   └── grafana-dashboards.json         # Example Grafana dashboards\n│\n├── scripts/\n│   ├── deploy.sh                       # Deployment script for the application\n│   └── monitor.sh                      # Script to check system health\n│\n└── README.md                           # Project documentation\n```\n\n### **Step 1: CI/CD Pipeline using GitHub Actions**\n\n1. **GitHub Actions Workflow (`.github/workflows/ci-cd-pipeline.yml`)**\n\nThis file automates the CI/CD process by defining the steps required for building, testing, and deploying the application whenever code is pushed to the repository.\n\n```yaml\nname: CI/CD Pipeline\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  build-and-test:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v2\n      \n      - name: Set up Node.js\n        uses: actions/setup-node@v2\n        with:\n          node-version: '14'\n\n      - name: Install dependencies\n        run: npm install\n\n      - name: Run tests\n        run: npm test\n\n  deploy:\n    runs-on: ubuntu-latest\n    needs: build-and-test\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v2\n\n      - name: Setup SSH\n        uses: webfactory/ssh-agent@v0.5.3\n        with:\n          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}\n\n      - name: Deploy to server\n        run: |\n          ssh -o StrictHostKeyChecking=no user@your-server-ip 'bash -s' \u003c ./scripts/deploy.sh\n```\n\n- This workflow automatically runs when changes are pushed to the `main` branch or when a pull request is created against `main`.\n- The `build-and-test` job installs dependencies and runs the tests.\n- The `deploy` job deploys the application to the server after tests pass.\n\n### **Step 2: Infrastructure Provisioning with Terraform**\n\nTerraform is used to automate the provisioning of infrastructure. In this example, we will provision an EC2 instance on AWS.\n\n1. **Terraform Configuration (`terraform/main.tf`)**\n\n```hcl\nprovider \"aws\" {\n  region = var.aws_region\n}\n\nresource \"aws_instance\" \"example\" {\n  ami           = \"ami-0c55b159cbfafe1f0\"  # Use a valid Ubuntu AMI for your region\n  instance_type = \"t2.micro\"\n  \n  tags = {\n    Name = \"DevOpsAutomationInstance\"\n  }\n}\n\noutput \"instance_ip\" {\n  value = aws_instance.example.public_ip\n}\n```\n\n- This configuration defines an EC2 instance using an Ubuntu AMI.\n- The `output` block outputs the public IP of the created EC2 instance.\n\n2. **Variables (`terraform/variables.tf`)**\n\n```hcl\nvariable \"aws_region\" {\n  description = \"AWS region to provision resources\"\n  default     = \"us-west-2\"\n}\n```\n\n- The `aws_region` variable allows you to specify the AWS region for provisioning resources.\n\n3. **Provider Configuration (`terraform/provider.tf`)**\n\n```hcl\nprovider \"aws\" {\n  region = \"us-west-2\"  # specify your region here\n}\n```\n\n- This file configures the AWS provider.\n\n4. **Apply Terraform Configuration**\n\nTo apply the configuration, use the following commands:\n\n```bash\n# Initialize Terraform\nterraform init\n\n# Apply Terraform configuration to provision resources\nterraform apply\n```\n\nThis will create the infrastructure on AWS (an EC2 instance, in this case).\n\n### **Step 3: Monitoring with Prometheus and Grafana**\n\nWe will use **Prometheus** for monitoring metrics and **Grafana** for visualizing those metrics.\n\n1. **Prometheus Configuration (`monitoring/prometheus.yml`)**\n\nThis file configures Prometheus to scrape metrics from your application.\n\n```yaml\nglobal:\n  scrape_interval: 15s\n\nscrape_configs:\n  - job_name: 'nodejs-app'\n    static_configs:\n      - targets: ['localhost:8080']  # Replace with your application's metrics endpoint\n```\n\n2. **Docker Compose for Prometheus and Grafana (`monitoring/docker-compose.yml`)**\n\nThis file defines the Docker containers for Prometheus and Grafana.\n\n```yaml\nversion: '3'\n\nservices:\n  prometheus:\n    image: prom/prometheus\n    container_name: prometheus\n    volumes:\n      - ./prometheus.yml:/etc/prometheus/prometheus.yml\n    ports:\n      - \"9090:9090\"\n\n  grafana:\n    image: grafana/grafana\n    container_name: grafana\n    environment:\n      GF_SECURITY_ADMIN_PASSWORD: \"admin\"\n    ports:\n      - \"3000:3000\"\n    depends_on:\n      - prometheus\n```\n\n- Prometheus will scrape metrics from the application and store them.\n- Grafana will be accessible on port 3000 for visualizing those metrics.\n- Grafana's default username is `admin`, and the password is set as `admin`.\n\n3. **Grafana Dashboards (`monitoring/grafana-dashboards.json`)**\n\nHere’s an example of a basic Grafana dashboard JSON file.\n\n```json\n{\n  \"dashboard\": {\n    \"title\": \"Node.js Application Metrics\",\n    \"panels\": [\n      {\n        \"title\": \"CPU Usage\",\n        \"type\": \"graph\",\n        \"targets\": [\n          {\n            \"expr\": \"rate(process_cpu_seconds_total[5m])\",\n            \"legendFormat\": \"CPU Usage\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n- This dashboard shows CPU usage from the `process_cpu_seconds_total` metric.\n\n4. **Run Prometheus and Grafana with Docker Compose**\n\nTo start Prometheus and Grafana, use Docker Compose:\n\n```bash\ncd monitoring\ndocker-compose up -d\n```\n\n- Access **Prometheus** at `http://localhost:9090`.\n- Access **Grafana** at `http://localhost:3000` (login with `admin`/`admin`).\n\n---\n\n### **Step 4: Deployment Script**\n\n1. **Deployment Script (`scripts/deploy.sh`)**\n\nThis script will be used in the CI/CD pipeline to deploy the application to the server.\n\n```bash\n#!/bin/bash\n\n# SSH into the server and pull the latest changes from GitHub\nssh user@your-server-ip \u003c\u003c 'EOF'\n  cd /path/to/your/app\n  git pull origin main\n  npm install\n  pm2 restart app\nEOF\n```\n\n- This script SSHs into the server, pulls the latest code from the repository, installs dependencies, and restarts the application.\n\n2. **Health Monitoring Script (`scripts/monitor.sh`)**\n\nThis script checks the health of the deployed application.\n\n```bash\n#!/bin/bash\n\n# Check if the application is running\nif curl -s http://localhost:8080/health | grep \"OK\"; then\n  echo \"Application is healthy\"\nelse\n  echo \"Application is down\"\n  exit 1\nfi\n```\n\n- This script pings the `/health` endpoint of the application to check if it's running and returns an appropriate status.\n\n---\n\n### **Step 5: Documentation (`README.md`)**\n\nProvide documentation for setting up and running the project.\n\n```markdown\n# DevOps Automation\n\nThis project automates the process of CI/CD, infrastructure provisioning, and monitoring.\n\n## Prerequisites\n\n- Terraform\n- Docker\n- Prometheus and Grafana (via Docker Compose)\n- AWS account (for infrastructure provisioning)\n- Node.js application to deploy\n\n## Steps\n\n### 1. Set up Infrastructure\n- Run `terraform apply` to provision the infrastructure on AWS.\n\n### 2. CI/CD Pipeline\n- GitHub Actions will automatically run on every push to the `main` branch to build, test, and deploy the application.\n\n### 3. Monitoring\n- Run `docker-compose up` in the `monitoring` directory to start Prometheus and Grafana for application monitoring.\n- Access Prometheus at `http://localhost:9090` and Grafana at `http://localhost:3000`.\n\n### 4. Deploying\n- The deployment script (`scripts/deploy.sh`) is used in the CI/CD pipeline to deploy the latest code to the server.\n\n## Conclusion\n\nThis project demonstrates automating the CI/CD process, provisioning cloud infrastructure, and monitoring the application using DevOps best practices.\n```\n\n---\n\n### **Conclusion**\n\nThis **DevOps Automation** project provides a simple yet effective pipeline for automating infrastructure provisioning (with Terraform), continuous integration/deployment (with GitHub Actions), and monitoring (with Prometheus and Grafana). You can extend this project to deploy and monitor different types of applications, integrate with additional tools, or scale it to larger infrastructure.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineermichael%2Fproject-2-devops-automation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengineermichael%2Fproject-2-devops-automation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineermichael%2Fproject-2-devops-automation/lists"}