Ashish Jaiswal Blog

A blog dedicated to community

Automate Installation of Perl Modules Using Cpanminus Manager

This manifest will help you to install perl libraries directly from cpan, You can set you cpan local repository or you can use any cpan mirror out there. All I did is created a defination to install the perl libraries from cpan repository.

Terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Install perl modules from cpan

class cpan {
  
  package { [ 'perl-YAML-Perl', 'perl-Error', 'perl-CPAN-DistnameInfo', 'perl-CPAN-Meta-Check',
      'perl-File-pushd', 'perl-local-lib', 'perl-Module-CPANfile', 'perl-App-cpanminus',
      'perl-aliased', 'make' ] : ensure => present }

  define perl ( $cpan_repo = "http://mirror.teklinks.com/CPAN/") {
      exec { "$name" :
          command => "cpanm --mirror $cpan_repo --mirror-only $name",
          require => Package["make", "perl-App-cpanminus" ],
          unless => "perldoc -l $name" }
  } # End of cpan_perl
} #End of perl

You can add like this in your example.pp

Terminal
1
cpan::perl { "Text::ASCIITable" :  }

Comments