ManageIQ / manageiq-automation_engine

Automation engine for ManageIQ
Apache License 2.0
11 stars 74 forks source link

Change automate methods to communicate via REST API #44

Open miq-bot opened 7 years ago

miq-bot commented 7 years ago

Much of this was discussed at the ManageIQ design summit for Botvinnik. However, @mkanoor and I recently sat down and brainstormed our way through many of the larger problems, and we think we've come to a cleaner design.

There may be more things I'm not thinking of, but I just wanted to start getting this information out there. Let's keep this document updated as we find more issues and/or come up with more ways to solve them.


Automate currently runs methods by

This causes a number of problems and headaches, which may be able to be addressed by moving to a REST API based implementation. Some notable issues:

Other thoughts:


TODO

cc @gmcculloug @mkanoor @tinaafitz @chessbyte cc @abellotti (re: REST API stuff and cfme_client split out into manageiq_client gem) cc @kbrock (re: system-only access rules)


This issue was moved to this repository from https://github.com/ManageIQ/manageiq/issues/2215, originally opened by @Fryguy

kbrock commented 7 years ago

The preamble is currently cut and pasted into a customer's scripts. Alternatively, it could be implemented as a parent class.

What user would automate methods run as

We (always?) pass the requesting/effective user to automate. This is needed for tenancy.

One thing to keep in mind. When a user does not have privileges to perform an operation, the user makes a request from automate to perform the operation on their behalf. So it is essentially a mechanism to escalated privileges.

So ignoring the fact that we don't have the user's password, we also don't properly establish the escalated user's identity when running automate methods.

UPDATE: not positive this is the intent of automate.

Fryguy commented 7 years ago

The preamble is currently cut and pasted into a customer's scripts. Alternatively, it could be implemented as a parent class.

Oh that's really interesting.

miq-bot commented 6 years ago

This issue has been automatically marked as stale because it has not been updated for at least 6 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions!

mkanoor commented 4 years ago

For Ansible Playbooks we have enhanced the REST-API to allow access to the Automate Workspace. https://www.manageiq.org/docs/reference/latest/api/reference/automate_workspaces

The engine creates a token and passes the token to the Ansible Playbook as an extra var which can be used by the playbook to connect to our REST API and access the workspace, update the workspace and also pass back updates to the workspace.

kbrock commented 4 years ago

Overview

When an automate method is called, a workspace ( MiqAeWorkspaceRuntime) is created and it is wrapped by an MiqAeService object. This is stored in an in-memory hash in the server process.

drb spawns a child process and the child process obtains a drb reference to the MiqAeService instance (living in server memory) and stores it in the $evm variable. The MiqAeService instance provides the child process with access to manageiq database and services.

Again: All manageiq provided services are provided from within the server process, accessible via $evm over drb.

Goal

Getting away from relying upon drb needs 2 steps:

  1. Access differently: Convert $evm to be a client side object
  2. Spawn Differently: Kick off automate scripts with something other than drb.

Benefits:

  1. Remove the need for a separate Automate Service Model API.
  2. Enhance the existing ReST API to provide more functionality to all
  3. ReST is more container friendly than drb.
  4. Remove drb which fixes some memory peculiarities.
  5. HTTP allows an easier worker pool model than our current spawning a process for every automate request.

Access

The client will be able to perform some functionality without the server. These methods will be moved into the child process. Other functions require the server. Some of these include sending mail, or a typical database access layer.

function new approach comment
exit
raise errors that are raised
enable_rbac unneeded
disconnect_sql unneeded
log() keep, simplified. $stdout, $stderr too
get_state_var helper into workspace?
ansible_stats_vars

Concepts needed:

Spawn

We currently have a number of ways of invoking automate.

  1. From automate (remote task, local task)
  2. Inline to populate dialogs
  3. an external event (like Vm creation) triggers an event

Also there are a number of templates to invoke:

  1. ansible
  2. automate