Class: Api::V2::AnsiblePlaybooksController

Inherits:
BaseController
  • Object
show all
Includes:
Api::Version2, ForemanAnsible::ProxyAPI
Defined in:
app/controllers/api/v2/ansible_playbooks_controller.rb

Overview

API controller for Ansible Roles

Instance Method Summary collapse

Instance Method Details

#action_permissionObject



32
33
34
35
36
37
38
39
# File 'app/controllers/api/v2/ansible_playbooks_controller.rb', line 32

def action_permission
  case params[:action]
  when 'sync', 'fetch'
    :import
  else
    super
  end
end

#fetchObject



27
28
29
30
# File 'app/controllers/api/v2/ansible_playbooks_controller.rb', line 27

def fetch
  fetched = fetch_playbooks_names
  render :json => { :results => { :playbooks_names => fetched } }
end

#plan_ansible_sync(proxy_id, playbooks_names) ⇒ Object



41
42
43
# File 'app/controllers/api/v2/ansible_playbooks_controller.rb', line 41

def plan_ansible_sync(proxy_id, playbooks_names)
  ForemanTasks.async_task(ImportPlaybooksJob::Async::SyncPlaybooks, proxy_id, playbooks_names)
end

#syncObject



20
21
22
# File 'app/controllers/api/v2/ansible_playbooks_controller.rb', line 20

def sync
  @task = plan_ansible_sync(@proxy.id, playbooks_names)
end