How to update values for Match and general section in sshd config using puppet

痞子三分冷 提交于 2020-08-10 18:54:49

问题


Below is the code:

$sections = ['Host *.example.net', 'User foo']

$sections.each |String $section| {
  sshd_config_match { "${section}":
    ensure => present,
  }
}
$settings = {
  'User foo'           => { 'X11Forwarding' => 'yes', 'banner' => 'none'},
  'Host *.example.net' => { 'X11Forwarding' => 'no',  'banner' => 'none'},
}
$settings.each |String $condition, Hash $properties| {
  $properties.each |String $key, String $value| {
    sshd_config { "${condition} ${key}":
      ensure    => 'present',
      condition => $condition,
      key       => $key,
      value     => $value,
    }
  }
}

Currently the key and value( ex:'X11Forwarding' => 'yes') is getting updated under the Match section as mentioned below in the screenshot:

I am looking for the key value( ex:'X11Forwarding' => 'yes') to be updated in global section if at all the section is not matched as mentioned in the below scrrenshot:

Currently above code works good for Match section and looking to update the gobal section if the section is not matched.

I am new to coding and also apologies if my question is confusing, Kindly help.

来源:https://stackoverflow.com/questions/63271537/how-to-update-values-for-match-and-general-section-in-sshd-config-using-puppet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!