フレームワークでシステム管理アプリケーションプログラミングをもっと簡単に
About me <ul><li>Gosuke Miyashita </li></ul><ul><ul><li>mizzy.org </li></ul></ul><ul><li>Working at paperboy&co. </li></ul...
With lots of Dr.Peppers
 
System Admin Application Framework? <ul><li>A framework for system admin app </li></ul><ul><ul><li>WAF for sysadmin </li><...
System Admin Application? <ul><li>Basically “Exec some operations for multiple hosts” </li></ul><ul><li>Easy to say, but ....
Framework? <ul><li>Hide the issues on previous page and you can concentrate for your really job </li></ul><ul><li>Selectin...
Framework? (cont.) <ul><li>Getting results and parse them </li></ul><ul><ul><li>Scalar, hash or array via JSON-RPC </li></...
Framework! <ul><li>use Punc::Client; </li></ul><ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul><li>my $res  = $...
 
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 RedH...
Architecture of Punc get a result call a module exec a module exec a module exec a module JSON-RPC over HTTPS + SSLv3 auth...
<ul><li>See http://coderepos.org/share/wiki/Punc </li></ul>
Checkout Punc <ul><li>$  svn co http://svn.coderepos.org/share/lang/perl/Punc/trunk Punc </li></ul><ul><li>$ cd Punc </li>...
Start puncmasterd <ul><li>; Create self-signed cert  </li></ul><ul><li>; automatically and start with https </li></ul><ul>...
Start puncd <ul><li>$ ./bin/puncd </li></ul><ul><li>(Request  a CSR to puncmaster and waiting it signed) </li></ul>
Sign to the CSR <ul><li>$ ./bin/puncmaster-ca --list </li></ul><ul><li>host.example.com </li></ul><ul><li>$ ./bin/puncmast...
Now puncd working! <ul><li>$ ./bin/puncd </li></ul><ul><li>Please contact me at: <URL:https://host.example.com:7080/> </li...
Use Punc with punc command <ul><li>$ ./bin/punc  &quot;*&quot;  call  service   description </li></ul><ul><li>NAME </li></...
Use Punc with Punc::Client <ul><li>use Punc::Client; </li></ul><ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul>...
 
virt module(not yet exist) <ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul><li>my $res  = $punc-> virt -> state...
smart module(not yet exist) <ul><li>my $punc  = Punc::Client->new( '*' ); </li></ul><ul><li>my $result = $punc-> smart -> ...
 
Punc module <ul><li>Module is distributed and executed on each targeted hosts </li></ul><ul><li>Master host calls modules ...
Architecture of Punc(again) get a result call a module exec a module exec a module exec a module JSON-RPC over HTTPS + SSL...
file module <ul><li>package Punc::Slave::Module::File; </li></ul><ul><li>use Path::Class qw( dir file ); </li></ul><ul><li...
service module(for Red Hat) <ul><li>package Punc::Slave::Module::Service::RedHat; </li></ul><ul><li>use Punc::Slave::Modul...
service module(for Debian) <ul><li>package Punc::Slave::Module::Service::Debian; </li></ul><ul><li>use Punc::Slave::Module...
Abstraction layer with Pfacter <ul><li>Automatically detect a targeted host’s environmant and execute a adequate module </...
Return values of a module <ul><li># return scalar, hash ref, or array ref on success </li></ul><ul><li>return $result;  </...
Module sync <ul><li>Mosules must be distributed to slaves </li></ul><ul><li>Punc has punc-modulesync command </li></ul><ul...
Summary <ul><li>Punc is a framework for sysatem admin app programming </li></ul><ul><li>Modules are executed on each slave...
Development in progress <ul><li>Code repository is in CodeRepos </li></ul><ul><ul><li>http://coderepos.org/share/ </li></u...
 
Upcoming SlideShare
Loading in...5
×

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

3,856

Published on

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

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

