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
38
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
380
Starting Python
kawaken
0
32
Goの時刻に関するテスト/Testing time in Go
kawaken
0
36
AWS Lambda + Go
kawaken
0
31
goaのdesignをラクに書く/Write goa design easily
kawaken
0
27
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
34
Other Decks in Programming
See All in Programming
Quine, Polyglot, 良いコード
qnighy
4
640
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
みんなでプロポーザルを書いてみた
yuriko1211
0
260
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
860
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Outline View in SwiftUI
1024jp
1
320
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
Featured
See All Featured
Being A Developer After 40
akosma
86
590k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Code Review Best Practice
trishagee
64
17k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Making Projects Easy
brettharned
115
5.9k
Visualization
eitanlees
145
15k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Into the Great Unknown - MozCon
thekraken
32
1.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Designing the Hi-DPI Web
ddemaree
280
34k
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/