Git Product home page Git Product logo

puppet-cpan's Introduction

puppet-cpan

Puppet Forge Version Puppet Forge Downloads Travis branch By Meltwater Maintenance license

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with cpan
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how

Overview

Handle installations of cpan modules via puppet.

Module Description

The cpan module sets up capn on a server

Setup

What puppet-cpan affects

  • cpan package.
  • cpan configuration file.

Usage

All options and configuration can be done through interacting with the parameters on the cpan class and the cpan resource type. These are documented below.

cpan class

class {'::cpan':
  manage_config  => true,
  manage_package => true,
  package_ensure => 'present',
  installdirs    => 'site',
  local_lib      => false,
  config_hash    => { 'build_requires_install_policy' => 'no' },
  ftp_proxy      => 'http://your_ftp_proxy.com',
  http_proxy     => 'http://your_http_proxy.com',
  environment    => {
  	'OPTIONAL_ENVIRONMENT_VAR_1' => '1',
  	'OPTIONAL_ENVIRONMENT_VAR_2' => '/foo/bar',
  },
}

Beginning with cpan

include '::cpan'
cpan { "Clone::Closure":
  ensure  => present,
  require => Class['::cpan'],
  force   => true,
}

Package Management

To avoid conflicts with in house package management, use:

class {'::cpan':
  manage_package => false,
}

Install Destination

To control target installation path, use:

class {'::cpan':
  installdirs => 'vendor',
}

Any of site (default), perl and vendor are accepted.

To further control the location of installed modules, you can use local::lib:

cpan { 'Foo::Bar':
  ensure    => present,
  local_lib => '/opt',
}

This will install the module into /opt. Of course you need to adjust @INC of your code in order to use that new location, e.g. by using perl -Mlocal::lib=/opt myapp.pl.

You can also define the default value of local_lib for all cpan resources:

Cpan { local_lib => '/opt' }

Configure a Proxy

class {'::cpan':
  ftp_proxy  => 'http://your_ftp_proxy.com',
  http_proxy => 'http://your_http_proxy.com',
}

Add additional environment variables

Some modules may require additional environment variables to be set e.g. during install, like DBD::Oracle or DBD::DB2.

cpan {'DBD::DB2':
  ensure      => 'latest',
  environment => {
   'DB2_HOME' => '/path/to/DB2,
  }
}

Overriding exists code

Some modules like Sys::RunAlone don't return a code 0 when invoked with perl -M$MODULE_NAME -e1. This means there's no way for puppet to check if they're installed or not (in an agnostic way). Therefore you'll have to change the exists_strategy:

cpan {'Sys::RunAlone':
  ensure => 'present',
  exists_strategy => 'find',
}

Currently two strategies are implemented:

include (default)

Tries to include module:

perl -M$MODULE_NAME

find

Tries to find module in @INC list much like pmpath is doing.

Reference

Classes

  • cpan: Main class for installation and service management.
  • cpan::install: Handles package installation.
  • cpan::params: Different configuration data for different systems.
  • cpan::config: Handles the cpan service.

Parameters

manage_config

manage_package

installdirs

local_lib

config_template

config_hash

package_ensure

ftp_proxy

http_proxy

environment

Limitations

This module has been built on and tested against Puppet 3.x and Puppet 4.x

The module has been tested on:

  • RedHat Enterprise Linux 6/7
  • Debian 6/7
  • CentOS 6/7

Testing on other platforms has been light and cannot be guaranteed.

Maintainer

puppet-cpan's People

Contributors

alexgoodchild avatar alexjfisher avatar becomingwisest avatar brentclark avatar cyberkov avatar dezmodue avatar faxm0dem avatar franknagel avatar geidies avatar ivanmp91 avatar jovandeginste avatar lehme avatar markuskont avatar salimane avatar seanmcl avatar stkerr avatar strangelittlemonkey avatar theevilapplepie avatar wleese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-cpan's Issues

Quotes around case options

I have been going over the git logs and this seems to be something that has flip flopped.