No notes for slide

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

  1. 1. フレームワークでシステム管理アプリケーションプログラミングをもっと簡単に
  2. 2. About me <ul><li>Gosuke Miyashita </li></ul><ul><ul><li>mizzy.org </li></ul></ul><ul><li>Working at paperboy&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. 3. With lots of Dr.Peppers
  4. 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>
  5. 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>
  6. 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->new( ‘*’ ); </li></ul></ul><ul><ul><li>$punc = Punc::Client->new( ‘www*’ ); </li></ul></ul><ul><li>Connect to target hosts and security </li></ul><ul><ul><li>$res = $punc-> service -> status ({ service => ‘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>
  7. 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-> service -> status (); </li></ul></ul><ul><ul><li>Programming with combination of small modules </li></ul></ul>
  8. 9. Framework! <ul><li>use Punc::Client; </li></ul><ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul><li>my $res = $punc-> service -> status ({ </li></ul><ul><li>service => 'httpd' </li></ul><ul><li>}); </li></ul><ul><li>while ( my $r = $res->next ) { </li></ul><ul><li>Punc::Client->new( $r->host ) </li></ul><ul><li>-> service -> start ({ </li></ul><ul><li>service => 'httpd' </li></ul><ul><li>}) if $r->result; </li></ul><ul><li>} </li></ul>
  9. 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>
  10. 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)
  11. 13. <ul><li>See http://coderepos.org/share/wiki/Punc </li></ul>
  12. 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>
  13. 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: <URL:https://host.example.com:7081/> </li></ul>
  14. 16. Start puncd <ul><li>$ ./bin/puncd </li></ul><ul><li>(Request a CSR to puncmaster and waiting it signed) </li></ul>
  15. 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>
  16. 18. Now puncd working! <ul><li>$ ./bin/puncd </li></ul><ul><li>Please contact me at: <URL:https://host.example.com:7080/> </li></ul>
  17. 19. Use Punc with punc command <ul><li>$ ./bin/punc &quot;*&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 &quot;*&quot; call service status --service=httpd </li></ul><ul><li># with Punc::Client module </li></ul><ul><li>my $punc = Punc::Client->new($target); </li></ul><ul><li>my $res = $punc->service->status({ service => 'httpd' }); </li></ul><ul><li>... </li></ul>
  18. 20. Use Punc with Punc::Client <ul><li>use Punc::Client; </li></ul><ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul><li>my $res = $punc-> service -> status ({ </li></ul><ul><li>service => 'httpd‘ </li></ul><ul><li>}); </li></ul><ul><li>while ( my $r = $res->next ) { </li></ul><ul><li>Punc->new($r->host)- >service </li></ul><ul><li>-> start ({ service => 'httpd' }) </li></ul><ul><li>if $r->result; </li></ul><ul><li>} </li></ul>
  19. 22. virt module(not yet exist) <ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul><li>my $res = $punc-> virt -> state ; </li></ul><ul><li>while ( my $r = $res->next ) { </li></ul><ul><li>next if $r->error; </li></ul><ul><li>for my $vm ( @{ $r->vms } ) { </li></ul><ul><li>if ( $vm->{state} eq 'shutdown' ) { </li></ul><ul><li>Punc->new($r->host)-> virt </li></ul><ul><li>-> create ($vm->{domain}) </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  20. 23. smart module(not yet exist) <ul><li>my $punc = Punc::Client->new( '*' ); </li></ul><ul><li>my $result = $punc-> smart -> info ; </li></ul><ul><li>while ( my $r = $result->next ) { </li></ul><ul><li>unless ( $r->code ) { </li></ul><ul><li>print &quot;$r->host has error: &quot;; </li></ul><ul><li>print $r->detail . &quot; &quot;; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  21. 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>
  22. 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)
  23. 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 => [ 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->{file}`; </li></ul><ul><li>} </li></ul><ul><li>sub copy { </li></ul><ul><li>... </li></ul>
  24. 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 => [ qw / redhat centos fedora / ] </li></ul><ul><li>}; </li></ul><ul><li>use Moose; </li></ul><ul><li>with 'Punc::Slave::Module::Service::Role'; </li></ul><ul><li>sub status { </li></ul><ul><li>my ( $self, $args ) = @_; </li></ul><ul><li>return $self->_command($args->{service}, 'status'); </li></ul><ul><li>} </li></ul>
  25. 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 => [ qw / debian ubuntu / ] </li></ul><ul><li>}; </li></ul><ul><li>use Moose; </li></ul><ul><li>with 'Punc::Slave::Module::Service::Role'; </li></ul><ul><li>sub status { </li></ul><ul><li>my ( $self, $args ) = @_; </li></ul><ul><li>return $self->_command($args->{service}, 'status'); </li></ul><ul><li>} </li></ul>
  26. 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>
  27. 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->error(‘error message’); </li></ul>
  28. 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>
  29. 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>
  30. 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>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×