Skip to content

Instantly share code, notes, and snippets.

@asasfu
Created November 20, 2017 03:05
Show Gist options
  • Save asasfu/b5f456045d3fc21d65fc64fcbc137a87 to your computer and use it in GitHub Desktop.
Save asasfu/b5f456045d3fc21d65fc64fcbc137a87 to your computer and use it in GitHub Desktop.
Puppet agent -t (puppetmaster) vs puppet apply(masterless)
#######################################################################
###
### Filesystem checks
###
<% if $nhc::check_fs_mount { -%>
<% $nhc::check_fs_mount.each |$fs_struct| { -%>
<%
$function = $fs_struct['fs_mode'] ? {
'ro' => 'check_fs_mount_ro',
'rw' => 'check_fs_mount_rw',
default => 'check_fs_mount'
}
$nonfatal = $fs_struct['nonfatal'] ? {
true => '-0',
default => undef
}
$remount = $fs_struct['remount'] ? {
true => '-r',
default => undef
}
$options = $fs_struct['options'] ? {
true => "-o ${fs_struct['options']}",
default => undef
}
$mount_opts = $fs_struct['mount_opts'] ? {
true => "-O ${fs_struct['mount_opts']}",
default => undef
}
$notfound_cmd = $fs_struct['notfound_cmd'] ? {
true => "-e ${fs_struct['notfound_cmd']}",
default => undef
}
$found_cmd = $fs_struct['found_cmd'] ? {
true => "-E ${fs_struct['found_cmd']}",
default => undef
}
$fs_name = "-f ${fs_struct['fs_name']}"
$fs_type = $fs_struct['fs_type'] ? {
true => "-t ${fs_struct['fs_type']}",
default => undef
}
$fs_source = $fs_struct['fs_source'] ? {
true => "-s ${fs_struct['fs_source']}",
default => undef
}
$formats = {
String => {
"format" => "% s",
"string_formats" => {
String => "%s"
}
},
String[0,0] => {
"format" => "% p",
"string_formats" => {
String => "%s"
}
},
Array => {
format => '% a',
separator => '',
string_formats => {
String => '%t',
}
},
Undef => {
"format" => "% s",
"string_formats" => {
String => "%s"
}
}
}
$filtered_fs = [
$function,
$nonfatal,
$remount,
$fs_source,
$fs_type,
$options,
$mount_opts,
$notfound_cmd,
$found_cmd,
$fs_name,
].filter |$item| { $item =~ NotUndef }
$final_fs = String($filtered_fs,$formats)
-%>
* || <%= $final_fs %>
<% } -%>
<% } -%>
puppet agent -t results(note the square brackets, shouldn't be there):
* || ['check_fs_mount_rw', '-f /']
* || ['check_fs_mount_rw', '-f /tmp']
* || ['check_fs_mount_rw', '-f /localscratch']
* || ['check_fs_mount', '-f /opt/software']
* || ['check_fs_mount_rw', '-f /home']
* || ['check_fs_mount_rw', '-f /project']
* || ['check_fs_mount_rw', '-f /scratch']
* || ['check_fs_mount_rw', '-f /cvmfs']
puppet apply results:
* || check_fs_mount_rw -f /
* || check_fs_mount_rw -f /tmp
* || check_fs_mount_rw -f /localscratch
* || check_fs_mount -f /opt/software
* || check_fs_mount_rw -f /home
* || check_fs_mount_rw -f /project
* || check_fs_mount_rw -f /scratch
* || check_fs_mount_rw -f /cvmfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment