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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
蒼時弦や
December 07, 2019
Programming
640
1
Share
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
200
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
220
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
470
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
680
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
440
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
510
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
530
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
280
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
320
Other Decks in Programming
See All in Programming
Programming with a DJ Controller — not vibe coding
m_seki
3
100
今こそ押さえておきたい アマゾンウェブサービス(AWS)の データベースの基礎 おもクラ #6版
satoshi256kbyte
1
250
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
970
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
140
AIエージェントで業務改善してみた
taku271
0
530
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
240
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
190
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
790
GitHubCopilotCLIをはじめよう.pdf
htkym
0
180
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
520
Vibe NLP for Applied NLP
inesmontani
PRO
0
430
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
570
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
760
GitHub's CSS Performance
jonrohan
1032
470k
Evolving SEO for Evolving Search Engines
ryanjones
0
180
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
230
Deep Space Network (abreviated)
tonyrice
0
120
The Cult of Friendly URLs
andyhume
79
6.8k
A better future with KSS
kneath
240
18k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
160
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
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