Class: PEClient::Resource::OrchestratorV1::Command
- Defined in:
- lib/pe_client/resources/orchestrator.v1/command.rb
Overview
Use the command endpoints to run Puppet, jobs, and plans on demand or stop in-progress jobs. You can also create task-targets, which provide privilege escalation for users who would otherwise not be able to run certain tasks or run tasks on certain nodes or node groups.
Constant Summary collapse
- BASE_PATH =
The base path for OrchestratorV1 API v1 Command endpoints.
"#{OrchestratorV1::BASE_PATH}/command".freeze
Instance Method Summary collapse
-
#deploy(environment:, scope: nil, concurrency: nil, debug: nil, description: nil, enforce_environment: nil, evaltrace: nil, filetimeout: nil, http_connect_timeout: nil, http_keepalive_timeout: nil, http_read_timeout: nil, noop: nil, no_noop: nil, ordering: nil, skip_tags: nil, tags: nil, timeout: nil, trace: nil, use_cached_catalog: nil, usecacheonfailure: nil, userdata: nil) ⇒ Hash
Run Puppet on demand – run the orchestrator across all nodes in an environment.
-
#environment_plan_run(plan_name:, params:, environment: nil, description: nil, timeout: nil, userdata: nil) ⇒ Hash
Use parameters to run a plan on specific nodes in a specific environment.
-
#plan_run(plan_name:, params: nil, environment: nil, description: nil, timeout: nil, userdata: nil) ⇒ Hash
Use the plan executor to run a plan.
-
#stop(job:, force: nil) ⇒ Hash
Stop an orchestrator job that is currently in progress.
-
#stop_plan(plan_job:) ⇒ Hash
Stop an orchestrator plan job that is currently in progress.
-
#task(environment:, scope:, params:, targets:, task:, timeout: nil, description: nil, noop: nil, userdata: nil) ⇒ Hash
Run a task on a set of nodes.
-
#task_target(display_name:, tasks: nil, all_tasks: nil, nodes: [], node_groups: [], pql_query: nil) ⇒ Hash
Create a task-target, which is a set of tasks and nodes/node groups you can use to provide specific privilege escalation for users who would otherwise not be able to run certain tasks or run tasks on certain nodes or node groups.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#deploy(environment:, scope: nil, concurrency: nil, debug: nil, description: nil, enforce_environment: nil, evaltrace: nil, filetimeout: nil, http_connect_timeout: nil, http_keepalive_timeout: nil, http_read_timeout: nil, noop: nil, no_noop: nil, ordering: nil, skip_tags: nil, tags: nil, timeout: nil, trace: nil, use_cached_catalog: nil, usecacheonfailure: nil, userdata: nil) ⇒ Hash
Run Puppet on demand – run the orchestrator across all nodes in an environment.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 69 def deploy(environment:, scope: nil, concurrency: nil, debug: nil, description: nil, enforce_environment: nil, evaltrace: nil, filetimeout: nil, http_connect_timeout: nil, http_keepalive_timeout: nil, http_read_timeout: nil, noop: nil, no_noop: nil, ordering: nil, skip_tags: nil, tags: nil, timeout: nil, trace: nil, use_cached_catalog: nil, usecacheonfailure: nil, userdata: nil) @client.post("#{BASE_PATH}/deploy", body: { environment:, scope:, concurrency:, debug:, description:, enforce_environment:, evaltrace:, filetimeout:, http_connect_timeout:, http_keepalive_timeout:, http_read_timeout:, noop:, no_noop:, ordering:, skip_tags:, tags:, timeout:, trace:, use_cached_catalog:, usecacheonfailure:, userdata: }.compact) end |
#environment_plan_run(plan_name:, params:, environment: nil, description: nil, timeout: nil, userdata: nil) ⇒ Hash
Use parameters to run a plan on specific nodes in a specific environment.
207 208 209 210 211 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 207 def environment_plan_run(plan_name:, params:, environment: nil, description: nil, timeout: nil, userdata: nil) @client.post("#{BASE_PATH}/environment_plan_run", body: { plan_name:, params:, environment:, description:, timeout:, userdata: }.compact) end |
#plan_run(plan_name:, params: nil, environment: nil, description: nil, timeout: nil, userdata: nil) ⇒ Hash
Use the plan executor to run a plan.
188 189 190 191 192 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 188 def plan_run(plan_name:, params: nil, environment: nil, description: nil, timeout: nil, userdata: nil) @client.post("#{BASE_PATH}/plan_run", body: { plan_name:, params:, environment:, description:, timeout:, userdata: }.compact) end |
#stop(job:, force: nil) ⇒ Hash
Stop an orchestrator job that is currently in progress.
86 87 88 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 86 def stop(job:, force: nil) @client.post("#{BASE_PATH}/stop", body: {job:, force:}.compact) end |
#stop_plan(plan_job:) ⇒ Hash
Stop an orchestrator plan job that is currently in progress. This command interrupts the thread that is running the plan. If the plan doesn’t have code to explicitly handle the interrupt, the plan finishes with an error. If the plan can handle the interrupt, whether or not the plan stops depends on the plan’s interruption handling. If the plan is running a task (or otherwise) when interrupted, an error occurs and the plan stops, but the underlying in-progress task job finishes. If you need to force stop an in-progress job, use #stop.
100 101 102 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 100 def stop_plan(plan_job:) @client.post("#{BASE_PATH}/stop_plan", body: {plan_job:}) end |
#task(environment:, scope:, params:, targets:, task:, timeout: nil, description: nil, noop: nil, userdata: nil) ⇒ Hash
Run a task on a set of nodes. The task does not run on any nodes in the defined scope that you do not have permission to run tasks on.
129 130 131 132 133 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 129 def task(environment:, scope:, params:, targets:, task:, timeout: nil, description: nil, noop: nil, userdata: nil) @client.post("#{BASE_PATH}/task", body: { environment:, scope:, params:, targets:, task:, timeout:, description:, noop:, userdata: }.compact) end |
#task_target(display_name:, tasks: nil, all_tasks: nil, nodes: [], node_groups: [], pql_query: nil) ⇒ Hash
While pql_query is optional, if you only use pql_query to define the nodes in the task-target, you must supply nodes and node_groups as empty arrays.
Create a task-target, which is a set of tasks and nodes/node groups you can use to provide specific privilege escalation for users who would otherwise not be able to run certain tasks or run tasks on certain nodes or node groups. When you grant a user permission to use a task-target, the user can run the task(s) in the task-target on the set of nodes defined in the task-target.
168 169 170 171 172 173 174 |
# File 'lib/pe_client/resources/orchestrator.v1/command.rb', line 168 def task_target(display_name:, tasks: nil, all_tasks: nil, nodes: [], node_groups: [], pql_query: nil) raise ArgumentError, "Either `tasks` or `all_tasks` must be provided" if tasks.nil? && all_tasks.nil? @client.post("#{BASE_PATH}/task_target", body: { display_name:, tasks:, all_tasks:, nodes:, node_groups:, pql_query: }.compact) end |