木偶中的多个控制条件验证

时间:2016-10-03 15:51:26

标签: powershell puppet puppet-enterprise facter librarian-puppet

我需要在运行其他清单文件之前验证内存,处理器和端口连接等代理。所以我创建了一个清单,就像通过保持全局事实和语句和exec资源一样。

class vc {
#Validateing Infra Before applying chnages
if $::facts['memorysize'] >= '4.00 GiB'and $::facts['processorcount'] >= 2 and Exec['port_connectivity'] {
  notify { "Infra validated" : }
  include vc::configs 
}
else {
  notify { "Infra not meeting requirements" : }
} 
# Checking port connecitivity to puppet master  
exec { 'port_connectivity':
  command   => 'New-Item c:\debug.txt -type file -Force',
  unless    => 'if((New-Object System.Net.Sockets.TcpClient ("linux-NAS-storage.com",6163)).connected -eq $true) { exit 1 }',
  provider  => powershell,
  }  
}

我的主题是puppet只应在if $::facts['memorysize'] >= '4.00 GiB'and $::facts['processorcount'] >= 2 and Exec['port_connectivity']条件成功的情况下执行。如果exec命令成功并且facter返回true,那么只有它应该执行,但是在单独执行manifest之后不检查该exec语句是否为true。我的主要目的是在运行puppet manifest之前验证端口。可以请任何帮助

0 个答案:

没有答案
相关问题