Your SlideShare is downloading. ×
0
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Yapc::Asia 2008 Tokyo - Easy system administration programming with a framework by Gosuke Miyashita

3,818

Published on

Published in: Technology, Art & Photos
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,818
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
28
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. フレームワークでシステム管理アプリケーションプログラミングをもっと簡単に
  • 2. About me <ul><li>Gosuke Miyashita </li></ul><ul><ul><li>mizzy.org </li></ul></ul><ul><li>Working at paperboy&amp;co. </li></ul><ul><li>Recently, released the photo album service “30days album” (http://30d.jp/) </li></ul><ul><ul><li>Total technical design, storage api programming, server settings </li></ul></ul><ul><li>I love Dr.Pepper </li></ul>
  • 3. With lots of Dr.Peppers
  • 4. &nbsp;
  • 5. System Admin Application Framework? <ul><li>A framework for system admin app </li></ul><ul><ul><li>WAF for sysadmin </li></ul></ul><ul><li>Func (Fedora Unified Network Controller) is a kind of it </li></ul><ul><ul><li>Although Func deoesn’t describe itself a framework </li></ul></ul><ul><ul><li>I’m devloping Punc, a perl colne of Func. </li></ul></ul>
  • 6. System Admin Application? <ul><li>Basically “Exec some operations for multiple hosts” </li></ul><ul><li>Easy to say, but ... </li></ul><ul><ul><li>How to select target hosts? </li></ul></ul><ul><ul><li>How to connect to target hosts? </li></ul></ul><ul><ul><li>How about security? </li></ul></ul><ul><ul><li>How about getting results and parsing them </li></ul></ul><ul><ul><li>How to reuse codes? </li></ul></ul>
  • 7. Framework? <ul><li>Hide the issues on previous page and you can concentrate for your really job </li></ul><ul><li>Selecting target hosts? </li></ul><ul><ul><li>$punc = Punc::Client-&gt;new( ‘*’ ); </li></ul></ul><ul><ul><li>$punc = Punc::Client-&gt;new( ‘www*’ ); </li></ul></ul><ul><li>Connect to target hosts and security </li></ul><ul><ul><li>$res = $punc-&gt; service -&gt; status ({ service =&gt; ‘httpd’ }); </li></ul></ul><ul><ul><li>You can get the status of httpd of all taget hosts. </li></ul></ul><ul><ul><li>Behind it, JSON-RPC over HTTPS + SSLv3 Auth </li></ul></ul>
  • 8. Framework? (cont.) <ul><li>Getting results and parse them </li></ul><ul><ul><li>Scalar, hash or array via JSON-RPC </li></ul></ul><ul><li>Reusability of code </li></ul><ul><ul><li>Punc consists of small modules. </li></ul></ul><ul><ul><li>$punc-&gt; service -&gt; status (); </li></ul></ul><ul><ul><li>Programming with combination of small modules </li></ul></ul>
  • 9. Framework! <ul><li>use Punc::Client; </li></ul><ul><li>my $punc = Punc::Client-&gt;new( &apos;*&apos; ); </li></ul><ul><li>my $res = $punc-&gt; service -&gt; status ({ </li></ul><ul><li>service =&gt; &apos;httpd&apos; </li></ul><ul><li>}); </li></ul><ul><li>while ( my $r = $res-&gt;next ) { </li></ul><ul><li>Punc::Client-&gt;new( $r-&gt;host ) </li></ul><ul><li>-&gt; service -&gt; start ({ </li></ul><ul><li>service =&gt; &apos;httpd&apos; </li></ul><ul><li>}) if $r-&gt;result; </li></ul><ul><li>} </li></ul>
  • 10. &nbsp;
  • 11. Punc <ul><li>A perl clone of Func </li></ul><ul><li>Why I’m developing Punc? </li></ul><ul><ul><li>Func only works on RedHat linux </li></ul></ul><ul><ul><li>Func does not have abstract layer of different environments </li></ul></ul><ul><ul><li>I LOVE Perl! </li></ul></ul>
  • 12. Architecture of Punc get a result call a module exec a module exec a module exec a module JSON-RPC over HTTPS + SSLv3 auth Manage target hosts Manage SSL certs master (puncmasterd) slave (puncd) slave (puncd) slave (puncd)
  • 13. <ul><li>See http://coderepos.org/share/wiki/Punc </li></ul>
  • 14. Checkout Punc <ul><li>$ svn co http://svn.coderepos.org/share/lang/perl/Punc/trunk Punc </li></ul><ul><li>$ cd Punc </li></ul>
  • 15. Start puncmasterd <ul><li>; Create self-signed cert </li></ul><ul><li>; automatically and start with https </li></ul><ul><li>$ ./bin/puncmasterd </li></ul><ul><li>Please contact me at: &lt;URL:https://host.example.com:7081/&gt; </li></ul>
  • 16. Start puncd <ul><li>$ ./bin/puncd </li></ul><ul><li>(Request a CSR to puncmaster and waiting it signed) </li></ul>
  • 17. Sign to the CSR <ul><li>$ ./bin/puncmaster-ca --list </li></ul><ul><li>host.example.com </li></ul><ul><li>$ ./bin/puncmaster-ca --sign host.example.com </li></ul>
  • 18. Now puncd working! <ul><li>$ ./bin/puncd </li></ul><ul><li>Please contact me at: &lt;URL:https://host.example.com:7080/&gt; </li></ul>
  • 19. Use Punc with punc command <ul><li>$ ./bin/punc &amp;quot;*&amp;quot; call service description </li></ul><ul><li>NAME </li></ul><ul><li>Punc::Slave::Module::Service - Punc module for service control. </li></ul><ul><li>SYNOPSIS </li></ul><ul><li># with punc command </li></ul><ul><li>$ sudo punc &amp;quot;*&amp;quot; call service status --service=httpd </li></ul><ul><li># with Punc::Client module </li></ul><ul><li>my $punc = Punc::Client-&gt;new($target); </li></ul><ul><li>my $res = $punc-&gt;service-&gt;status({ service =&gt; &apos;httpd&apos; }); </li></ul><ul><li>... </li></ul>
  • 20. Use Punc with Punc::Client <ul><li>use Punc::Client; </li></ul><ul><li>my $punc = Punc::Client-&gt;new( &apos;*&apos; ); </li></ul><ul><li>my $res = $punc-&gt; service -&gt; status ({ </li></ul><ul><li>service =&gt; &apos;httpd‘ </li></ul><ul><li>}); </li></ul><ul><li>while ( my $r = $res-&gt;next ) { </li></ul><ul><li>Punc-&gt;new($r-&gt;host)- &gt;service </li></ul><ul><li>-&gt; start ({ service =&gt; &apos;httpd&apos; }) </li></ul><ul><li>if $r-&gt;result; </li></ul><ul><li>} </li></ul>
  • 21. &nbsp;
  • 22. virt module(not yet exist) <ul><li>my $punc = Punc::Client-&gt;new( &apos;*&apos; ); </li></ul><ul><li>my $res = $punc-&gt; virt -&gt; state ; </li></ul><ul><li>while ( my $r = $res-&gt;next ) { </li></ul><ul><li>next if $r-&gt;error; </li></ul><ul><li>for my $vm ( @{ $r-&gt;vms } ) { </li></ul><ul><li>if ( $vm-&gt;{state} eq &apos;shutdown&apos; ) { </li></ul><ul><li>Punc-&gt;new($r-&gt;host)-&gt; virt </li></ul><ul><li>-&gt; create ($vm-&gt;{domain}) </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  • 23. smart module(not yet exist) <ul><li>my $punc = Punc::Client-&gt;new( &apos;*&apos; ); </li></ul><ul><li>my $result = $punc-&gt; smart -&gt; info ; </li></ul><ul><li>while ( my $r = $result-&gt;next ) { </li></ul><ul><li>unless ( $r-&gt;code ) { </li></ul><ul><li>print &amp;quot;$r-&gt;host has error: &amp;quot;; </li></ul><ul><li>print $r-&gt;detail . &amp;quot; &amp;quot;; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  • 24. &nbsp;
  • 25. Punc module <ul><li>Module is distributed and executed on each targeted hosts </li></ul><ul><li>Master host calls modules on targeted hosts via punc command or Punc::Client </li></ul>
  • 26. Architecture of Punc(again) get a result call a module exec a module exec a module exec a module JSON-RPC over HTTPS + SSLv3 auth Manage target hosts Manage SSL certs master (puncmasterd) slave (puncd) slave (puncd) slave (puncd)
  • 27. file module <ul><li>package Punc::Slave::Module::File; </li></ul><ul><li>use Path::Class qw( dir file ); </li></ul><ul><li>use Punc::Slave::Module { </li></ul><ul><li>operatingsystem =&gt; [ qw/ .* / ] </li></ul><ul><li>}; </li></ul><ul><li>sub md5sum { </li></ul><ul><li>my ( $self, $args ) = @_; </li></ul><ul><li>return `md5sum $args-&gt;{file}`; </li></ul><ul><li>} </li></ul><ul><li>sub copy { </li></ul><ul><li>... </li></ul>
  • 28. service module(for Red Hat) <ul><li>package Punc::Slave::Module::Service::RedHat; </li></ul><ul><li>use Punc::Slave::Module::Service { </li></ul><ul><li>operatingsystem =&gt; [ qw / redhat centos fedora / ] </li></ul><ul><li>}; </li></ul><ul><li>use Moose; </li></ul><ul><li>with &apos;Punc::Slave::Module::Service::Role&apos;; </li></ul><ul><li>sub status { </li></ul><ul><li>my ( $self, $args ) = @_; </li></ul><ul><li>return $self-&gt;_command($args-&gt;{service}, &apos;status&apos;); </li></ul><ul><li>} </li></ul>
  • 29. service module(for Debian) <ul><li>package Punc::Slave::Module::Service::Debian; </li></ul><ul><li>use Punc::Slave::Module::Service { </li></ul><ul><li>operatingsystem =&gt; [ qw / debian ubuntu / ] </li></ul><ul><li>}; </li></ul><ul><li>use Moose; </li></ul><ul><li>with &apos;Punc::Slave::Module::Service::Role&apos;; </li></ul><ul><li>sub status { </li></ul><ul><li>my ( $self, $args ) = @_; </li></ul><ul><li>return $self-&gt;_command($args-&gt;{service}, &apos;status&apos;); </li></ul><ul><li>} </li></ul>
  • 30. Abstraction layer with Pfacter <ul><li>Automatically detect a targeted host’s environmant and execute a adequate module </li></ul><ul><li>Punc uses Pfacter for this purpose </li></ul><ul><li>Pfacter is a perl clone of Facter by Ruby </li></ul><ul><li>Facter is used with Puppet </li></ul>
  • 31. Return values of a module <ul><li># return scalar, hash ref, or array ref on success </li></ul><ul><li>return $result; </li></ul><ul><li># return an error using Class::ErrorHandler </li></ul><ul><li>return $self-&gt;error(‘error message’); </li></ul>
  • 32. Module sync <ul><li>Mosules must be distributed to slaves </li></ul><ul><li>Punc has punc-modulesync command </li></ul><ul><li>punc-modulesync made with file module </li></ul>
  • 33. Summary <ul><li>Punc is a framework for sysatem admin app programming </li></ul><ul><li>Modules are executed on each slave node </li></ul><ul><li>Master calls modules via JSON-RPC over HTTPS </li></ul><ul><li>Programming with Punc is a combination of module calls </li></ul><ul><li>Caller programs could be written by langauages other than Perl </li></ul>
  • 34. Development in progress <ul><li>Code repository is in CodeRepos </li></ul><ul><ul><li>http://coderepos.org/share/ </li></ul></ul><ul><ul><li>http://svn.coderepos.org/share/lang/perl/Punc/trunk </li></ul></ul><ul><li>Feel free to commit to trunk or make your branch! </li></ul><ul><li>Please ask yappo if you don’t have a commit bit of CodeRepos </li></ul><ul><li>#coderepos@freenode or #assurer@freenode </li></ul>
  • 35. &nbsp;

×