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
31
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
350
Starting Python
kawaken
0
28
Goの時刻に関するテスト/Testing time in Go
kawaken
0
25
AWS Lambda + Go
kawaken
0
25
goaのdesignをラクに書く/Write goa design easily
kawaken
0
25
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
29
Other Decks in Programming
See All in Programming
いつか使える ObjectSpace / Maybe useful ObjectSpace
euglena1215
2
130
オートマトン学習しろ / Do automata learning
makenowjust
3
110
デザインシステムとコンポーネント指向によるフロントエンド開発プロセスの革新 / Innovation in Frontend Development Processes through Design Systems and Component-Oriented Architecture
nrslib
8
5.3k
What you can do with Ruby on WebAssembly
kateinoigakukun
0
120
Go Code Generation at newmo / 2024-08-27 #newmo_layerx_go
genkey6
0
550
Architecture Decision Record (ADR)
nearme_tech
PRO
1
650
開発を加速する共有Swift Package実践
elmetal
PRO
0
380
Amazon BedrockでサーバレスなAIお料理ボットを作成する!!
tosuri13
0
180
rails_girls_is_my_gate_to_join_the_ruby_commuinty
maimux2x
0
180
Rubyとクリエイティブコーディングの輪の広がり / The Growing Circle of Ruby and Creative Coding
chobishiba
1
240
RAGの回答精度評価用のQAデータセットを生成AIに作らせた話
kurahara
0
240
Regular Expressions, REXML, Automata Learning
makenowjust
0
190
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
35
6.8k
Creatively Recalculating Your Daily Design Routine
revolveconf
215
12k
A designer walks into a library…
pauljervisheath
201
24k
Optimising Largest Contentful Paint
csswizardry
29
2.8k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.8k
A better future with KSS
kneath
235
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
Designing with Data
zakiwarfel
98
5k
Intergalactic Javascript Robots from Outer Space
tanoku
268
26k
GitHub's CSS Performance
jonrohan
1029
450k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Automating Front-end Workflow
addyosmani
1365
200k
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/