Demystify file system hierarchy for deployments


jkutej@cpan.org
16 August 2011

What to expect?

What to expect?

Why?

Why this talk?

Why should you care?

Why me?

Why so many questions?

package Acme::KnowledgeWisdom;
use Moose;
use warnings FATAL => 'all';

has 'in_questions' => ( isa => 'Bool', is => 'ro', default => 1);
has 'has_already'  => ( isa => 'Bool', is => 'ro', default => 0);

sub get {
    my $kw = shift;
    return $kw->ask
        if $kw->in_questions;
    return 42;
}
sub ask {
    my $self = shift;
    return 42
        if $self->has_already;
    my $kw = Acme::KnowledgeWisdom->new;
    return $kw->get;
}
	

1. OS for you

Demystify file system

Why not to fear OS?

OS

So OS is just a bunch of files in different folders or a collection that has no special meaning besides making our project to run, to be live.

OS is that stuff that we need for our project.

What do we need from OS?

Where is Perl?

Where are configurtion and data files?

http://perlmonks.org/?node_id=919265

Filesystem Hierarchy Standard

OS is there for our project!

2. Perl code and deployments

How to install Perl code?

Perl code layers

Perl code life-cycle ♲

☎ customer ☘ sales ⚔ negotiations ☐ specification ✍ contract ⚒ developer ☢ development machine ☀ version control ☔ user-acceptance machine ☇ quality assurance review ☠ customer review ☃ release tag 𝄞 packaging (tarball||dist) ★ staging machine ☇ quality assurance review ☑ deployment ☇☈ quality assurance review ☕ another job well done ☻ happy customer ☻☺ more customers $€₤¥ money && ♥♡♥♡ our job

How many server types did you count?

Depends on scale...

minimalist
dev (laptop) + prod = 1
minimal
dev (laptop) + uat&staging + 2x prod = 3
full
1 x dev + code + uat + 2x staging + 2x prod = 6
bigger
? x dev + code + batch + uat + 8x staging + 8x prod = ~20
making $€₤¥
? x dev + code + batch + monitoring + ~4x uat + 8x staging + ~30x prod = >50

Prod?

dev
laptops for mobility while developing, for bigger projects also shared dev servers needed
code
code repository, DPAN, Pod, wiki?, Debian repo, batch results
batch
auto packaging (.tar.gz, .deb), smoke-testing, statistics processing
monitoring
ops maintenance server
uat
all prod stuff on one server
staging
mirror of the prod servers, where deployment is tested and verified
production
(all redundant) - load balancers, servers with interface for registered users, servers for anonymous clients, batch processing servers, database servers, storage servers

3. Related Perl modules

Why Sys::Path?

$Config::Config{'prefix'}
eq
'/usr'

Sys::Path

supply autoconf style installation directories

say Sys::Path->sysconfdir;
# /etc
say Sys::Path->datadir;
# /usr/share
say Sys::Path->logdir;
# /var/log

say Sys::Path->sysconfdir;
# /home/daxim/local/etc
say Sys::Path->datadir;
# /home/daxim/local/share
say Sys::Path->logdir;
# /home/daxim/local/log
	

Why Module::Build::SysPath?

Module::Build::SysPath

Build.PL

my $builder = Module::Build::SysPath->new(
    module_name        => 'Debian::Apt::PM',
	configure_requires => {
		'Module::Build::SysPath' => 0.13,
	},
	

Module::Build::SysPath

YourApp::SPc

sub prefix { ↲
	use Sys::Path; ↲
	Sys::Path->find_distribution_root(__PACKAGE__); ↲
};
sub localstatedir ↲
{ __PACKAGE__->prefix }; ↲
sub sysconfdir ↲
{ File::Spec->catdir(__PACKAGE__->prefix, 'etc') };
sub datadir ↲
{ File::Spec->catdir(__PACKAGE__->prefix, 'share') };
sub cachedir ↲
{ File::Spec->catdir(__PACKAGE__->localstatedir, 'cache') };
sub logdir ↲
{ File::Spec->catdir(__PACKAGE__->localstatedir, 'log') };
...
	

Module::Build::SysPath

YourApp::SPc after install

sub prefix { ↲
	use Sys::Path; ↲
	Sys::Path->find_distribution_root(__PACKAGE__); ↲
};
sub sysconfdir {'/etc'}
sub datadir {'/usr/share'};
sub cachedir {'/var/cache'};
sub sharedstatedir {'/var/lib'};
	

Sys::Path Module::Build::SysPath bonus => /etc

CPAN::Mini::Inject

CPAN::Mini::Webserver

Pod::POM::Web + trick

Debian::Apt::PM

CPAN::Patches

Sum up

What's the vision?

Thanks!
Any answers?