Uploading a zipped file from the puppet master to a windows node for Test, Dev & Prod Environment

asked 2015-09-23 04:11:12 -0600

michaelokoluko gravatar image

updated 2015-09-24 03:54:46 -0600

Working on developing a manifest for the following scenario:

  1. Puppet Master receives a zipped PowerShell script (for windows build) called “download.ps1” – Action : Upload zip file to puppet master – using best practices where is the ideal place to place this file on the PE master.

  2. Pushes the .gz file to windows agents

  3. This file gets unzipped at the target server(s)

  4. The powershell scripts gets executed and deployed - in the appropriate Test, Dev or Prod environment - this would require a variable

I believe its needs to be a bit modular as in splitting the code into interdependent functional parts going by the scenario steps listed above - below is my current skeletal code WIP..

class downloadScript { file { '/var/tmp/download.zip': ensure => present, source => 'puppet:///modules/downloadScript/download.ps1', mode => '0755', owner => 'root', group => 'root', before => Exec['download.zip'], } exec {'unpackdownload.zip': unless => 'test -f /var/tmp/download.ps1', cwd => '/var/tmp', command => 'unzip download.zip', logoutput => true, refreshonly => true, provider => powershell, } exec {'install_download.ps1': # if you want this to only run under certain conditions, use the 'unless' or onlyif' ensure => installed, path => 'C:/WINDOWS/Sytems32/WindowsPowerShell/v1.0', command => 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -ExecutionPolicy RemoteSigned -file c:\download.ps1', logoutput => true, refreshonly => true, provider => powershell, } }

Any pointers?

Regards

edit retag flag offensive close merge delete

Comments

Fix your formatting, this is unreadable.

ramindk gravatar imageramindk ( 2015-09-23 10:37:56 -0600 )edit
1

Question: why zip a single powershell scripts? Why not store in files or template and have it dropped or executed instead? The whole downloadScript class could be cut down to a single exec statement.

souldonut gravatar imagesouldonut ( 2015-09-23 17:39:01 -0600 )edit

The zipped file in question is 45 Mb and I have located tye best place to place it is in the files directory (as you alluded to..) I might also explore using the template resource if I can get my head round it.

michaelokoluko gravatar imagemichaelokoluko ( 2015-10-02 07:51:26 -0600 )edit

Bte way, can someone point me to the tool that Ramindk mentioned that allows formating of my code so it looks readable on this site? Is it akin to the on JIRA uses...

michaelokoluko gravatar imagemichaelokoluko ( 2015-10-02 07:52:59 -0600 )edit

For the records Ramindk! I manually zip and copy the zipped file (download.ps1) via winscp unto the puppet master and place in the files directory and puppet pushes it to the agents and I also use mtime to allow for a copy/replace everytime we generate a new powershell windows build.

michaelokoluko gravatar imagemichaelokoluko ( 2015-10-02 07:57:19 -0600 )edit