Tasks
The /tasks
endpoints modify the tasks that Consul-Terraform-Sync is responsible for running.
Update Task
This endpoint allows patch updates to specifically supported fields for existing tasks. Currently only supports updating a task’s enabled value.
Method | Path | Produces |
---|---|---|
PATCH | /tasks/:task_name | application/json |
Request Parameters
- run - (string) Values can be only be “inspect” and “now”.
- “inspect”: Does not update the task but returns information on if/how resources would be changed for the proposed task update.
- “now”: Updates the task accordingly and immediately runs the task, rather than allowing the task to run at the natural daemon cadence
Response Fields
- inspect - Information on how resources would be changed given a proposed task update, similar to inspect-mode. This is only returned when passed the
run=inspect
request parameter- changes_present - (bool) Whether or not changes were detected for running the proposed task update
- plan - (string) The Terraform plan generated for the proposed task update . Note: a non-empty string does not necessarily indicate changes were detected.
Example: Disable a task
Request:
$ curl --header "Content-Type: application/json" \
--request PATCH \
--data '{"enabled":false}' \
localhost:8558/v1/tasks/task_a
Response:
{}
Example: Inspect enabling a task
Request:
$ curl --header "Content-Type: application/json" \
--request PATCH \
--data '{"enabled":true}' \
localhost:8558/v1/tasks/task_a?run=inspect
Response if no changes present:
{
"changes_present": false,
"plan": "No changes. Infrastructure is up-to-date. <truncated>"
}
Response if changes present:
{
"changes_present": true,
"plan": "<terraform plan truncated> Plan: 3 to add, 0 to change, 0 to destroy."
}