public function index()
 {
     $tasks = Tasks::orderBy('id', 'desc')->paginate(10);
     $invs = Inventories::select("name", "id")->get();
     $templates = Templates::select("name", "id")->get();
     return view("jobs.index", compact("invs", "templates", "tasks"));
 }
 public function edit_post(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required', 'noidung' => 'required']);
     $inv = Inventories::findorFail($id);
     $inv->name = $request->name;
     $inv->content = $request->noidung;
     $inv->save();
     return \Redirect::to(route("inventories"))->with('success', "Profile updated success.");
 }
Example #3
0
 public static function createJob($request)
 {
     $inv = Inventories::find($request->iid);
     $job = new Tasks();
     $job->iid = $request->iid;
     $job->tid = $request->tid;
     $job->vars = $request->vars;
     $job->sudo = $request->sudo;
     $job->hosts = $request->hosts;
     $job->save();
     $pid = $job->id;
     $vars = json_decode($job->vars);
     file_put_contents(storage_path("roles/inv{$pid}"), $inv->content);
     file_put_contents(storage_path("roles/yml{$pid}"), View::make("jobs.yml", compact("job", "pid", "vars"))->render());
     file_put_contents(storage_path("tmp/log" . $pid . ".txt"), "");
     dispatch(new runAnsible($job->id));
     return $job->id;
 }