Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
2019 - PVE 社群 - Rails 串接 Proxmox VE API 自動化教學用虛...
Search
蒼時弦や
December 07, 2019
Programming
670
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
2019 - PVE 社群 - Rails 串接 Proxmox VE API 自動化教學用虛擬機分配
再接案公司用 Proxmox VE 建制簡易的練習 VM 環境,讓同事可以在需要的時候申請機器來練習使用。
蒼時弦や
December 07, 2019
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
210
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
270
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
500
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
730
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
490
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
520
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
540
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
310
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
350
Other Decks in Programming
See All in Programming
Building a Meta Ray-Ban display app
akkeylab
0
180
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
240
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
130
VibeCodingからAgenticWorkflowへ
starfish719
0
810
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
160
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
400
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.7k
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
1
350
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
170
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
430
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.7k
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
220
The SEO Collaboration Effect
kristinabergwall1
1
530
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Scaling GitHub
holman
464
140k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
500
Designing for Performance
lara
611
70k
Marketing to machines
jonoalderson
1
5.7k
Designing Powerful Visuals for Engaging Learning
tmiket
1
510
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
580
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
810
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
420
Transcript
Rails 串接 Proxmox VE API 自動化教學用虛擬機分配 Photo by Franck V.
on Unsplash
WEB DEVELOPER GAME DEVELOPER ࣌ ݭ @elct9620
None
為什麼 使用 Proxmox VE?
Photo by Hal Gatewood on Unsplash 接案公司
Photo by Jordan Harrison on Unsplash 硬體資源不足
Photo by NESA by Makers on Unsplash 技術交接容易
為什麼 要做虛擬機練習系統?
Photo by Christina @ wocintechchat.com on Unsplash 熟悉 DevOps 的人太少
Photo by Jordan Sanchez on Unsplash 練習的機會不多
Photo by Christian Fregnan on Unsplash 人工開設虛擬機並不方便
如何用 Proxmox VE 解決 問題?
API Snapshot Qemu Agent + +
require 'net/http' rquire 'oj' uri = URI('https:!//192.168.100.220:8006/api2/json/access/ticket') req = Net!::HTTP!::Post.new
req['Content-Type'] = 'application/x-!!www-form-urlencoded' req.body = URI.encode_!!www_form(username: 'xxx@pve', password: 'xxx') token = {} Net!::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| res = http.request(req) token = Oj.load(res.body)&.fetch('data', {}) end puts token['ticket'] # !=> XXXX puts token['CSRFPreventionToken'] # !=> XXX
require 'net/http' rquire 'oj' uri = URI(TICKET_URI) req = Net!::HTTP!::Post.new
req['Content-Type'] = 'application/x-!!www-form-urlencoded' req.body = URI.encode_!!www_form( username: 'xxx@pve', password: 'xxx' )
token = {} Net!::HTTP.start( uri.host, uri.port, use_ssl: true ) do
|http| res = http.request(req) token = Oj.load(res.body)&.fetch('data', {}) end puts token['ticket'] # !=> XXXX puts token['CSRFPreventionToken'] # !=> XXX
req = Net!::HTTP!::Get.new(uri) req['Cookie'] = "PVEAuthCookie=!#{token['ticket']}"
req = Net!::HTTP!::Post.new(uri) req['Cookie'] = "PVEAuthCookie=!#{token['ticket']}" req['CSRFPreventionToken'] = token['CSRFPreventionToken']
詳細的文件可以在 Wiki 中找到
非同步 行為處理
Proxmox!::API.post('nodes/pve/100/status/start') .fetch(:data) # !=> UPID:pve:00001560:3C9C598C:5C6944F7:qmstart: 100:user@pve:
需要自己用 UPID 確認狀態
loop do status = task('pve', upid) break if status['exitstatus'] !==
'OK' sleep 1 end
Snapshot Backup VS
None
如何 自動設定 SSH Key 到機器
None
None
File Write Qemu Agent VM PlayGround GitLab Public Key
File Write Qemu Agent VM PlayGround GitLab Public Key 從
GitLab 取出 使用者 Public Key
File Write Qemu Agent VM PlayGround GitLab Public Key 透過
Proxmox API 控制 Qemu Agent
File Write Qemu Agent VM PlayGround GitLab Public Key 將
Public Key 寫入 指定的虛擬機
預設 權限不足,需要自己調整 SELinux
None
THANKS