'I want to write a puppet manifest that will first check available space in C drive if the size is exceed then it will call powershell script
Senario 1 : I want to write a puppet manifest that will first check available space in C drive if the size is exceed then it will call powershell script to do the housekeeping.
How i can add condition that will check the C drive space and if the limit is exceeding then it will run below module that has contain to do the housekeeping
From below class i am able to run ps1 file but command not executing
class windows_disk_cleanup::disk {
$powershell ='C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe'#-NoProfile -NoLogo -NonInteractive'
exec { 'external-code':
command => "$powershell -command ('windows_disk_cleanup/cleanup.ps1')",
logoutput => true, } }
Scenario 2: Alternatively i am thinking, before run the script it will check the condition if condition match for e.g C dirve space usage is 75% then disk_cleanup script will copy to the target server then it will run and do the housekeeping after execution that file should be remove from the server. Below something i am trying ,
class free_disk_space::space {
file {'C:/disk_space':
ensure => 'directory',
path => 'C:/disk_space',
}
file { 'C:/disk_space/disk_cleanup.ps1':
ensure => 'present',
path => 'C:/disk_space/disk_cleanup.ps1',
source => 'puppet:///modules/free_disk_space/disk_cleanup.ps1',
}
exec { 'deploy_disk_cleanup':
path => 'C:/Windows/System32/WindowsPowerShell/v1.0',
command =>'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -File "C:/disk_space/disk_cleanup.ps1"',
timeout => 0
}
exec { 'remove_disk_cleanup':
command =>'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe "Remove-item -path C:/disk_space/disk_cleanup.ps1"',
refreshonly => true,
}
}
I hope i am able to explain my query and what i am looking for
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|