diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-01-25 13:30:51 +1000 |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-01-27 17:40:08 +1000 |
commit | 0d24f3e4b3e2a17b2c5a17b5a6a7752514ef0791 (patch) | |
tree | d42c5929375e5cd5bf49d0fa9273ee8a111dd11f | |
parent | e3b825b5816a7bbd8df1fb977c0f6befa44ffd87 (diff) |
homedir_cpan: implement new module to allow non-root CPAN module installs.
This module should allow all test machines to install new CPAN modules
to $HOME/perl5 using `cpanm', and those modules will be automatically
available in the environment for all test scripts.
In comparison to the `cpan' module:
cpan: suitable for e.g. a server running a perl web app which
wants a static set of modules from cpan.
homedir_cpan: suitable for e.g. a test machine which may be running
perl test scripts for multiple projects, and may want to add/remove
various modules during the test procedure.
Reviewed-by: Keith Isdale
Change-Id: Ia30fcbcbe152efc6940d795435b00287d9074446
-rw-r--r-- | puppet/manifests/nodes.pp | 3 | ||||
-rwxr-xr-x | puppet/modules/homedir_cpan/files/profile.d/local-lib-perl.sh | 9 | ||||
-rw-r--r-- | puppet/modules/homedir_cpan/manifests/init.pp | 13 | ||||
-rw-r--r-- | puppet/modules/homedir_cpan/manifests/linux.pp | 16 | ||||
-rw-r--r-- | puppet/modules/homedir_cpan/manifests/ubuntu.pp | 17 |
5 files changed, 58 insertions, 0 deletions
diff --git a/puppet/manifests/nodes.pp b/puppet/manifests/nodes.pp index 76ea54d..0ffa14e 100644 --- a/puppet/manifests/nodes.pp +++ b/puppet/manifests/nodes.pp @@ -68,6 +68,9 @@ node 'linux-tester.test.qt.nokia.com' inherits default { include crosscompilers include intel_compiler include vmware_tools + + # Allow test machines to install modules from cpan under $HOME/perl5 + include homedir_cpan } node 'maemo-tester.test.qt.nokia.com' inherits default { diff --git a/puppet/modules/homedir_cpan/files/profile.d/local-lib-perl.sh b/puppet/modules/homedir_cpan/files/profile.d/local-lib-perl.sh new file mode 100755 index 0000000..c60077b --- /dev/null +++ b/puppet/modules/homedir_cpan/files/profile.d/local-lib-perl.sh @@ -0,0 +1,9 @@ +# deployed by puppet - do not modify, your changes will be discarded. + +# `perl -Mlocal::lib' prints out shell script suitable for use with eval, +# to set up the user's environment to use $HOME/perl5 as a prefix for +# perl modules. It is not harmful if $HOME/perl5 doesn't exist yet. +# +# See: perldoc local::lib +# +eval $(perl -Mlocal::lib) diff --git a/puppet/modules/homedir_cpan/manifests/init.pp b/puppet/modules/homedir_cpan/manifests/init.pp new file mode 100644 index 0000000..d2e8b46 --- /dev/null +++ b/puppet/modules/homedir_cpan/manifests/init.pp @@ -0,0 +1,13 @@ +import "*" + +# This module sets up the necessary environment so that users +# can easily install cpan modules into a prefix under $HOME/perl5 +# and have all perl scripts find them automatically, without any +# root permissions required. +class homedir_cpan { + case $operatingsystem { + Ubuntu: { include homedir_cpan::ubuntu } + default: { error("homedir_cpan is not yet implemented for $operatingsystem") } + } +} + diff --git a/puppet/modules/homedir_cpan/manifests/linux.pp b/puppet/modules/homedir_cpan/manifests/linux.pp new file mode 100644 index 0000000..b422b6e --- /dev/null +++ b/puppet/modules/homedir_cpan/manifests/linux.pp @@ -0,0 +1,16 @@ +class homedir_cpan::linux { + # If this machine has a defined testuser, let's install cpanminus + # automatically. + if $testuser { + exec { "install cpanm for $testuser": + command => "/bin/su - -c ' + + wget --no-check-certificate http://cpanmin.us -O - \ + | perl - -l /home/$testuser/perl5 App::cpanminus + + ' $testuser", + creates => "/home/$testuser/perl5/bin/cpanm", + logoutput => true, + } + } +} diff --git a/puppet/modules/homedir_cpan/manifests/ubuntu.pp b/puppet/modules/homedir_cpan/manifests/ubuntu.pp new file mode 100644 index 0000000..a6e2cd4 --- /dev/null +++ b/puppet/modules/homedir_cpan/manifests/ubuntu.pp @@ -0,0 +1,17 @@ +class homedir_cpan::ubuntu inherits homedir_cpan::linux { + package { + # Need gcc to build CPAN modules + "gcc": ensure => installed; + "g++": ensure => installed; + + # We use the local::lib module to implement $HOME/perl5 + "liblocal-lib-perl": ensure => installed; + } + + file { "/etc/profile.d/local-lib-perl.sh": + ensure => present, + source => "puppet:///modules/homedir_cpan/profile.d/local-lib-perl.sh", + require => Package["liblocal-lib-perl"], + } +} + |