Puppet on Windows: Avoid download msi files if they aren't going to be installed

1,819 views
Skip to first unread message

tiochan

unread,
May 24, 2012, 9:06:43 AM5/24/12
to puppet...@googlegroups.com
Hi all!

I'm new on puppet, and I making my firsts classes.

I have defined an example class to install 7Zip on Windows servers, it runs right, but I would like to improve it.
The problem is that each time that I execute the "puppet agent --test" it downloads the 7zip.msi file, although it is really installed.

So, my question is:
Is possible to avoid the download of the associated source file, I there is no need to install it?

This is the code:


class software_dir {

    file { 'SOFTWARE_DIR':
        path => 'C:\\SOFTWARE',
        ensure => directory,
    }
}

class 7Zip() {

    include software_dir

    $7Zip_source = 'puppet://puppet.upc.edu/modules/windows/7z920.msi'
    $7Zip_path = 'C:\\SOFTWARE\\7z920.msi'
    $7Zip_package_name = '7-zip 9.20'

    file { $7Zip_path:
        source  => $7Zip_source;
    }

    package { $7Zip_package_name:
        ensure => installed,
        provider => 'msi',
        source => File[$7Zip_path],
    }
}


Thanks in advance.

Jeff McCune

unread,
May 24, 2012, 4:42:49 PM5/24/12
to puppet...@googlegroups.com
On Thu, May 24, 2012 at 6:06 AM, tiochan <tio...@gmail.com> wrote:
Hi all!

I'm new on puppet, and I making my firsts classes.

Welcome!
 
I have defined an example class to install 7Zip on Windows servers, it runs right, but I would like to improve it.
The problem is that each time that I execute the "puppet agent --test" it downloads the 7zip.msi file, although it is really installed.

When using a file resource, Puppet should only transfer the file if there is a mis-match between the local file and the copy on the puppet master.

Could you paste the output of puppet agent --test so we can see why the file is being transfered more than once?  Do you happen to be removing the MSI from C:\Software\ between puppet runs?  If so, Puppet will just put the file right back in place.
 
So, my question is:
Is possible to avoid the download of the associated source file, I there is no need to install it?

This is the code:


class software_dir {

    file { 'SOFTWARE_DIR':
        path => 'C:\\SOFTWARE',
        ensure => directory,
    }
}

class 7Zip() {

    include software_dir

    $7Zip_source = 'puppet://puppet.upc.edu/modules/windows/7z920.msi'
    $7Zip_path = 'C:\\SOFTWARE\\7z920.msi'
    $7Zip_package_name = '7-zip 9.20'

    file { $7Zip_path:
        source  => $7Zip_source;
    }

    package { $7Zip_package_name:
        ensure => installed,
        provider => 'msi',
        source => File[$7Zip_path],

I think this line above should be source => "${7Zip_path}"  It shouldn't contain a reference to the _resource_ File[$7Zip_path] but instead simply the string that contains the path.

I'm not sure this is actually the problem though.  I think the output of puppet agent --test will help diagnose this further.

-Jeff

tiochan

unread,
May 25, 2012, 4:58:12 AM5/25/12
to puppet...@googlegroups.com

Jeff, thank for your reply.


Really puppet downloads the file only once, this is not in fact a problem.
I re-made the previous code to simplify it:

class 7Zip() {

    include software_dir

    file { 'C:\\SOFTWARE\\7z920.msi':
        source  => 'puppet://puppet.upc.edu/modules/windows/7z920.msi',
    }

    package { '7-zip 9.20':

        ensure => installed,
        provider => 'msi',
        source => 'C:\\SOFTWARE\\7z920.msi',
    }
}

I can see that if the msi has been installed (by puppet), puppet will not try to install again, this is correct. But always, if it has been installed or not, the file C:\\SOFTWARE\\7z920.msi is downloaded.

A band of having a software repository mounted as a mapped drive... Is possible to avoid that the msi file to being downloaded if it is not going to be installed?



Thanks again.




jcbollinger

unread,
May 25, 2012, 8:43:40 AM5/25/12
to Puppet Users

On May 25, 3:58 am, tiochan <tioc...@gmail.com> wrote:

This stanza:

> file { 'C:\\SOFTWARE\\7z920.msi':
> source => 'puppet://puppet.upc.edu/modules/windows/7z920.msi',
> }

tells Puppet that there is supposed to be a file C:\\SOFTWARE\
\7z920.msi on the system, and its content is supposed to exactly match
that of puppet://puppet.upc.edu/modules/windows/7z920.msi. That's
altogether independent of whatever use that file may have. If the
file is missing when Puppet runs then it will download a fresh copy.
If it is present then Puppet will check its content; it will download
a fresh copy only if the content does not match.

If you do not want the file downloaded every time then either
1) leave it in place where Puppet puts it (per your instructions), or
2) remove that stanza, because it is a lie if you don't actually want
the file to be there.


> A band of having a software repository mounted as a mapped drive... Is
> possible to avoid that the msi file to being downloaded if it is not going
> to be installed?


If you make the MSI file accessible to the system via a mapped drive
or network share then you can exercise option (2) above without losing
the ability to run the installer.


John

Jeff McCune

unread,
May 25, 2012, 10:49:30 AM5/25/12
to puppet...@googlegroups.com
You can also provide a plain HTTP(S) URI to the source parameter and it will only be downloaded if it's not already installed.

-Jeff

tiochan

unread,
May 29, 2012, 2:47:25 AM5/29/12
to puppet...@googlegroups.com

As I can see, the best bet (and perhaps it would be a need) is having a global respository accessible via netbios, NFS and HTTP for puppet, so software is not needed to be transferred each time.

Thank you, John.

tiochan

unread,
May 29, 2012, 3:52:58 AM5/29/12
to puppet...@googlegroups.com
That worked, thanks a lot.

El viernes, 25 de mayo de 2012 16:49:30 UTC+2, Jeff McCune escribió:
On Fri, May 25, 2012 at 5:43 AM, jcbollinger wrote:
Reply all
Reply to author
Forward
0 new messages