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.

MethodPathProduces
PATCH/tasks/:task_nameapplication/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:

  1. $ curl --header "Content-Type: application/json" \
  2. --request PATCH \
  3. --data '{"enabled":false}' \
  4. localhost:8558/v1/tasks/task_a

Response:

  1. {}

Example: Inspect enabling a task

Request:

  1. $ curl --header "Content-Type: application/json" \
  2. --request PATCH \
  3. --data '{"enabled":true}' \
  4. localhost:8558/v1/tasks/task_a?run=inspect

Response if no changes present:

  1. {
  2. "changes_present": false,
  3. "plan": "No changes. Infrastructure is up-to-date. <truncated>"
  4. }

Response if changes present:

  1. {
  2. "changes_present": true,
  3. "plan": "<terraform plan truncated> Plan: 3 to add, 0 to change, 0 to destroy."
  4. }