Question

how to install multiple package in puppet 4?

Posted August 3, 2016 4.5k views
RubyConfiguration Management

I am testing existing custom code from 3.1 to 4.5.2 on puppet. It is for minicoda package installation.

class profile::hadoop::miniconda {
# Install miniconda default env (usually running python 2.7)
   exec { 'install_miniconda':
     command => '/test/python_module_install.sh',
     timeout => 1620,
     onlyif => '/usr/bin/test ! -d  /opt/miniconda'
  }

# Install miniconda python 3.4.3 env (py34) unless already installed
# It may fail at first run ever because "conda env" is not supported
# before an actual environment is created first
   exec { 'install_miniconda_py34':
     command => '/opt/miniconda/bin/conda create -n py34 python=3.4.3',
     unless => "/opt/miniconda/bin/conda env list| grep py34",
     require => Exec["install_miniconda"],
  }

        define miniconda_package{ $conda = "/opt/miniconda/bin/conda"

           exec { "miniconda_${name}":
               command => "${conda} install --yes  ${name}",
               require => Exec["install_miniconda"],
               unless => "${conda} list ${name}| grep ${name}"
           }
       }
  # Install Python modules into /opt/miniconda/ default env (usually running python 2.7)
  miniconda_package{[numpy,scipy,pandas,scikit-learn,rpy2,statsmodels,scikit-image,sympy,pymc]:
       require => File["condarc"],
   }


        define miniconda_package_py34{ $conda = "/opt/miniconda/bin/conda"

           exec { "miniconda_${name}_py34":
               command => "${conda} install --yes -n py34 ${name}",
               require => Exec["install_miniconda"],
               unless => "${conda} list -n py34 ${name}| grep ${name}"
           }
       }
  # Install Python modules into /opt/miniconda/ py34 env (usually running python 3.4.3)
  miniconda_package_py34{[numpy,scipy,pandas,scikit-learn,rpy2,statsmodels,scikit-image,sympy,pymc]:
       require => File["condarc"],
   }

        define pip_package{ $pip = "/opt/miniconda/bin/pip"

           exec { "pip_${name}":
               command => "${pip} install --upgrade ${name} -i http://server/products/miniconda/pypi.python.org/simple",
               require => Exec["install_miniconda"],
               unless => "${pip} list | grep -i ${name}"
           }
       }
  # Install pip modules into /opt/miniconda/ default env (usually running python 2.7)
  pip_package{[pyDOE,happybase,gplearn]:
       require => File["condarc"],
   }

        define pip_package_py34{ $pip = "/opt/miniconda/envs/py34/bin/pip"

           exec { "pip_${name}_py34":
               command => "${pip} install --upgrade ${name} -i http://server/products/miniconda/pypi.python.org/simple",
               require => Exec["install_miniconda"],
               unless => "${pip} list | grep -i ${name}"
           }
       }
  # Install pip modules into /opt/miniconda/ py34 env (usually running pythoni 3.4.3)
  pip_package_py34{[pyDOE,gplearn]:
       require => File["condarc"],
   }


   # To manage local repo's using .condarc file
   file { "condarc":
               ensure   => file,
               owner    => 'root',
               group    => 'root',
               mode     => '0644',
               source   => "puppet:///modules/profile/hadoop/miniconda_condarc",
               path     => "/root/.condarc",
               require  => Exec["install_miniconda"],
  }
}

Client side error
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Resource Statement, Invalid resource type miniconda_package

kindly let me know iif we need any modification on existing pp file for working in puppet 4.5.2.

edited by kamaln7

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

I believe that you maybe receiving this error as Puppet 4.0 no longer supports locally scoped defined types. Since you are going from Puppet 3.x to Puppet 4.x this maybe affected.

You may want to check with the module to ensure that it has Puppet 4.x support otherwise if this is indeed the issue you may have to fix it yourself in order for the upgrade to work.

Submit an Answer