Skip to content

Instantly share code, notes, and snippets.

@iNecas
Created June 26, 2017 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iNecas/2a20c8160debb598a1a7705ac89abb21 to your computer and use it in GitHub Desktop.
Save iNecas/2a20c8160debb598a1a7705ac89abb21 to your computer and use it in GitHub Desktop.
Get raw action data from task in JSON format.
# Get raw action data from task in JSON format.
#
# usage:
#
# TASK_IDS="TASK_ID_1,TASK_ID_2" \
# foreman-rake console 2>/dev/null < foreman_tasks_extract_data.rb | \
# grep "^OUT: " | sed "s/^OUT: //g"
task_ids = ENV['TASK_IDS'].split(',').map(&:strip)
tasks = ForemanTasks::Task.where(:id => task_ids)
puts("OUT: " + tasks.map do |t|
{:task_id => t.id,
:actions => t.execution_plan.actions.map do |h|
h.to_hash.slice(:class, :id, :input, :output)
end }
end.to_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment