วันศุกร์ที่ 13 พฤศจิกายน พ.ศ. 2569

ubuntu - rundeck ce

 

คู่มือการติดตั้ง Rundeck Community Edition พร้อม PostgreSQL

บน Ubuntu Server 24.04 LTS

Rundeck CE + PostgreSQL Installation Guide

รายการรายละเอียด
SoftwareRundeck Community Edition
Operating SystemUbuntu Server 24.04 LTS
Java RuntimeOpenJDK 17
DatabasePostgreSQL
Database VersionUbuntu 24.04 Repository Version
Installation MethodAPT Repository
Web InterfaceTCP Port 4440
Database PortTCP Port 5432
Servicerundeckd / postgresql
Document Version1.0
Date13 November 2026

1. วัตถุประสงค์ (Objective)

เอกสารฉบับนี้จัดทำขึ้นเพื่ออธิบายขั้นตอนการติดตั้ง Rundeck Community Edition (CE) ร่วมกับ PostgreSQL Database บน Ubuntu Server 24.04 LTS

โดยกำหนดให้ PostgreSQL เป็นฐานข้อมูลหลักสำหรับจัดเก็บข้อมูลของ Rundeck แทน Embedded H2 Database เพื่อให้เหมาะสมกับการนำไปใช้งานในระบบ Production

1.1 ความสามารถของระบบ

  • Centralized Automation Management
  • Remote Command Execution ผ่าน SSH
  • Job Scheduling
  • Workflow Automation
  • Job Execution History
  • Node Management
  • User and Role Management

2. System Architecture

โครงสร้างระบบที่ติดตั้งประกอบด้วย:

text
          Administrator
                |
                |
           Web Browser
                |
                | TCP 4440
                |
        +----------------+
        |                |
        |  Ubuntu Server |
        |                |
        |    Rundeck CE  |
        |                |
        +----------------+
                |
                | JDBC
                | TCP 5432
                |
        +----------------+
        |   PostgreSQL   |
        |    Database    |
        |                |
        | DB: rundeck    |
        | User: rundeck  |
        +----------------+

หมายเหตุ: ตัวอย่างนี้ติดตั้ง Rundeck และ PostgreSQL บน Ubuntu Server เครื่องเดียวกัน โดยเชื่อมต่อ Database ผ่าน localhost

3. System Requirements

3.1 Hardware Requirements

ResourceRecommended
CPU2-4 Cores
RAM8 GB ขึ้นไป
Disk30 GB ขึ้นไป
NetworkInternet Access
OSUbuntu Server 24.04 LTS

ขนาด Hardware สามารถปรับเพิ่มตามจำนวน Node และปริมาณ Job ที่ทำงานในระบบ

3.2 Software Requirements

SoftwareVersion
Ubuntu24.04 LTS
OpenJDK17
PostgreSQLUbuntu Repository Version
Rundeck CECommunity Edition
JDBC DriverPostgreSQL JDBC

4. เตรียมความพร้อม Ubuntu Server

เข้าสู่ระบบด้วย User ที่มีสิทธิ์ sudo

4.1 Update System


sudo apt update
sudo apt upgrade -y

4.2 ติดตั้ง Package พื้นฐาน


sudo apt install -y \
curl \
wget \
gnupg \
ca-certificates \
vim \
net-tools

4.3 ตั้งค่า Timezone

ตัวอย่างประเทศไทย:

bash
sudo timedatectl set-timezone Asia/Bangkok

ตรวจสอบ:

bash
timedatectl

5. ติดตั้ง Java OpenJDK 17

Rundeck ต้องใช้ Java Runtime Environment ในการทำงาน

5.1 ติดตั้ง Java


sudo apt install -y openjdk-17-jre-headless

5.2 ตรวจสอบ Java


java -version

ตรวจสอบ Java Path:


readlink -f $(which java)

ผลลัพธ์ควรเป็น Java Version 17

6. ติดตั้ง PostgreSQL Database

6.1 ติดตั้ง PostgreSQL


sudo apt install -y postgresql postgresql-contrib

6.2 Enable PostgreSQL Service


sudo systemctl enable postgresql
sudo systemctl start postgresql

