Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Pyvmomiとansibleのdynamic inventory

2,407 views

Published on

Pyvmomiとansibleのdynamic inventory

大阪Pythonユーザの集まり 2014/10
http://osakapy.connpass.com/event/8994/

Published in: Software
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ...................................ALL FOR EBOOKS................................................. Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • ACCESS that WEBSITE Over for All Ebooks (Unlimited) ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... DOWNLOAD FULL EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M }
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Pyvmomiとansibleのdynamic inventory

  1. 1. pyvmomiと AnsibleのDynamic Inventory
  2. 2. 自己紹介 ● 河野健太朗(@kawken) ● シナジーマーケティング(株) ● 仕事 o WEBアプリ開発  SIのお仕事  Ruby on Rails を主に使ってる o 開発環境の改善  レガシーな環境をモダンにするような活動  社内の開発用サーバ管理
  3. 3. Dynamic Inventory とは? ● インベントリファイルに、実行権限が付与 されていると実行結果を使用する仕組み 手順 1. JSONを出力するスクリプトを作成& 実行 権限を付与 2. インベントリファイルとしてスクリプトを 指定する ansible-playbook -i hosts.py site.yml
  4. 4. Dynamic Inventory のルール ● スクリプトはpython以外でもOK ● --list, --host のコマンドライン引数が渡って くる o デフォルトは--list o ホストが指定されているときは--host ● スクリプト用の設定ファイルはiniファイル が推奨? ● 実行時に設定したい値は環境変数で渡す以 外なさそう https://github.com/ansible/ansible/tree/devel/plugins/inventory
  5. 5. 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 ● 読み方は…?
  6. 6. pyvmomiのサンプル https://github.com/vmware/pyvmomi/blob/master/sample/poweronvm.py# L116 なぜか3スペースなのがつらい
  7. 7. 使いどころ ● 社内の開発用サーバの構築(VMware) 1. pyvmomiで仮想マシン構築 2. CentOSのkickstartで自動インストール 3. Ansibleでプロビジョニング DHCPのためFQDNとIPがわからないので、 pyvmomiでVMwareの管理名からIPを取得している TARGET_HOST="$vmname" ansible-playbook -i target.py site.yml
  8. 8. target.pyの実行結果 $ TARGET_HOST=sample.local vmware/target.py { "all": { "hosts": [ "192.168.0.123" ], "vars": { "target_hostname": "sample.local" } } }
  9. 9. まとめ ● Dynamic Inventory o 簡単なスクリプトから始められる o VMWareやAWS上に構築された、IPやEnd Pointが わからないようなサーバを特定して、プロビジョニ ングすることができる ● pyvmomi o pyvmomiはVMwareの操作が簡単にできる o サンプルを見ると何となくわかるので、Pythonがわ かれば簡単
  10. 10. 参考 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/

×