In manifests/init.pp the operating system names in the case statement are no longer in quotes (they were removed in commit 2da0666

Before that the quotes were added in commit a17ae4a

I use puppet 3.8 in Debian 7 and as soon as I change the puppet configuration to have parser = future not having the quotes breaks the module.

Missing basic necessity

I think that this module should ensure that things like make and a c compiler are present on a system, because without that, building a module won't really happen. Unfortunately, this module also doesn't err out when that happens, it just says, "This might take a while." and then comes back thumbs up when it failed to build and install a module because it didn't require any building tools to be present. Can you please adjust for correct error reporting on unsuccessful builds and installations and also include a package ensure for make and a cc. GCC is pretty commonly available even though Clang is growing in popularity. Thank you.

Extra single quotes in cpan.conf.erb

The extra single quotes cause the resulting q[] value to be quoted in the Config.pm file and misinterpreted by cpan.

68c68
<     '<%= k -%>' => 'q[<%= v -%>]',

---
>     '<%= k -%>' => q[<%= v -%>],

Sample usage errors out with missing package_name argument

The required package_name argument of the cpan class is not documented. Using the provided sample config results in the following error:

Class[Cpan]: expects a value for parameter 'package_name'

The source code references this in the cpan::install class which is only mentioned in the docs as "Handles package installation".

What is the correct way to use this module?

module doesn't seem to accept that Class::AccessorMaker is installed, though it is.

I believe the issue lies within the ruby check for inappropriate perl exit code:

#cpan doesn't always provide the right exit code, so we double check
system("perl #{ll} -M#{resource[:name]} -e1 > /dev/null 2>&1")
estatus = $?.exitstatus

with Class::AccessorMaker, because if you call Class::AccessorMaker with that, you'll always get an exit code 255 -- even though it's installed properly.

Is this actually an issue with the AccessorMaker cpan module?

ensure=>latest errors with non-standard versions

calling the cpan provider on a module that has a non-standard or missing version in cpan will error.

Two examples I found were Log::Dispatch::Gelf (version is "v1.3.0", including that leading "v") and "Graph::Directed" (no version is defined).

Current behavior is an error like this:

Error: Could not set 'latest' on ensure: undefined method `[]' for nil:NilClass at 37:/etc/puppet/environments/...
Error: Could not set 'latest' on ensure: undefined method `[]' for nil:NilClass at 37:/etc/puppet/environments/...
Wrapped exception:
undefined method `[]' for nil:NilClass
Error: /Stage[main]/Tbb/Cpan[Log::Dispatch::Gelf]/ensure: change from present to latest failed: Could not set 'latest' on ensure: undefined method `[]' for nil:NilClass at 37:/etc/puppet/environments/...
Error: Could not set 'latest' on ensure: undefined method `[]' for nil:NilClass at 37:/etc/puppet/environments/...
Error: Could not set 'latest' on ensure: undefined method `[]' for nil:NilClass at 37:/etc/puppet/environments/...
Wrapped exception:
undefined method `[]' for nil:NilClass
Error: /Stage[main]/Tbb/Cpan[Graph::Directed]/ensure: change from present to latest failed: Could not set 'latest' on ensure: undefined method `[]' for nil:NilClass at 37:/etc/puppet/environments/...

It seems that a cleaner option would be to either print a notice (something like "could not upgrade: CPAN version could not be determined"), or to silently fail to upgrade.

Also, I think better parsing of the cpan version might help (stripping initial [a-zA-Z]*, or successfully matching a versionless installed module to an undefined version of cpan), and would eliminate the errors in both of these examples.

Problem with automatic run

The module works fine for me, but the changes only get applied if I trigger a puppet run manually.

Is there any requirement for it to be hooked to a tty?

Every time I let it run by itself it fails with:

puppet-agent[1462]: (/Stage[main]/Cpan::Install/Package[gcc]/ensure) created
puppet-agent[1462]: (/Stage[main]/Cpan::Install/Package[perl-CPAN]/ensure) created
puppet-agent[1462]: (/Stage[main]/Cpan::Config/File[/usr/share/perl5/CPAN/Config.pm]) Skipping because of failed dependencies
puppet-agent[1462]: (/Stage[main]/Cpan/Anchor[cpan::end]) Skipping because of failed dependencies

It then does a bunch of other tasks and comes back to this:

puppet-agent[1462]: Installing cpan module Digest::MD5
puppet-agent[1462]: Forcing install for Digest::MD5
puppet-agent[9556]: Starting Puppet client version 7.18.0
puppet-agent[9629]: Run of Puppet configuration client already in progress; skipping (/opt/puppetlabs/puppet/cache/state/agent_catalog_run.lock exists)
puppet-agent[1462]: cpan Digest::MD5 failed with error code 2

Apparently it runs into a lock mid-run.

My resource block is the following:

class { 'cpan':
manage_config => true,
manage_package => true,
package_ensure => 'present',
local_lib => true,
}
[
'Digest::MD5',
'DBI',
'Template',
'MIME::Entity',
'MIME::Types',
'MD5',
'PDF::API2',
'PostScript::Simple',
'File::NFSLock',
'Mail::IMAPClient',
'Email::Valid',
'File::Slurp',
'Time::ParseDate',
].each |$package| {
cpan { $package:
ensure => 'present',
force => true,
}
}

Running cpan install on Darwin

I understand that the module isn't meant to be supported on Mac but I think the issue should be the same for Linux:

perl -MCPAN -e 'CPAN::Shell->force(qw(install ${package}))'

This command would not work when run via Puppet. Do you know by any chance why is it trying to create a CPAN directory in the root space?

mkdir /CPAN: Read-only file system at /usr/local/Cellar/perl/5.34.0/lib/perl5/5.34.0/CPAN/HandleConfig.pm line 601.

I don't seem to be able to find any manuals of required environment variables required by CPAN to run properly, while it is surely missing something to install those modules to a specific directory.

gcc package requirement breaks users who require gcc

Hi.

First, thanks for this package!

I'm having trouble using it though, because I ensure gcc is installed in my modules. including cpan breaks my code, as there are then duplicate definitions. Is there any way to make this configurable, so I can let cpan know gcc is already there?

The same issue holds with perl-CPAN.

Thanks,

Sean

Error installing Sys::RunAlone

Hi,

From what I understand, the module is installed properly but puppet fails to check if it's present or not.

CPAN: Storable loaded ok (v2.41)
Reading '/root/.cpan/Metadata'
  Database was generated on Wed, 29 Mar 2017 06:54:21 GMT
CPAN: Module::CoreList loaded ok (v3.03)
Sys::RunAlone is up to date (0.12).
Error: cpan Sys::RunAlone failed with error code 2
Error: /Stage[main]/Rg_proftpd::Rg_proftpd_install/Cpan[Sys::RunAlone]/ensure: change from absent to present failed: cpan Sys::RunAlone failed with error code 2

After a quick look at the provider code, I think I found the culprit:

# sudo perl -MSys::RunAlone -e1
Add __END__ to end of script '-e' to be able use the features of Sys::RunALone
# echo $?
2

Any idea how to fix? Any workaround I can apply?

Regards,
Vincent

Using deprecated stdlib routines

Recent versions of stdlib have deprecated a bunch of validation routines
The cpan module is using at least one of these (validate_bool)

Error 500 on SERVER: Server Error: Evaluation Error: Unknown function: 'validate_bool'. (file: /etc/puppetlabs/code/environments/production/modules/cpan/manifests/init.pp, line: 54, column: 3)

how/where does it install the module?

ANOTHER EDIT: apparently, using cpan it couldn't find some of the dependencies for the module below while cpanm handled it perfectly. Again, reason was not show, unless I ran cpan manually.

EDIT: Hi, actually that's a problem in the App::ElasticSearch::Utilities. But, my suggestion is to add more logging when it fails. In that case one of the test failed and it wasn't cleared from Puppet results what is the reason it wasn't installed.

Hey,
I have installed the module on my puppet master:

puppet module install meltwater/cpan

And then added to my .pp module file (different module then cpan):

include ::cpan

..... couple of lines lower

cpan { "App::ElasticSearch::Utilities":
    ensure => present
}

when running the puppet agent:

Can't locate App/ElasticSearch/Utilities.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
Notice: /Stage[main]/Profile::Elasticsearch::Node/Cpan[App::ElasticSearch::Utilities]/ensure: created

But the module is not installed. I have noticed all the files are in /.cpan/build/App-ElasticSearch-Utilities-1.3-wqOODF, but I think that the make-install parts didn't take place. I've seen that the install command in your module doesn't do anything, is that connected?
I am running RedHat 6 and perl version v5.10.1, puppet v3.3.0.

That's how I know it's not installed:

[root@es1 friedmaa]# perl -MApp::ElasticSearch::Utilities -e1
Can't locate App/ElasticSearch/Utilities.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

Thanks,
Amit

Force flag doesn't work

puppet agent --test

Warning: Local environment: "production" doesn't match server specified node environment "development", switching agent to "development".
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/spacewalked.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Caching catalog for prod-mx-test.example.com
Info: Applying configuration version '1398818410'
Info: Installing cpan module Net::Address::IP::Local
Info: Forcing install for Net::Address::IP::Local
CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/Metadata'
Database was generated on Tue, 29 Apr 2014 23:41:02 GMT
Running install for module 'Net::Address::IP::Local'
CPAN: Data::Dumper loaded ok (v2.124)
'YAML' not installed, falling back to Data::Dumper and Storable to read prefs '/root/.cpan/prefs'
Running make for J/JM/JMEHNLE/net-address-ip-local/Net-Address-IP-Local-0.1.2.tar.gz
CPAN: Digest::SHA loaded ok (v5.47)
Checksum for /root/.cpan/sources/authors/id/J/JM/JMEHNLE/net-address-ip-local/Net-Address-IP-Local-0.1.2.tar.gz ok
Net-Address-IP-Local-0.1.2/
Net-Address-IP-Local-0.1.2/INSTALL
Net-Address-IP-Local-0.1.2/CHANGES
Net-Address-IP-Local-0.1.2/SIGNATURE
Net-Address-IP-Local-0.1.2/lib/
Net-Address-IP-Local-0.1.2/lib/Net/
Net-Address-IP-Local-0.1.2/lib/Net/Address/
Net-Address-IP-Local-0.1.2/lib/Net/Address/IP/
Net-Address-IP-Local-0.1.2/lib/Net/Address/IP/Local.pm
Net-Address-IP-Local-0.1.2/TODO
Net-Address-IP-Local-0.1.2/MANIFEST
Net-Address-IP-Local-0.1.2/Makefile.PL
Net-Address-IP-Local-0.1.2/Build.PL
Net-Address-IP-Local-0.1.2/debian/
Net-Address-IP-Local-0.1.2/debian/rules
Net-Address-IP-Local-0.1.2/debian/compat
Net-Address-IP-Local-0.1.2/debian/changelog
Net-Address-IP-Local-0.1.2/debian/control
Net-Address-IP-Local-0.1.2/debian/copyright
Net-Address-IP-Local-0.1.2/META.yml
Net-Address-IP-Local-0.1.2/LICENSE
Net-Address-IP-Local-0.1.2/README
CPAN: File::Temp loaded ok (v0.22)

CPAN.pm: Going to build J/JM/JMEHNLE/net-address-ip-local/Net-Address-IP-Local-0.1.2.tar.gz

This module requires Module::Build to install itself.
Install Module::Build now from CPAN? [y]

This is with the force => true used.

Update the forge module

It would be really nice if you could find the time to update the forge to include the latest changes to the module.

Thanks

Debian support

Trying to use module on Ubuntu 15.04 systems and getting the following message:

Error: Evaluation Error: Error while evaluating a Function Call, Module cpan is not supported on Debian at /etc/puppetlabs/code/environments/production/modules/cpan/manifests/init.pp:59:7 on node kermit.

Tried this with the following small code fragment:

$cpanmods=['Net::SSLeay',]
include cpan
cpan { $cpanmods: 
  ensure => present, 
  require => Class['::cpan'],
}

Is there a problem or have I missed out something? Module was manually installed on this test server with the usual 'sudo puppet module install meltwater-cpan'.

Force flag not working

Using Puppet to create a Virtual Machine using the Vagrant infrastructure

Puppet-CPAN version 1.5.0

Workstation Host: Ubuntu/Mint; puppet 3.4.3; Perl 5.18.2
VM: Centos 7; puppet version 3.7.4; Perl version 5.16.3

*Puppet file:

class foo {
  include cpan
  # This is "chaining" - the sequence has to follow the arrows,
  # and if one fails, it all stops there...
  cpan { 'IRI' :
      ensure  => present,
      require => Class['oricpanmodules'],
    }->cpan { 'RDF::Trine' :
     ensure  => present,
      require => Package['raptor2']
    }->cpan {'RDF::Trine::Model' :
      ensure => present,
    }->cpan {'RDF::Trine::Parser' :
      ensure => present,
    }->cpan {'RDF::Trine::NamespaceMap' :
      ensure => present,
    }->cpan {'RDF::Trine::Serializer::Turtle' :
      ensure => present,
    }->cpan {'RDF::Trine::Serializer::RDFJSON' :
      ensure => present,
    }->cpan {'RDF::Trine::Serializer::RDFXML' :
      ensure => present,
    }->cpan { 'RDF::Lazy' :
      # Note: RDF::Lazy 0.081 fails tests under Perl 5.16 & later
      # Requires the --force flag
      ensure  => present,
      require => Class['::cpan'],
      force => true,
    }
}

The RDF::Lazy module is known to fail it's tests under Perl 5.16, however the code itself is fine.

If I ssh onto the Vagrant box, and install the module directly, it goes:

[vagrant@ori-devel ~]$ sudo cpan RDF::Lazy
CPAN: Storable loaded ok (v2.45)
.......
Failed 1/11 test programs. 6/100 subtests failed.
.......
Running make install
   make test had returned bad status, won't install without force

verses

[vagrant@ori-devel ~]$ sudo cpan -f RDF::Lazy
CPAN: Storable loaded ok (v2.45)
.........
 VOJ/RDF-Lazy-0.081.tar.gz
  /usr/bin/make install  -- OK

So this makes me think there's an issue with the cpan module and the force flag

No parameter named 'environment'

After downloading the code from here, and installing it directly on our Puppet server (necessary, since your updated code actually pays attention to environmentally set proxy variables we are using) -- I'm getting an error randomly on a client server, and not sure what in the code could be causing it. This is the Puppet code snippet I'm using:

## CPAN Packages class { '::cpan': manage_package => false, } cpan { 'DBD::Oracle': ensure => present, environment => { 'ORACLE_HOME' => '/oracleHomes/product/19.0.0/client_1', 'LD_LIBRARY_PATH' => '/oracleHomes/product/19.0.0/client_1/lib', }, exists_strategy => 'find', require => Class['::cpan'], } ## End of CPAN Packages

Works fine, installs the CPAN module, usually runs correctly when executing 'puppet agent -t'

Periodically (every 5 or 6) runs, it will start throwing errors:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: no parameter named 'environment'

This will often continue to throw an error for the next 5 or 6 runs, then clear up, and then start again another 5 or 6 runs down the line. I'm frankly baffled as to what could be causing it.

Should be able to add environment variables

I need to set and environment variable for DB2 perl module to install. It would be nice if I could just add something like environment => 'DB2_HOME=

' and the module sets it right before trying to install the module.

files/Config.pm insert works, but failing to do a basic module install?

Hi @wleese

I have a w3cvalidators.pp manifest in my nodes directory that works entirely, except for the part below indicated by "<<<", which doesn't install the Term::ReadLine cpan module as requested, and as would seem to be implied by the cpan/README.md file:

$validator_dependency_pkgs = [ 'lynx', 'git',
'opensp', 'opensp-devel', 'tidy', 'libtidy', 'mercurial', 'mercurial-hgk' ]

node 'validator13x.mydomain.net' inherits linux-basenode {
package { $validator_dependency_pkgs: ensure => present }
}

node 'vp-c6-andrei.mydomain.net' inherits linux-basenode {
package { $validator_dependency_pkgs: ensure => present }
include cpan
cpan { 'Term::ReadLine': <<<
ensure => present, <<<
require => Class['::cpan'], <<<
force => true, <<<
} <<<

}

instead it responds with:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not autoload puppet/type/cpan: uninitialized constant Puppet::Parameter::Boolean on node vp-c6-andrei.mydomain.net
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Just having the "include cpan" is fine - that throws in the requested Config.pm from the cpan module's file directory. Is there anything obvious I'm doing wrong here, apart from being a n00b?

Thanks for any ideas,

Andrei

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.