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

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Event

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

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

    + mizzymizzy, 2 years ago

    custom

    2663 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2663
      • 2663 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 20
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events