Linuxサーバー上で10秒で完全自動DevOpsインフラ構築
これはDevOps分野の自動化ワークフローで、13個のノードを含みます。主にSet, Ssh, Wait, ManualTriggerなどのノードを使用。 Docker、K8s、Jenkins、Grafanaを使用してLinuxサーバーのDevOpsインフラを自動化
- •特別な前提条件なし、インポートしてすぐに使用可能
使用ノード (13)
カテゴリー
{
"id": "7p3d4ltVk0ICrNbX",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "Automate Full DevOps Infrastructure Setup on Linux Server in Just 10 Seconds",
"tags": [],
"nodes": [
{
"id": "a0973093-3fba-485a-8100-ae3e54c9dc5f",
"name": "DevOpsセットアップ開始",
"type": "n8n-nodes-base.manualTrigger",
"position": [
0,
0
],
"parameters": {},
"typeVersion": 1
},
{
"id": "83e1e3a0-ef2f-45d7-bf73-a37f430ca622",
"name": "パラメータ設定",
"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": "システム準備",
"type": "n8n-nodes-base.ssh",
"position": [
660,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"🚀 DevOps Stack Setup - System Preparation\"\necho \"==========================================\"\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 \"✅ System preparation completed!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "150157b9-6b02-4953-aa60-192f526d9f9a",
"name": "Dockerインストール",
"type": "n8n-nodes-base.ssh",
"position": [
880,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"🐳 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 \"✅ Docker installation completed!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "8e450cfb-3075-4d36-96bf-2a342e04dd87",
"name": "Kubernetesインストール",
"type": "n8n-nodes-base.ssh",
"position": [
1100,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"☸️ 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 \"✅ Kubernetes installation completed!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "8fccf05b-3eb2-401f-bbfb-96b3d1b9aa5f",
"name": "Jenkinsインストール",
"type": "n8n-nodes-base.ssh",
"position": [
1320,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"🔧 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/lib/jenkins/secrets/initialAdminPassword)\"\necho \"✅ Jenkins installation completed!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "668996d6-413b-4467-8ad0-600a5d3162cf",
"name": "監視ツールインストール",
"type": "n8n-nodes-base.ssh",
"position": [
1540,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"📊 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 \"✅ Monitoring stack installation completed!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "7d88a242-654b-4dee-8642-84366b4eacb9",
"name": "DevOpsユーザー作成",
"type": "n8n-nodes-base.ssh",
"position": [
1760,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"👤 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 \"✅ DevOps user created successfully!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "fcb8d5c7-c333-4bbc-ac49-3fc3e782bd46",
"name": "セキュリティ設定",
"type": "n8n-nodes-base.ssh",
"position": [
1980,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"🔒 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 \"✅ Security configuration completed!\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "b2c7b3cc-d9fd-4931-9c1a-9c2168eef699",
"name": "最終設定",
"type": "n8n-nodes-base.ssh",
"position": [
2200,
0
],
"parameters": {
"command": "#!/bin/bash\n\necho \"🎯 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 \"🎉 DevOps Stack Setup Complete!\"\necho \"==============================\"\necho \"📊 Installation Summary:\"\necho \"• Docker: $(docker --version)\"\necho \"• Kubernetes: $(kubectl version --client --short)\"\necho \"• Helm: $(helm version --short)\"\necho \"• Jenkins: http://$(hostname -I | awk '{print $1}'):8080\"\necho \"• Prometheus: http://$(hostname -I | awk '{print $1}'):9090\"\necho \"• Grafana: http://$(hostname -I | awk '{print $1}'):3000\"\necho \"• DevOps User: {{ $json.devops_user }}\"\necho \"• Password: {{ $json.user_password }}\"\necho \"• Project Directory: /home/{{ $json.devops_user }}/projects/\"\necho \"\"\necho \"🚀 Your DevOps environment is ready for CI/CD!\"\necho \"Happy DevOps! 🎯\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "3f1ef253-89df-4073-9295-0698b0f347cd",
"name": "セットアップ完了",
"type": "n8n-nodes-base.set",
"position": [
2420,
0
],
"parameters": {
"values": {
"string": [
{
"name": "setup_status",
"value": "✅ 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": "待機",
"type": "n8n-nodes-base.wait",
"position": [
440,
0
],
"webhookId": "4c6684a7-dc07-4a55-bb17-832802b06d9a",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "9e38d276-b2e5-4a4b-8038-209a5dcbccf3",
"name": "付箋1",
"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,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "f83e2551-7393-4aec-aba1-d43449ed9961",
"connections": {
"e8c31a96-3853-4ee6-9870-b73d0ba528e1": {
"main": [
[
{
"node": "8f11ab98-149b-4192-8345-b278532d12ab",
"type": "main",
"index": 0
}
]
]
},
"150157b9-6b02-4953-aa60-192f526d9f9a": {
"main": [
[
{
"node": "8e450cfb-3075-4d36-96bf-2a342e04dd87",
"type": "main",
"index": 0
}
]
]
},
"8fccf05b-3eb2-401f-bbfb-96b3d1b9aa5f": {
"main": [
[
{
"node": "668996d6-413b-4467-8ad0-600a5d3162cf",
"type": "main",
"index": 0
}
]
]
},
"7d88a242-654b-4dee-8642-84366b4eacb9": {
"main": [
[
{
"node": "fcb8d5c7-c333-4bbc-ac49-3fc3e782bd46",
"type": "main",
"index": 0
}
]
]
},
"8e450cfb-3075-4d36-96bf-2a342e04dd87": {
"main": [
[
{
"node": "8fccf05b-3eb2-401f-bbfb-96b3d1b9aa5f",
"type": "main",
"index": 0
}
]
]
},
"668996d6-413b-4467-8ad0-600a5d3162cf": {
"main": [
[
{
"node": "7d88a242-654b-4dee-8642-84366b4eacb9",
"type": "main",
"index": 0
}
]
]
},
"a0973093-3fba-485a-8100-ae3e54c9dc5f": {
"main": [
[
{
"node": "83e1e3a0-ef2f-45d7-bf73-a37f430ca622",
"type": "main",
"index": 0
}
]
]
},
"8f11ab98-149b-4192-8345-b278532d12ab": {
"main": [
[
{
"node": "150157b9-6b02-4953-aa60-192f526d9f9a",
"type": "main",
"index": 0
}
]
]
},
"b2c7b3cc-d9fd-4931-9c1a-9c2168eef699": {
"main": [
[
{
"node": "3f1ef253-89df-4073-9295-0698b0f347cd",
"type": "main",
"index": 0
}
]
]
},
"83e1e3a0-ef2f-45d7-bf73-a37f430ca622": {
"main": [
[
{
"node": "e8c31a96-3853-4ee6-9870-b73d0ba528e1",
"type": "main",
"index": 0
}
]
]
},
"fcb8d5c7-c333-4bbc-ac49-3fc3e782bd46": {
"main": [
[
{
"node": "b2c7b3cc-d9fd-4931-9c1a-9c2168eef699",
"type": "main",
"index": 0
}
]
]
}
}
}このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級 - DevOps
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
このワークフローを共有