如何使用防火墙DSC资源使用Puppet创建防火墙规则?

时间:2020-10-23 13:39:38

标签: puppet parameter-splatting

我想创建一个类,该类在我的VM上创建新的防火墙规则。 我正在尝试利用DSC资源-防火墙。 我当前的课程位于新的win_basic_firewall.pp中,看起来像这样

$('.MyDivs').on('mouseenter mouseleave click', function(e) {
    sameOperation();
});

我有一个列出我的规则的json配置文件。我目前有这个:

class osconfig::win_basic_firewall {
  if $dscmoduleversion != '' {
      $module = {
          'name'    => 'networkingdsc',
          'version' => $dscmoduleversion,
      }
  }else{
      $module = 'networkingdsc'
  }
  $fwallow = lookup('myfirewall')

  $fwallow.each |String $fwname, $rule|{
      dsc { $fwname : 
      require       => Dsc['PSModule networkingdsc'],
      resource_name => 'Firewall',
      module        => $module,
      properties    => {
          * => $rule
      },
    }
  }
}

清单文件中只有一行

"myfirewall":{
        "Newtestrule":{
            "Name":"RDP test",
            "Action": "Allow",
            "Description": "This will allow RDP only from my IP",
            "DisplayName": "My TEST rule RDP",
            "Direction": "Inbound",
            "Enabled":"True",
            "Encryption": "NotRequired",
            "Ensure": "Present",
            "LocalPort": ["3389"],
            "RemoteAddress": ["xx.xx.xx.xx/xx"],
            "Protocol": "TCP"
        }
    },

当我的人偶代理在VM上运行时,我得到的是:

include osconfig::win_basic_firewall

...恰好是通过喷溅的那一行

win_basic_firewall.pp, line: 18, column: 13

我该怎么办?

0 个答案:

没有答案