Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Based on some code from this blog and in the comments I'm trying to define some simple CPAN install functionality for Puppet, and I'm trying this:

class perl {
  define install-cpan () {
    exec { "cpan_load_${name}":
      command => "perl -I.cpan -MCPAN -e '\$ENV{PERL_MM_USE_DEFAULT}=1; install $name'",
      cwd => "/root",
      path => "/usr/bin:/usr/sbin:/bin:/sbin",
      unless => "perl -M$name -e 1",
    }
  }
  package { 'perl': ensure => installed }

}

perl::install-cpan { "Bundle::CPAN": }

But I get this error:

err: Could not retrieve catalog from remote server: Could not intern
from pson: Could not convert from pson: Could not find relationship
target "Perl::Install-cpan[Bundle::CPAN]"

What does this mean and how do I fix it?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I've actually decided to go with cpanminus over cpan, and am using:

# perl/manifests/init.pp

class perl {

  define installCPAN () {
    exec { "cpanLoad${title}":
      command => "cpanm $name",
      path    => "/usr/bin:/usr/sbin:/bin:/sbin",
      unless  => "perl -I.cpan -M$title -e 1",
      timeout => 600,
      require => Exec["initCPAN"],
    }
  }

  package { "perl": ensure => installed, require => Class["common"] }
  exec { "initCPAN":
    command =>  "wget -O - http://cpanmin.us | perl - --self-upgrade",
    path    => "/usr/bin:/usr/sbin:/bin:/sbin",
    creates  => "/bin/cpanm",
    require => [ Class["common"], Package["perl"] ],
  }
  # E.g.
  installCPAN { "JSON": }
  installCPAN { "JSON::XS": }
}
share|improve this answer

The major error seems to be the "-" in the name "install-cpan". The following does work though, and the INIT_CPAN command can be found at How do I automate CPAN configuration?.

# perl/manifests/init.pp

class perl {

  define installCPAN () {
    exec { "cpanLoad${title}":
      command => "perl -MCPAN -e 'install(q[$name])'",
      cwd     => "/root",
      path    => "/usr/bin:/usr/sbin:/bin:/sbin",
      unless  => "perl -I.cpan -M$name -e 1",
      timeout => 600,
      environment => [
        "PERL_MM_USE_DEFAULT=1",
        "PERL_MM_NONINTERACTIVE=1",
        "AUTOMATED_TESTING=1",
      ],
    }
  }

  package { "perl": ensure => installed, require => Class["common"] }
  file { "initCPANcmd":
    source => "puppet://puppet/perl/INIT_CPAN",
    path   => "/root/INIT_CPAN",
    owner  => "root",
    mode   => 700,
  }
  exec { "initCPAN":
    command =>  "/root/INIT_CPAN",
    cwd     => "/root",
    path    => "/usr/bin:/usr/sbin:/bin:/sbin",
    creates  => "/root/.cpan/CPAN/MyConfig.pm",
    require => [ File["initCPANcmd"], Package["perl"] ],
  }

  perl::installCPAN { "Bundle::CPAN": require => Exec["initCPAN"] }

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.