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
88
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
450
Starting Python
kawaken
0
79
Goの時刻に関するテスト/Testing time in Go
kawaken
0
85
AWS Lambda + Go
kawaken
0
83
goaのdesignをラクに書く/Write goa design easily
kawaken
0
80
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
86
Other Decks in Programming
See All in Programming
20250808_AIAgent勉強会_ClaudeCodeデータ分析の実運用〜競馬を題材に回収率100%の先を目指すメソッドとは〜
kkakeru
0
200
ライブ配信サービスの インフラのジレンマ -マルチクラウドに至ったワケ-
mirrativ
1
260
AHC051解法紹介
eijirou
0
620
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
950
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
190
The State of Fluid (2025)
s2b
0
190
レガシープロジェクトで最大限AIの恩恵を受けられるようClaude Codeを利用する
tk1351
2
590
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
13
7k
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
200
DynamoDBは怖くない!〜テーブル設計の勘所とテスト戦略〜
hyamazaki
1
210
あのころの iPod を どうにか再生させたい
orumin
2
2.5k
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
2
790
Featured
See All Featured
Gamification - CAS2011
davidbonilla
81
5.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
183
54k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
560
Scaling GitHub
holman
462
140k
Designing Experiences People Love
moore
142
24k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Side Projects
sachag
455
43k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
The Pragmatic Product Professional
lauravandoore
36
6.8k
Writing Fast Ruby
sferik
628
62k
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/