ตรวจสอบสถานะ:


sudo systemctl status postgresql

สถานะที่ต้องการ:


Active: active (exited)

หมายเหตุ: Ubuntu ใช้ PostgreSQL cluster management ผ่าน service wrapper ซึ่งสถานะของ service หลักอาจแสดง active (exited) ได้ ให้ตรวจสอบ cluster เพิ่มเติมด้วยคำสั่ง:

pg_lsclusters

6.3 ตรวจสอบ PostgreSQL Version

sudo -u postgres psql -c "SELECT version();"

6.4 สร้าง Database และ User สำหรับ Rundeck

เข้าสู่ PostgreSQL:


sudo -u postgres psql

สร้าง User:

sql
CREATE USER rundeck WITH PASSWORD 'CHANGE_THIS_STRONG_PASSWORD';

สร้าง Database:

sql
CREATE DATABASE rundeck OWNER rundeck;

กำหนดสิทธิ์:

sql
GRANT ALL PRIVILEGES ON DATABASE rundeck TO rundeck;

ออกจาก PostgreSQL:

sql
\q

หมายเหตุ: ให้เปลี่ยน CHANGE_THIS_STRONG_PASSWORD เป็นรหัสผ่านจริงที่มีความซับซ้อน และห้ามใช้ตัวอย่างนี้ใน Production

6.5 ตรวจสอบ Database

bash
sudo -u postgres psql -l

ควรพบ Database ชื่อ:

text
rundeck

6.6 ทดสอบ Login ด้วย User Rundeck

bash
PGPASSWORD='CHANGE_THIS_STRONG_PASSWORD' \
psql -h 127.0.0.1 -U rundeck -d rundeck \
-c "SELECT current_database(), current_user;"

ผลลัพธ์ควรแสดง:

text
 current_database | current_user
------------------+-------------
 rundeck          | rundeck

7. ติดตั้ง Rundeck Community Edition

7.1 เพิ่ม Rundeck Official Repository

ใช้คำสั่ง:

bash
curl -fsSL \
https://raw.githubusercontent.com/rundeck/packaging/main/scripts/deb-setup.sh \
| sudo bash -s rundeck

คำสั่งดังกล่าวใช้สำหรับเพิ่ม Community Edition Repository

7.2 Update Repository

bash
sudo apt update

7.3 ติดตั้ง Rundeck CE

bash
sudo apt install -y rundeck

ตรวจสอบ Package:

bash
dpkg -l | grep rundeck

7.4 หยุด Rundeck Service ก่อนตั้งค่า Database

bash
sudo systemctl stop rundeckd

ขั้นตอนนี้ช่วยป้องกันไม่ให้ Rundeck เริ่มต้นด้วยค่า Database H2 ก่อนเปลี่ยนไปใช้ PostgreSQL

8. ตั้งค่า Rundeck เชื่อมต่อ PostgreSQL

8.1 สำรอง Configuration เดิม

bash
sudo cp \
/etc/rundeck/rundeck-config.properties \
/etc/rundeck/rundeck-config.properties.bak

8.2 แก้ไข Configuration

bash
sudo vim /etc/rundeck/rundeck-config.properties

เพิ่มหรือแก้ไขค่า Database Configuration ดังนี้:

properties
dataSource.driverClassName=org.postgresql.Driver

dataSource.url=jdbc:postgresql://127.0.0.1:5432/rundeck

dataSource.username=rundeck

dataSource.password=CHANGE_THIS_STRONG_PASSWORD

เปลี่ยนรหัสผ่านให้ตรงกับ User ที่สร้างไว้ใน PostgreSQL

ข้อควรระวัง:

  • ไม่ควรมีช่องว่างระหว่างเครื่องหมาย = กับค่ารหัสผ่าน
  • ห้ามมี Configuration ของ H2 ที่ขัดแย้งกับ PostgreSQL
  • ตรวจสอบว่า PostgreSQL JDBC Driver พร้อมใช้งาน ซึ่งใน Rundeck รุ่นปัจจุบันมีการรวม Driver มาให้แล้ว

8.3 ตั้งค่า Server URL

เพิ่มหรือแก้ไข:

properties
grails.serverURL=http://YOUR_SERVER_IP:4440

