install directory for package, and other basic questions

77 views
Skip to first unread message

Matyas A. Sustik

unread,
Oct 10, 2014, 11:50:34 PM10/10/14
to puppet...@googlegroups.com
I am new to Puppet. I hoped someone in this group could get me on the right track with some questions I have.

1. I would appreciate an example demonstrating how to tell puppet to install a specific package in a specific location? For example, how to write that python2.7 should be installed in /usr/local/bin?

2. How to install a python module, for example pandas? From the command line one could use pip. Does puppet know about pip?

3. How to install a package from the tarballs and specify some parameters to the install process?

Thanks!

Matyas A. Sustik

unread,
Oct 20, 2014, 8:07:20 PM10/20/14
to puppet...@googlegroups.com
I follow up to my own post in case someone else encounters the same questions.


On Friday, October 10, 2014 8:50:34 PM UTC-7, Matyas A. Sustik wrote:
I am new to Puppet. I hoped someone in this group could get me on the right track with some questions I have.

1. I would appreciate an example demonstrating how to tell puppet to install a specific package in a specific location? For example, how to write that python2.7 should be installed in /usr/local/bin?


Puppet is not the right tool for this task according to our local puppetmaster.

Though he also said it can be done when I pressed him. But consider that if an expert says it is too hard and you get 0 responses on google groups you should think twice before embarking on this project: you will probably put a lot of effort in and get stuck at some stage with no help in sight.

2. How to install a python module, for example pandas? From the command line one could use pip. Does puppet know about pip?


You can specify pip to be used for the install. However, if you use python2.7 then you want pip2.7 as well and so you are back to problem 1.
 
3. How to install a package from the tarballs and specify some parameters to the install process?


Ultimately you can write a script that will be executed by puppet and do anything you want. However the benefits puppet brings in this case compared to the rest of the effort will not justify its use.

Felix Frank

unread,
Nov 5, 2014, 7:36:36 PM11/5/14
to puppet...@googlegroups.com
On 10/21/2014 02:07 AM, Matyas A. Sustik wrote:
I follow up to my own post in case someone else encounters the same questions.

On Friday, October 10, 2014 8:50:34 PM UTC-7, Matyas A. Sustik wrote:
I am new to Puppet. I hoped someone in this group could get me on the right track with some questions I have.

1. I would appreciate an example demonstrating how to tell puppet to install a specific package in a specific location? For example, how to write that python2.7 should be installed in /usr/local/bin?


Puppet is not the right tool for this task according to our local puppetmaster.

Oh you have deployed a talking puppet master? ;-)


Though he also said it can be done when I pressed him. But consider that if an expert says it is too hard and you get 0 responses on google groups you should think twice before embarking on this project: you will probably put a lot of effort in and get stuck at some stage with no help in sight.


Yeah, this would most likely require
a) creating a package that installs to that location or
b) making Puppet build from source, but read below


2. How to install a python module, for example pandas? From the command line one could use pip. Does puppet know about pip?


You can specify pip to be used for the install. However, if you use python2.7 then you want pip2.7 as well and so you are back to problem 1.

Yes. You might be able to coax the puppet agent into using a pip wrapper that maps to pip2.7, but not in a flexible fashion.


 
3. How to install a package from the tarballs and specify some parameters to the install process?


Ultimately you can write a script that will be executed by puppet and do anything you want. However the benefits puppet brings in this case compared to the rest of the effort will not justify its use.

Indeed. Writing a script that compiles a software or does whatever, then deploying and running it through Puppet, does not stricly qualify as "solving something with Puppet".

So, fair assessments all.

Cheers,
Felix

jcbollinger

unread,
Nov 6, 2014, 9:53:28 AM11/6/14
to puppet...@googlegroups.com


On Friday, October 10, 2014 10:50:34 PM UTC-5, Matyas A. Sustik wrote:
I am new to Puppet. I hoped someone in this group could get me on the right track with some questions I have.

1. I would appreciate an example demonstrating how to tell puppet to install a specific package in a specific location? For example, how to write that python2.7 should be installed in /usr/local/bin?


