Re: [Puppet Users] manifest for files executable on windows

1,330 views
Skip to first unread message

Josh Cooper

unread,
Jul 9, 2012, 3:27:06 PM7/9/12
to puppet...@googlegroups.com
Hi,

On Mon, Jul 9, 2012 at 10:53 AM, vita <vt...@yahoo.com> wrote:
> Hello Puppet Users,
>
> I need a puppet master (Ubuntu) to push the executable files to the agent
> (windows 7) and install those executables
>
> I believe the manifest file should be set up to push such config to the
> windows agent. I came up with something like this:
>
> class wireshark {
> exec { 'wireshark':
> command => 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe,

Need an ending quote above.

> }
> }
> node homebasic32.test.com {
> include wireshark
> }
>
> According to my understanding, this manifest file will execute already
> existing Wireshark-win32-1.8.0.exe file on windows. I cannot figure out how
> to make the master to push this file to windows first.
>
> Please help!
>
> Great thanks!!!
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/C0mZoYGo8ucJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

You will want to declare a file resource whose source refers back to
your 'wireshark' module on your puppetmaster:

file { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe':
ensure => present,
source => 'puppet:///modules/wireshark/Wireshark-win32-1.8.0.exe',
}

Then place the Wireshark executable on the puppetmaster, e.g.
/etc/puppetlabs/modules/wireshark/files/Wireshark-win32-1.8.0.exe,
with the appropriate executable mode, e.g. 0750.

When the Puppet agent applies the catalog, it will download the file
if necessary, and then execute it. However, as currently written,
Puppet will execute the wireshark installer every time it runs. You
will need to use the `onlyif` or `creates` parameters for your exec
resource so that Puppet performs the exec if wireshark is not
installed.[1] For example, `creates => 'C:\Program Files
(x86)\Wireshark\wireshark.exe'`

Finally, we are working on updating the package provider to support
non-MSI types, such as NullSoft that Wireshark uses.[2]

Josh

[1] http://docs.puppetlabs.com/references/stable/type.html#exec
[2] https://projects.puppetlabs.com/issues/11870

--
Josh Cooper
Developer, Puppet Labs

Viktoriya Tochilnikova

unread,
Jul 9, 2012, 4:17:01 PM7/9/12
to puppet...@googlegroups.com, Josh Cooper
I have followed you suggestions for placing the file on windows and got following error. Pls advise!!!
 
================================
C:\Program Files\Puppet Labs\Puppet Enterprise\bin>puppet agent --test --server
qalab2.pertino.com
info: Caching catalog for homebasic32.pertino.com
info: Applying configuration version '1341864702'
err: /Stage[main]//File[C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe]: Coul
d not evaluate: Error 400 on SERVER: Not authorized to call find on /file_metada
ta/puppet/modules/wsh/Wireshark-win32-1.8.0.exe Could not retrieve file metadata
 for puppet:///puppet/modules/wsh/Wireshark-win32-1.8.0.exe: Error 400 on SERVER
: Not authorized to call find on /file_metadata/puppet/modules/wsh/Wireshark-win
32-1.8.0.exe at /etc/puppet/manifests/site.pp:8
notice: Finished catalog run in 0.23 seconds
================================
 
 
Viktoriya


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsub...@googlegroups.com.

Viktoriya Tochilnikova

unread,
Jul 9, 2012, 4:18:14 PM7/9/12
to puppet...@googlegroups.com, Josh Cooper

Here is my file:

file { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe':
      ensure => present,    
      source => 'puppet:///puppet/modules/wsh/Wireshark-win32-1.8.0.exe',
    }

 
Viktoriya



From: Josh Cooper <jo...@puppetlabs.com>
To: puppet...@googlegroups.com
Sent: Monday, July 9, 2012 12:27 PM
Subject: Re: [Puppet Users] manifest for files executable on windows
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsub...@googlegroups.com.

Josh Cooper

unread,
Jul 9, 2012, 4:44:03 PM7/9/12
to Viktoriya Tochilnikova, puppet...@googlegroups.com
Hi Viktoriya,

On Mon, Jul 9, 2012 at 1:18 PM, Viktoriya Tochilnikova <vt...@yahoo.com> wrote:
>
> Here is my file:
>
> file { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe':
> ensure => present,
> source => 'puppet:///puppet/modules/wsh/Wireshark-win32-1.8.0.exe',

The source needs to be 'puppet:///modules/wsh/Wireshark-win32-1.8.0.exe'
>> puppet-users...@googlegroups.com.
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
>

Josh

Viktoriya Tochilnikova

unread,
Jul 9, 2012, 4:56:18 PM7/9/12
to puppet...@googlegroups.com, Josh Cooper
Josh,
This is what I got this time, after fixing the source path. Pls help. Great Thanks!
C:\Program Files\Puppet Labs\Puppet Enterprise\bin>puppet agent --test --server
qalab2.pertino.com
info: Caching catalog for homebasic32.pertino.com
info: Applying configuration version '1341867021'
err: /Stage[main]//File[C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe]: Coul
d not evaluate: Could not retrieve information from environment production sourc
e(s) puppet:///modules/wsh/Wireshark-win32-1.8.0.exe at /etc/puppet/manifests/si
te.pp:8
notice: Finished catalog run in 0.20 seconds
>
 
Viktoriya


>> puppet-users+unsub...@googlegroups.com.

> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
>

Josh

--
Josh Cooper
Developer, Puppet Labs

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsub...@googlegroups.com.

Viktoriya Tochilnikova

unread,
Jul 9, 2012, 5:18:32 PM7/9/12
to puppet...@googlegroups.com, Josh Cooper
I have figured it out and got it to work - my executable is getting placed on win machine. Great thanks, Josh.
How, I need to execute it. Here is my executable:

exec { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe':
        creates => 'C:\Program Files\Wireshark\wireshark.exe'
    }

Is this correct?
 
Viktoriya



From: Viktoriya Tochilnikova <vt...@yahoo.com>
To: "puppet...@googlegroups.com" <puppet...@googlegroups.com>
Cc: Josh Cooper <jo...@puppetlabs.com>
Sent: Monday, July 9, 2012 1:56 PM

Josh Cooper

unread,
Jul 9, 2012, 6:02:45 PM7/9/12
to Viktoriya Tochilnikova, puppet...@googlegroups.com
Hi Viktoriya,

On Mon, Jul 9, 2012 at 2:18 PM, Viktoriya Tochilnikova <vt...@yahoo.com> wrote:
> I have figured it out and got it to work - my executable is getting placed
> on win machine. Great thanks, Josh.
> How, I need to execute it. Here is my executable:
>
> exec { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe':
> creates => 'C:\Program Files\Wireshark\wireshark.exe'
> }
>
> Is this correct?
>

Yes, looks good provided 'C:\Program Files\Wireshark\wireshark.exe' is
the correct path for the installed executable.

If you run into issues, try adding the `logoutput => true` parameter
to the exec resource.
>>> puppet-users...@googlegroups.com.
>> puppet-users...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/puppet-users?hl=en.
>>
>>
>>
>
> Josh
>
> --
> Josh Cooper
> Developer, Puppet Labs
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
>
>
>



Viktoriya Tochilnikova

unread,
Jul 9, 2012, 6:16:14 PM7/9/12
to puppet...@googlegroups.com, Josh Cooper
I got an error with/without logoutput:
 
C:\Program Files\Puppet Labs\Puppet Enterprise\bin>puppet agent --test --server
qalab2.pertino.com
info: Caching catalog for homebasic32.pertino.com
info: Applying configuration version '1341871910'
notice: /Stage[main]//File[C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe]/en
sure: defined content as '{md5}1e791b80e0693e174c6666930b0728a9'
err: /Stage[main]//Exec[C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe]/retur
ns: change from notrun to 0 failed: CreateProcess() failed: The requested operat
ion requires elevation.
notice: Finished catalog run in 5.16 seconds
What is wrong now?
 
Thanks, 
 
Viktoriya


>>> puppet-users+unsub...@googlegroups.com.
>> puppet-users+unsub...@googlegroups.com.

>> For more options, visit this group at
>> http://groups.google.com/group/puppet-users?hl=en.
>>
>>
>>
>
> Josh
>
> --
> Josh Cooper
> Developer, Puppet Labs
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to

> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
>
>
>



--
Josh Cooper
Developer, Puppet Labs

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsub...@googlegroups.com.

Viktoriya Tochilnikova

unread,
Jul 10, 2012, 11:50:49 AM7/10/12
to puppet...@googlegroups.com
UPDATE:

Here is the working version of the manifest file for windows agent. The master with such manifest will send wireshark and winpcap executables to the windows machine and execute them:


file { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe':
      ensure => 'present',    
      source => 'puppet:///modules/wsh/Wireshark-win32-1.8.0.exe'
    }
exec { 'C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe /S':
    cwd     => 'C:\Users\vita\Downloads',
        creates => 'C:\Program Files\Wireshark\wireshark.exe',
    logoutput => 'true'
    }


file { 'C:\Users\vita\Downloads\winpcap-nmap-4.12.exe':
      ensure => 'present',    
      source => 'puppet:///modules/wsh/winpcap-nmap-4.12.exe'
    }
exec { 'C:\Users\vita\Downloads\winpcap-nmap-4.12.exe /S':
        cwd     => 'C:\Users\vita\Downloads',
        creates => 'C:\Program Files\WinPcap\rpcapd.exe',
        logoutput => 'true'
    }

Great thanks, Josh, for your support!
 
Viktoriya



From: Viktoriya Tochilnikova <vt...@yahoo.com>
To: "puppet...@googlegroups.com" <puppet...@googlegroups.com>
Cc: Josh Cooper <jo...@puppetlabs.com>
Sent: Monday, July 9, 2012 1:18 PM
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.

Viktoriya Tochilnikova

unread,
Jul 10, 2012, 4:18:36 PM7/10/12
to Josh Cooper, puppet...@googlegroups.com
Josh,

I need to push and install python.msi package on win host. Should I use "exec" block or "package" instead? I am not sure, pls confirm. THanks!
 
Viktoriya



From: Josh Cooper <jo...@puppetlabs.com>
To: Viktoriya Tochilnikova <vt...@yahoo.com>
Sent: Monday, July 9, 2012 7:42 PM

Subject: Re: [Puppet Users] manifest for files executable on windows

Great to hear. Can you post your final manifest to the user list?

Thanks,
Josh

On Jul 9, 2012, at 7:28 PM, Viktoriya Tochilnikova <vt...@yahoo.com> wrote:

Yes, I figured that one out. Also, I have found the version of the winpcap that can be installed silently as well. I got whole thing to work!!! Thanks.
 
Viktoriya



From: Josh Cooper <jo...@puppetlabs.com>
To: Viktoriya Tochilnikova <vt...@yahoo.com>
Sent: Monday, July 9, 2012 5:21 PM

Subject: Re: [Puppet Users] manifest for files executable on windows

Btw, I found this link
http://www.wireshark.org/docs/wsug_html_chunked/ChBuildInstallWinInstall.html

"/S runs the installer or uninstaller silently with default values.
Please note: The silent installer won't install WinPCap!"

So you will need to pass /S in your exec, but you will also need to
install winpcap separately. I'm not sure why wireshark doesn't install
winpcap in silent mode. Seems odd.

HTH,
Josh

On Mon, Jul 9, 2012 at 4:56 PM, Josh Cooper <jo...@puppetlabs.com> wrote:
> You will have to google to see how to install wireshark silently. This
> isn't a puppet issue, it's a wireshark installer issue. Figure out
> whatever the argument is, verify you can install wireshark from the
> command line silently, and then tell puppet to use the same
> argument(s).
>
> Josh
>
> On Mon, Jul 9, 2012 at 4:33 PM, Viktoriya Tochilnikova <vt...@yahoo.com> wrote:
>> I have no idea what args I need to specify. Can you be more detailed? Tell
>> me exactly what I need to put into my 'exec' block to make this installer
>> work automatically. Many Thanks!!!!

>> Viktoriya
>>
>>
>> ________________________________
>> From: Josh Cooper <jo...@puppetlabs.com>
>> To: Viktoriya Tochilnikova <vt...@yahoo.com>
>> Sent: Monday, July 9, 2012 4:28 PM

>>
>> Subject: Re: [Puppet Users] manifest for files executable on windows
>>
>> This is an issue with the wireshark installer. You'll need to specify
>> the appropriate set of arguments to install wireshark silently.
>>
>> On Mon, Jul 9, 2012 at 4:15 PM, Viktoriya Tochilnikova <vt...@yahoo.com>
>> wrote:
>>> I got it to work, BUT installation of the wireshark is NOT happening
>>> automatically - the agent is popping up the first screen of the installer.
>>> WHY? I am looking for the automated install, without user intervention.
>>> Thanks.

>>>
>>> Viktoriya
>>>
>>>
>>> ________________________________
>>> From: Josh Cooper <jo...@puppetlabs.com>
>>> To: Viktoriya Tochilnikova <vt...@yahoo.com>
>>> Sent: Monday, July 9, 2012 4:03 PM

>>>
>>> Subject: Re: [Puppet Users] manifest for files executable on windows
>>>
>>> Hi Viktoriya,
>>>
>>> On Mon, Jul 9, 2012 at 3:38 PM, Viktoriya Tochilnikova <vt...@yahoo.com>
>>> wrote:
>>>> C:\Windows\system32>puppet agent --test --server qalab2.pertino.com
>>>> err: Could not request certificate: The certificate retrieved from the
>>>> master do
>>>> es not match the agent's private key.
>>>> Certificate fingerprint: 7D:4B:96:E0:FD:80:30:E5:94:AC:77:0E:39:D5:EF:28
>>>> To fix this, remove the certificate from both the master and the agent
>>>> and
>>>> then
>>>> start a puppet run, which will automatically regenerate a certficate.
>>>> On the master:
>>>>  puppet cert clean homebasic32.pertino.com
>>>> On the agent:
>>>>  rm -f
>>>> C:/ProgramData/PuppetLabs/puppet/etc/ssl/certs/homebasic32.pertino.com.p
>>>> em
>>>>  puppet agent -t
>>>> Exiting; failed to retrieve certificate and waitforcert is disabled
>>>>
>>>> Viktoriya
>>>>
>>>>
>>>
>>> See http://docs.puppetlabs.com/windows/running.html#security-context.
>>> Basically, the master has already issued a certificate for that
>>> agent's name (the agent running in a non-elevated security context).
>>> You'll need to follow the instructions in the error message to reset
>>> the ssl state.

>>>
>>>> ________________________________
>>>> From: Viktoriya Tochilnikova <vt...@yahoo.com>
>>>> To: Josh Cooper <jo...@puppetlabs.com>
>>>> Sent: Monday, July 9, 2012 3:35 PM

>>>>
>>>> Subject: Re: [Puppet Users] manifest for files executable on windows
>>>>
>>>> If I run an agent with Admin privileges, I am getting a cert related
>>>> error.
>>>> It's asking to remove certs on master and agent and generate them again.
>>>> Is
>>>> this safe? Is this expected? Why do certificates work in not-Admin mode?
>>>>
>>>> Thanks,

>>>> Viktoriya
>>>>
>>>>
>>>> ________________________________
>>>> From: Josh Cooper <jo...@puppetlabs.com>
>>>> To: Viktoriya Tochilnikova <vt...@yahoo.com>
>>>> Sent: Monday, July 9, 2012 3:24 PM

>>>>
>>>> Subject: Re: [Puppet Users] manifest for files executable on windows
>>>>
>>>> On Mon, Jul 9, 2012 at 3:16 PM, Viktoriya Tochilnikova <vt...@yahoo.com>
>>>> wrote:
>>>>> I got an error with/without logoutput:
>>>>>
>>>>> C:\Program Files\Puppet Labs\Puppet Enterprise\bin>puppet agent --test
>>>>> --server
>>>>> qalab2.pertino.com
>>>>> info: Caching catalog for homebasic32.pertino.com
>>>>> info: Applying configuration version '1341871910'
>>>>> notice:
>>>>> /Stage[main]//File[C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe]/en
>>>>> sure: defined content as '{md5}1e791b80e0693e174c6666930b0728a9'
>>>>> err:
>>>>>
>>>>>
>>>>>
>>>>> /Stage[main]//Exec[C:\Users\vita\Downloads\Wireshark-win32-1.8.0.exe]/retur
>>>>> ns: change from notrun to 0 failed: CreateProcess() failed: The
>>>>> requested
>>>>> operat
>>>>> ion requires elevation.
>>>>> notice: Finished catalog run in 5.16 seconds
>>>>> What is wrong now?
>>>>>
>>>>
>>>> On UAC systems, you need to "run as administrator". See
>>>>
>>>> http://docs.puppetlabs.com/windows/running.html#running-other-puppet-tasks

Josh Cooper

unread,
Jul 10, 2012, 5:07:25 PM7/10/12
to Viktoriya Tochilnikova, puppet...@googlegroups.com
Hi Viktoriya,

On Tue, Jul 10, 2012 at 1:18 PM, Viktoriya Tochilnikova <vt...@yahoo.com> wrote:
> Josh,
>
> I need to push and install python.msi package on win host. Should I use
> "exec" block or "package" instead? I am not sure, pls confirm. THanks!
>

Use package. Note there are some issues with the current MSI provider
in 2.7.x. I have a pull request here[1] though it has not yet been
merged. Also see ticket 11868[2] for more information.

Josh

[1] https://github.com/puppetlabs/puppet/pull/851
[2] https://projects.puppetlabs.com/issues/11868
Reply all
Reply to author
Forward
0 new messages