ตัวอย่าง:

properties
grails.serverURL=http://192.168.1.100:4440

เปลี่ยน IP ให้ตรงกับ IP Address ของ Ubuntu Server

9. เริ่มต้น Rundeck Service

9.1 Start Rundeck

bash
sudo systemctl daemon-reload
sudo systemctl start rundeckd

9.2 Enable Auto Start

bash
sudo systemctl enable rundeckd

9.3 ตรวจสอบสถานะ

bash
sudo systemctl status rundeckd

สถานะที่ต้องการ:

text
Active: active (running)

9.4 ตรวจสอบ Rundeck Log

bash
sudo tail -f /var/log/rundeck/service.log

รอจนพบข้อความลักษณะนี้:

text
Grails application running at http://localhost:4440

9.5 ตรวจสอบ Database Connection

ตรวจสอบ Log เพื่อให้แน่ใจว่า Rundeck สามารถเชื่อมต่อ PostgreSQL ได้ และไม่มีข้อความ Database Connection Error

10. ตั้งค่า Firewall

10.1 เปิด Web Interface Port

bash
sudo ufw allow 4440/tcp

10.2 PostgreSQL Port

เนื่องจากติดตั้ง PostgreSQL และ Rundeck บนเครื่องเดียวกัน จึงไม่จำเป็นต้องเปิด Port 5432 ให้เครือข่ายภายนอก

แนะนำให้ PostgreSQL รับการเชื่อมต่อเฉพาะ localhost

ตรวจสอบสถานะ:

bash
sudo ufw status

11. เข้าใช้งาน Rundeck Web Interface

เปิด Browser จากเครื่อง Client

ระบุ URL:

text
http://YOUR_SERVER_IP:4440

ตัวอย่าง:

text
http://192.168.1.100:4440

ข้อมูล Login เริ่มต้นตามค่า Default:

รายการค่า
Usernameadmin
Passwordadmin
Port4440

Security Requirement: เปลี่ยนรหัสผ่าน Default และตั้งค่าการเข้าถึงให้เหมาะสมก่อนนำไปใช้งานจริง

12. ตรวจสอบระบบหลังติดตั้ง

ดำเนินการตรวจสอบระบบทั้งหมดตามรายการต่อไปนี้

12.1 ตรวจสอบ Java

bash
java -version

12.2 ตรวจสอบ PostgreSQL

bash
sudo systemctl status postgresql

12.3 ตรวจสอบ PostgreSQL Cluster

bash
pg_lsclusters

12.4 ตรวจสอบ Database

bash
sudo -u postgres psql -l

12.5 ตรวจสอบ Rundeck Service

bash
sudo systemctl status rundeckd

12.6 ตรวจสอบ Port

bash
sudo ss -lntp | grep -E '4440|5432'

12.7 ตรวจสอบ HTTP

bash
curl -I http://localhost:4440

12.8 ตรวจสอบ Log

bash
sudo tail -n 100 /var/log/rundeck/service.log

13. การ Backup PostgreSQL

แนะนำให้ตั้งค่า Backup Database เป็นประจำ

13.1 สร้าง Backup Directory

bash
sudo mkdir -p /backup/rundeck
sudo chown postgres:postgres /backup/rundeck

13.2 Backup Database

bash
sudo -u postgres pg_dump \
-F c \
-f /backup/rundeck/rundeck_$(date +%F).dump \
rundeck

13.3 ตรวจสอบไฟล์ Backup

bash
sudo ls -lh /backup/rundeck/

13.4 Restore Database

ตัวอย่างการ Restore:

bash
sudo -u postgres pg_restore \
--clean \
--if-exists \
-d rundeck \
/backup/rundeck/rundeck_2026-11-13.dump

ข้อควรระวัง: ควรทดสอบ Restore ในระบบทดสอบก่อนใช้งานจริง และต้องหยุด Rundeck ก่อน Restore Database เพื่อป้องกันข้อมูลไม่สอดคล้องกัน

ควรสำรองข้อมูลเพิ่มเติม ได้แก่:

  • /etc/rundeck/
  • /var/lib/rundeck/
  • Project Configuration
  • Key Storage และไฟล์ที่เกี่ยวข้อง

