diff --git a/plans/util/code_sync_status.pp b/plans/util/code_sync_status.pp new file mode 100644 index 00000000..06db9e7b --- /dev/null +++ b/plans/util/code_sync_status.pp @@ -0,0 +1,25 @@ +# @api private +plan peadm::util::code_sync_status ( + Peadm::SingleTargetSpec $targets, +) { + $data = run_task('peadm::code_sync_status', $targets).first.value + + # Print a table of summary status + out::message( + format::table({ + title => 'Summary', + rows => $data['environments'].reduce([['Overall sync status', $data['sync']]]) |$memo, $val| { + $memo << ["${val[0]} environment in sync", $val[1]['sync']] }})) + + # Print a server status table, one for each environment + $data['environments'].each |$env, $_| { + out::message( + format::table({ + title => "Server sync status - ${env}", + head => ['Server', 'In Sync', 'Commit'], + rows => $data['environments'][$env]['servers'].reduce([]) |$memo, $val| { + $memo << [$val[0], $val[1]['sync'], $val[1]['commit']] }})) + } + + return('Done') +} diff --git a/tasks/code_sync_status.rb b/tasks/code_sync_status.rb index 16126683..93c2fa69 100755 --- a/tasks/code_sync_status.rb +++ b/tasks/code_sync_status.rb @@ -98,9 +98,12 @@ def sync_status environmentstocheck.each do |environment| results[environment] = check_environment_code(environment, servers, status_call) end + # Confirm are all environments being checked in sync - results['sync'] = results.all? { |_k, v| v['sync'] == true } - results + { + 'environments' => results, + 'sync' => results.all? { |_k, v| v['sync'] == true }, + } end end # Run the task unless an environment flag has been set, signaling not to. The