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
Pyvmomiとansibleのdynamic inventory
Search
Kentaro Kawano
October 22, 2014
Programming
0
46
Pyvmomiとansibleのdynamic inventory
大阪Pythonユーザの集まり 2014/10
http://osakapy.connpass.com/event/8994/
Kentaro Kawano
October 22, 2014
Tweet
Share
More Decks by Kentaro Kawano
See All by Kentaro Kawano
Goでのレシーバーとnilの関係 / Receiver and nil relationship in Go
kawaken
0
390
Starting Python
kawaken
0
39
Goの時刻に関するテスト/Testing time in Go
kawaken
0
42
AWS Lambda + Go
kawaken
0
36
goaのdesignをラクに書く/Write goa design easily
kawaken
0
33
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
38
Other Decks in Programming
See All in Programming
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
return文におけるstd::moveについて
onihusube
1
750
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
530
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
200
.NET 9アプリをCGIとして レンタルサーバーで動かす
mayuki
1
770
良いユニットテストを書こう
mototakatsu
4
1.7k
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Unsuck your backbone
ammeep
669
57k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Statistics for Hackers
jakevdp
796
220k
Speed Design
sergeychernyshev
25
670
Into the Great Unknown - MozCon
thekraken
33
1.5k
Making the Leap to Tech Lead
cromwellryan
133
9k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
It's Worth the Effort
3n
183
28k
Transcript
pyvmomiͱ AnsibleͷDynamic Inventory
ࣗݾհ • Տ݈ଠ࿕(@kawken) • γφδʔϚʔέςΟϯάʢגʣ • ࣄ o WEBΞϓϦ։ൃ ▪
SIͷ͓ࣄ ▪ Ruby on Rails ΛओʹͬͯΔ o ։ൃڥͷվળ ▪ ϨΨγʔͳڥΛϞμϯʹ͢ΔΑ͏ͳ׆ಈ ▪ ࣾͷ։ൃ༻αʔόཧ
Dynamic Inventory ͱʁ • ΠϯϕϯτϦϑΝΠϧʹɺ࣮ߦݖݶ͕༩͞Ε ͍ͯΔͱ࣮ߦ݁ՌΛ༻͢ΔΈ खॱ 1. JSONΛग़ྗ͢ΔεΫϦϓτΛ࡞ ˍ
࣮ߦݖݶ Λ༩ 2. ΠϯϕϯτϦϑΝΠϧͱͯ͠εΫϦϓτΛࢦఆ ͢Δ ansible-playbook -i hosts.py site.yml
Dynamic Inventory ͷϧʔϧ • εΫϦϓτpythonҎ֎ͰOK • --list, --host ͷίϚϯυϥΠϯҾ͕ͬͯ͘Δ o
σϑΥϧτ --list o ϗετ͕ࢦఆ͞Ε͍ͯΔͱ͖ --host • εΫϦϓτ༻ͷઃఆϑΝΠϧ iniϑΝΠϧ͕ਪ ʁ • ࣮ߦ࣌ʹઃఆ͍ͨ͠ڥมͰ͢Ҏ֎ͳ ͦ͞͏ https://github.com/ansible/ansible/tree/devel/plugins/inventory
pyvmomiͱʁ • VMware vSphere APIͷPythonόΠϯσΟϯά o VMware vSphere APIͱ ▪
VMware ESXͳͲͰཧ͍ͯ͠ΔԾϗετΛૢ ࡞ • VMwareެࣜ o https://github.com/vmware/pyvmomi • VMOMI o Virtualization Management Object Management Infrastructure • ಡΈํ…ʁ
pyvmomiͷαϯϓϧ https://github.com/vmware/pyvmomi/blob/master/sample/ poweronvm.py#L116 ͳ͔ͥ3εϖʔεͳͷ͕ͭΒ͍
͍Ͳ͜Ζ • ࣾͷ։ൃ༻αʔόͷߏஙʢVMwareʣ 1. pyvmomiͰԾϚγϯߏங 2. CentOSͷkickstartͰࣗಈΠϯετʔϧ 3. AnsibleͰϓϩϏδϣχϯά DHCPͷͨΊFQDNͱIP͕Θ͔Βͳ͍ͷͰɺ
pyvmomiͰVMwareͷཧ໊͔ΒIPΛऔಘ͍ͯ͠Δ TARGET_HOST="$vmname" ansible-playbook -i target.py site.yml
target.pyͷ࣮ߦ݁Ռ $ TARGET_HOST=sample.local vmware/target.py { "all": { "hosts": [ "192.168.0.123"
], "vars": { "target_hostname": "sample.local" } } }
·ͱΊ • Dynamic Inventory o ؆୯ͳεΫϦϓτ͔Β࢝ΊΒΕΔ o VMWareAWS্ʹߏங͞ΕͨɺIPEnd Point͕Θ ͔Βͳ͍Α͏ͳαʔόΛಛఆͯ͠ɺϓϩϏδϣχϯ
ά͢Δ͜ͱ͕Ͱ͖Δ • pyvmomi o pyvmomiVMwareͷૢ࡞͕؆୯ʹͰ͖Δ o αϯϓϧΛݟΔͱԿͱͳ͘Θ͔ΔͷͰɺPython͕Θ ͔Ε؆୯
ࢀߟ AnsibleެࣜυΩϡϝϯτ Dynamic Inventory ͷઆ໌ http://docs.ansible.com/intro_dynamic_inventory.html εΫϦϓτͷ࡞Γํ http://docs.ansible.com/developing_inventory.html Dyanmic Inventory
ͷαϯϓϧ https://github.com/ansible/ansible/tree/devel/plugins/inventory pyvmomi https://github.com/vmware/pyvmomi VMOMI https://github.com/vmware/pyvmomi/wiki/VMOMI VMware vSphere Web Services SDK Documentation https://www.vmware.com/ support/developer/vc-sdk/