Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
40
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
36
Goの時刻に関するテスト/Testing time in Go
kawaken
0
38
AWS Lambda + Go
kawaken
0
33
goaのdesignをラクに書く/Write goa design easily
kawaken
0
29
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
35
Other Decks in Programming
See All in Programming
大規模サイトリビルドの現場から:成功と失敗のリアルな教訓 / Site Rebuild,Real Lessons Learned from Successes and Failures_JJUG Fall 2024
techtekt
0
190
Full stack testing :: basic to basic
up1
1
770
MoQとか勉強会#2 発表資料
yuki_uchida
1
110
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
140
PipeCDの歩き方
kuro_kurorrr
3
140
Gestaltung digitaler Lösungen – Produktions- oder Designprozess?
techstories
0
120
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2.3k
社内活動の取り組み紹介 ~ スリーシェイクでこんな取り組みしてます ~
bells17
0
360
Develop iOS apps with Neovim / vimconf_2024
uhooi
1
120
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
410
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
820
Swift Testing - iPlayground
chiaoteni
0
130
Featured
See All Featured
Designing for Performance
lara
604
68k
The Cult of Friendly URLs
andyhume
78
6.1k
Embracing the Ebb and Flow
colly
84
4.5k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Code Reviewing Like a Champion
maltzj
520
39k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
870
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Visualization
eitanlees
145
15k
Being A Developer After 40
akosma
87
590k
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/