Note that although there may be a Python 2.7 package for your system, Python 2.7 is not in itself a 'package' in the sense that term is used in Puppet.  A 'package' in Puppet is an RPM, or a DEB, or even a Python pip or Ruby gem.  These sorts of packages generally get installed to whatever location the packaging system chooses.  On a package by package basis, however, and depending on package type, you may be able to influence installation location via the 'install_options' parameter of the Package resource type.

 

2. How to install a python module, for example pandas? From the command line one could use pip. Does puppet know about pip?



Puppet does know about pip, but generally speaking, it's bad news to use different package management systems on the same system.  You really should use packages of the native packaging type, managed by the system's package manager, even if you have to create the needed packages and keep them in a local repository within your organization.  (Though plenty of people do ignore this policy advice.)

 
3. How to install a package from the tarballs and specify some parameters to the install process?



You can use Exec resources to do this if for some reason it is not feasible to build a bona fide package in the package management sense.  I don't like it, but I have done it.  From an individual system perspective, it has all the negative consequences of a manual source install, but it at least has the advantage of repeatability.


John

Ashish Jaiswal

unread,
Nov 11, 2014, 3:47:03 AM11/11/14
to puppet...@googlegroups.com, jcbollinger
Hello,

> 3. How to install a package from the tarballs and specify some
parameters to the install process?

There is already a nice defination called netinstall, I have used it and
tweak a lill bit for my enviornment.
https://github.com/example42/puppi/blob/master/manifests/netinstall.pp
> feasible to build a /bona fide/ package in the package management
> sense. I don't like it, but I have done it. From an individual
> system perspective, it has all the negative consequences of a manual
> source install, but it at least has the advantage of repeatability.
>
>
> John
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/ce971b71-16ce-4d23-8e56-3a8792fb317b%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/ce971b71-16ce-4d23-8e56-3a8792fb317b%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Matyas A. Sustik

unread,
Dec 23, 2014, 6:18:48 PM12/23/14
to puppet...@googlegroups.com
I revisited the issue a few weeks later and worked on it a couple hours.

1. I managed to write the scripts and manifest files that install and upgrade python2.7 into the alternate /usr/local/bin location. So this was a WIN!

2. I am still battling with pip. I tried to install pip2.7 using the script method and while that works, there is a serious roadblock: puppet does not pick up the pip installed this way. Even though /usr/local/bin is in the PATH for root, puppet says it cannot find pip. I even tried putting in a simlink from /usr/bin/pip to /usr/local/bin/pip, but strangely enough that does not make a difference.

3. While the script method works for python2.7, my solution cannot be called elegant or efficient. The install files are created every time unconditionally, even when the scripts do not get to be executed. I could not see an easy way to resolve this problem.

For reference I have:

class ... {
    file { 'install_python-2.7.8':
        path    => '/tmp/install_python-2.7.8.sh',
        ensure  => file,
        source  => "puppet:///modules/.../scripts/install_python-2.7.8.sh",
        mode    => 0755,
    }

    # No python2.7 exists:
    exec { 'install_python-2.7.8':
        command => '/tmp/install_python-2.7.8.sh',
        require => [File['/tmp/install_python-2.7.8.sh'],
                    Package['gcc-c++']],
        creates => '/usr/local/bin/python2.7',
        timeout => 1200,
    }
}

The exec only runs when /usr/local/bin/python2.7 does not exist, but the installation script gets created on the nodes unconditionally.

I posted the above in case someone finds this useful. I also welcome comments and suggestions.

Best,
-Matyas

Felix Frank

unread,
Dec 23, 2014, 6:42:55 PM12/23/14
to puppet...@googlegroups.com
Hey, thanks for sharing your experience.

On 12/24/2014 12:18 AM, Matyas A. Sustik wrote:
> The exec only runs when /usr/local/bin/python2.7 does not exist, but
> the installation script gets created on the nodes unconditionally.

That's actually well done. Barring that I have been doing things wrong
for quite a while (which happens), it is quite normal for agent nodes to
be littered with some files that are needed during provisioning only.
It's the most direct way to have Puppet make sure that the process works
from start to finish.

With that said, there is some cool work in progress to allow Puppet to
do that, and *not* define each state as permanent:
https://forge.puppetlabs.com/puppetlabs/transition

You should not use that in production yet, but more elegant solutions
are likely feasible in the foreseeable future.

Regards,
Felix
Reply all
Reply to author
Forward
0 new messages