问题
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