X

Puppet – Install Software for Windows Clients

Previous post : Puppet Your First Class

Installing software with Puppet for windows is a little bit harder than doing it on Linux.

Here are the steps: 
1. Install the software in a windows machine to see how the version details are displayed by Puppet.
2. Create a class where it first creates an upload folder for your installations
3. Create a class for Workrave installation.

For our first example I will use a simple software: workrave. You can download it from http://www.workrave.org.

First Step:

Install workrave in a Windows machine where you have Puppet agent installed. Check the details with the command below:

puppet resource package > software.txt

This command will create a file and in it you can see the software installed. Below is the screenshot. From the screenshot we see the details of workrave.

 

Second Step:

Create a folder for your uploads. This is not necessary, You can use C:\Temp or other folders. I use a custom folder for Puppet installation files. Here is the class init file:

class softwarerepo {
   file { 'c:\\SoftwareRepo':
      ensure => 'directory',
      source_permissions => ignore,
   }
}

And here is the folder structure for it under /etc/puppet/modules for your puppetmaster server:

./softwarerepo:
total 12
drwxr-xr-x 3 root root 4096 Dec 10 10:13 .
drwxr-xr-x 5 root root 4096 Dec 10 10:13 ..
drwxr-xr-x 2 root root 4096 Dec 10 13:41 manifests

./softwarerepo/manifests:
total 12
drwxr-xr-x 2 root root 4096 Dec 10 13:41 .
drwxr-xr-x 3 root root 4096 Dec 10 10:13 ..
-rw-r--r-- 1 root root 117 Dec 10 10:13 init.pp

Third step:

In this step we will create another class for workrave. Here is the class details.

class workrave {

  file { 'c:/SoftwareRepo/workrave-win32-v1.10-installer.exe':
    source => 'puppet:///modules/workrave/workrave-win32-v1.10-installer.exe',
    source_permissions => ignore,
    require => File['c:/SoftwareRepo'],
  }

  package { 'Workrave 1.10':
    ensure => installed,
    source => 'c:/SoftwareRepo/workrave-win32-v1.10-installer.exe',
    install_options => ['/VERYSILENT'],
    require => File['c:/SoftwareRepo/workrave-win32-v1.10-installer.exe'],
  }
}

The first block file uploads the installer file and requires a folder C:\SoftwareRepo exists. If the folder does not exist it will be created by the previous class. The second block package installs the software. As you see we used the same details from the software.txt. In software.txt we can see how it is recognized by Puppet.

TIP:
The installation options may change for different installers. For our example it is /VERYSILENT. This parameter will ensure a silent install in the background.For different software you need to check the installer options in command prompt with a parameter: “/?”

Here is the folder structure:

./workrave:
total 16
drwxr-xr-x 4 root root 4096 Dec 5 20:40 .
drwxr-xr-x 5 root root 4096 Dec 10 10:13 ..
drwxr-xr-x 2 root root 4096 Dec 5 20:40 files
drwxr-xr-x 2 root root 4096 Dec 5 20:43 manifests

./workrave/files:
total 13972
drwxr-xr-x 2 root root 4096 Dec 5 20:40 .
drwxr-xr-x 4 root root 4096 Dec 5 20:40 ..
-rw-r--r-- 1 root root 14298591 Dec 5 20:40 workrave-win32-v1.10-installer.exe

./workrave/manifests:
total 12
drwxr-xr-x 2 root root 4096 Dec 5 20:43 .
drwxr-xr-x 4 root root 4096 Dec 5 20:40 ..
-rw-r--r-- 1 root root 627 Dec 5 20:43 init.pp

After you are done with your classes you need to import the new classes in foreman and assign in to the relevant hosts or host groups.

Below you can see that the classes are assigned to host windowstest. Now running a puppet test will show us if everything went fine:

As you can see from the screenshot. Workrave was uploaded and installed successfully.

? The end of post ?

This post was last modified on December 10, 2014, 5:17 pm

Categories: Puppet
Fuat Ulugay: