Not sure if you got an answer that made sense, but here is my take on what 
you may be seeking. You can refer to 
https://docs.puppet.com/puppet/latest/lang_relationships.html for a better 
explanation than I can give here. 

Now I haven't worked with Puppet on Windows, but this is how I have setup 
similar 


class profile::application {
## Install application package
  package { 'application':
    ensure => installed,
    source => //server/share/application.msi,
  } ->
  file {'C:/Program Files (x86)/application/app1.exe':
    ensure => present,
    require => Package['application'],     # Make sure that the 
application.msi ran before checking for the apps.
  } 
  file {'C:/Program Files (x86)/application/app2.exe':
    ensure => present,
    require => Package['application'],      # Make sure that the 
application.msi ran before checking for the apps.
  } ~>
  service {'app1':
    ensure => 'running',
    enable => true,
    require => File['C:/Program Files (x86)/application/app1.exe'],   #Make 
sure app exists before trying to start 
  }
  service {'app2':
    ensure => 'running',
    enable => true,
    require => File['C:/Program Files (x86)/application/app2.exe'],   #Make 
sure app exists before trying to start 
  }
}


Another way you do the file / service blocks would be to try the below. It 
will make sure the .msi file was run first and after it checks for the file 
it would tell the service to do the setup.


file {'<path to file for app X>': 
   ensure => present,
   require => Package['application'],
   notify => Service['<app>']
}

service {'app': 
   ensure => 'running',
   enabled => 'true",
}

You may also want to look at the Metaparameter Reference pages at 
https://docs.puppet.com/puppet/4.8/metaparameter.html as it talks about the 
various ones I used above as well as many others. They are very good at 
doing workflow. 

If you are feeling really adventurous you might want to look at coding a 
custom fact (which can be written in any language that returns key=>value 
pairs in the format puppet wants) that would parse through your 
//server/share/application.msi file and run a for look on each "app" it 
find in there.  You could use variables to simplify your manifest a lot. 
Look at https://docs.puppet.com/puppet/latest/lang_iteration.html.  The 
custom fact would be pushed to your Windows server and run before the 
catalog is compiled on the Puppet master. 

So using the example Puppet gives for declaring resources and a custom fact 
that returns the fact apps_to_install=[ 'app1', 'app2', ...., 'appX' ], you 
could try to do: 

$app_to_install.each |String $my_app| {
   package {'$my_app': 
   ... 
   }
   file {'C:/Program Files (x86)/application/$my_app':
   ...
    require => Package['$my_app'],     
    notify => Serice['$my_app'],
   }

   service {'$my_app': 
      ...
   }
} 

Hopefully something in my ramblings made some sense and helped you figure 
out what to do to get this working. 





>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/69e721b3-d8e0-4d91-aee5-6b9c3c299178%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to