14. Troubleshooting

14.1 Rundeck ไม่สามารถ Start ได้

ตรวจสอบ:

bash
sudo systemctl status rundeckd

sudo journalctl -u rundeckd -n 100 --no-pager

sudo tail -n 100 /var/log/rundeck/service.log

14.2 PostgreSQL Connection Refused

ตรวจสอบ:

bash
sudo systemctl status postgresql

pg_lsclusters

sudo ss -lntp | grep 5432

ทดสอบเชื่อมต่อ:

bash
psql -h 127.0.0.1 -U rundeck -d rundeck

14.3 Password Authentication Failed

ตรวจสอบ:

  • Username ของ PostgreSQL
  • Password ใน Configuration
  • Password ของ Database User
  • PostgreSQL Authentication Configuration

14.4 Database Does Not Exist

ตรวจสอบ:

bash
sudo -u postgres psql -l

ตรวจสอบว่ามี Database ชื่อ rundeck

14.5 ไม่สามารถเข้า Web Interface ได้

ตรวจสอบ:

bash
sudo ss -lntp | grep 4440

sudo ufw status

sudo systemctl status rundeckd

15. Security Recommendations สำหรับ Production

ก่อนนำระบบไปใช้งานจริง แนะนำให้ดำเนินการเพิ่มเติม:

  1. เปลี่ยน Default Admin Password
  2. ใช้งาน HTTPS ผ่าน Nginx Reverse Proxy
  3. จำกัด IP ที่เข้าถึง Web Interface
  4. จำกัด PostgreSQL ให้รับการเชื่อมต่อจาก Localhost หากติดตั้งเครื่องเดียวกัน
  5. กำหนดสิทธิ์ User และ Role ตามหน้าที่
  6. ใช้ SSH Key Authentication สำหรับ Managed Nodes
  7. จำกัดสิทธิ์ Sudo ของบัญชีที่ Rundeck ใช้
  8. ตั้งค่า Database Backup และทดสอบ Restore
  9. จัดเก็บ Password และ Secret อย่างปลอดภัย
  10. ติดตาม Log และตรวจสอบการทำงานของระบบอย่างสม่ำเสมอ

16. สรุปผลการติดตั้ง

หลังจากดำเนินการติดตั้งตามขั้นตอนทั้งหมด จะได้ระบบ Rundeck Community Edition ที่ทำงานบน Ubuntu Server 24.04 LTS และใช้ PostgreSQL เป็น Database Backend

ระบบพร้อมสำหรับการดำเนินการขั้นตอนถัดไป ได้แก่:

  • สร้าง Rundeck Project
  • เพิ่ม Managed Nodes
  • ตั้งค่า SSH Connection
  • สร้าง Automation Jobs
  • กำหนด Job Scheduling
  • ตั้งค่า User และ Access Control

Installation Checklist

รายการตรวจสอบผลการดำเนินงาน
Ubuntu Server 24.04☐ Complete
OpenJDK 17☐ Complete
PostgreSQL Installation☐ Complete
PostgreSQL Database☐ Complete
PostgreSQL User☐ Complete
Rundeck CE Installation☐ Complete
Database Configuration☐ Complete
Rundeck Service☐ Complete
Firewall Configuration☐ Complete
Web Interface Login☐ Complete
Database Backup☐ Complete

ผู้ดำเนินการติดตั้ง

ผู้ติดตั้ง: ............................................................

วันที่ดำเนินการ: ....................................................

ผู้ตรวจสอบ: ..........................................................

วันที่ตรวจสอบ: ......................................................

Installation Status: Completed / Pending Verification


17. Reference Documents

  1. Rundeck Official Documentation – Ubuntu/Debian Installation
    https://docs.rundeck.com/docs/administration/install/linux-deb.html
  2. Rundeck Official Documentation – PostgreSQL Database
    https://docs.rundeck.com/docs/administration/configuration/database/postgres.html
  3. Rundeck Database Configuration
    https://docs.rundeck.com/docs/administration/configuration/database/
  4. Rundeck Configuration Reference
    https://docs.rundeck.com/docs/administration/configuration/config-file-reference.html

End of Document