6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/services/foreman_ansible_director/action_service.rb', line 6
def trigger(action_class, task_args: {}, mode: :auto)
effective_sync_mode = case mode
when :sync, :async
mode
when :auto
Rails.env.production? ? :async : :sync
else
raise ArgumentError,
"Invalid sync_mode: #{mode.inspect}. Expected :auto, :sync, or :async"
end
::ForemanAnsibleDirector::Logging::ActionLogger.log_trigger(
action_class: action_class,
task_args: task_args,
mode: effective_sync_mode
)
if effective_sync_mode == :async
::ForemanTasks.async_task(action_class, **task_args)
else ::ForemanTasks.sync_task(action_class, **task_args)
end
end
|