Consul-Terraform-Sync 태스크 CLI 참조
Consul-Terraform-Sync 태스크 CLI 참조 (task command)
Consul-Terraform-Sync(CTS)의 task 하위 명령들(create, enable, disable, delete)에 대한 참조 문서예요.
출처: 문서
본문
task create
task create 명령은 새 태스크를 만들어 실행되고 태스크 리소스를 업데이트하도록 해요. 이 명령은 태스크가 생성될 경우 리소스가 어떻게 수정될지에 대한 Terraform 플랜을 생성하고 출력해요(inspect-mode와 유사). 그런 다음 명령은 태스크를 만들기 전에 사용자 승인을 요청해요.
태스크를 업데이트하는 데는 사용되지 않으며, 태스크 이름이 이미 존재하면 태스크를 만들지 않아요.
사용법 (Usage)
consul-terraform-sync task create [options] -task-file=<task config>
옵션:
일반 옵션 외에도 이 명령은 다음을 지원해요:
| 이름 | 필수 | 유형 | 설명 |
|---|---|---|---|
-task-file |
필수 | string | 태스크 구성 파일의 경로. 자세한 내용은 구성 정보를 참고하세요. |
-auto-approve |
선택 | boolean | 생성 전에 플랜의 대화형 승인을 건너뛸지 여부. |
예시 (Example)
task_example.hcl:
task {
name = "task_a"
description = ""
enabled = true
providers = []
module = "org/example/module"
version = "1.0.0"
variable_files = []
condition "services" {
names = ["web", "api"]
}
}
셸 세션:
$ consul-terraform-sync task create -task-file=task_example.hcl
==> Inspecting changes to resource if creating task 'task_a'...
Generating plan that Consul-Terraform-Sync will use Terraform to execute
Request ID: 1da3e8e0-87c3-069b-51a6-46903e794a76
Request Payload:
// <request payload truncated>
Plan:
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
// <diff truncated>
Plan: 1 to add, 0 to change, 0 to destroy.
==> Creating the task will perform the actions described above.
Do you want to perform these actions for 'task_a'?
- This action cannot be undone.
- Consul-Terraform-Sync cannot guarantee Terraform will perform
these exact actions if monitored services have changed.
Only 'yes' will be accepted to approve, enter 'no' or leave blank to reject.
Enter a value: yes
==> Creating and running task 'api-task'...
The task creation request has been sent to the CTS server.
Please be patient as it may take some time to refer to a confirmation that this task has completed.
Warning: Terminating this process will not stop task creation.
==> Task 'task_a' created
Request ID: '78eddd74-0f08-83d6-72b2-6aaac1424fba'
task enable
task enable 명령은 기존 태스크를 활성화해 실행되고 태스크 리소스를 업데이트하도록 해요. 태스크가 이미 활성화되어 있다면 성공을 반환해요. 이 명령은 태스크가 활성화될 경우 리소스가 어떻게 수정될지에 대한 Terraform 플랜을 생성하고 출력해요(inspect-mode와 유사). 리소스 변경이 감지되면 명령은 태스크를 활성화하기 전에 사용자 승인을 요청해요. 리소스가 감지되지 않으면 명령은 태스크를 활성화해요.
사용법 (Usage)
consul-terraform-sync task enable [options] <task_name>
인자:
| 이름 | 필수 | 유형 | 설명 |
|---|---|---|---|
task_name |
필수 | string | 활성화할 태스크의 이름. |
옵션:
일반 옵션 외에도 이 명령은 다음을 지원해요:
| 이름 | 필수 | 유형 | 설명 |
|---|---|---|---|
-auto-approve |
선택 | boolean | 활성화 전에 플랜의 대화형 승인을 건너뛸지 여부. |
예시 (Example)
$ consul-terraform-sync task enable task_a
==> Inspecting changes to resource if enabling 'task_a'...
Generating plan that Consul-Terraform-Sync will use Terraform to execute
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
// <diff truncated>
Plan: 3 to add, 0 to change, 0 to destroy.
==> Enabling the task will perform the actions described above.
Do you want to perform these actions for 'task_a'?
- This action cannot be undone.
- Consul-Terraform-Sync cannot guarantee Terraform will perform
these exact actions if monitored services have changed.
Only 'yes' will be accepted to approve.
Enter a value: yes
==> Enabling and running 'task_a'...
==> 'task_a' enable complete!
task disable
task disable 명령은 기존 태스크를 비활성화해 더 이상 실행되고 태스크 리소스를 업데이트하지 않도록 해요. 태스크가 이미 비활성화되어 있다면 성공을 반환해요.
사용법 (Usage)
consul-terraform-sync task disable [options] <task_name>
인자:
| 이름 | 필수 | 유형 | 설명 |
|---|---|---|---|
task_name |
필수 | string | 비활성화할 태스크의 이름. |
옵션: 현재는 일반 옵션만 지원해요.
예시 (Example)
$ consul-terraform-sync task disable task_b
==> Waiting to disable 'task_b'...
==> 'task_b' disable complete!
task delete
task delete 명령은 기존 태스크를 삭제해요. 명령은 태스크를 삭제하기 전에 사용자 승인을 요청해요. 태스크는 삭제 대상으로 표시되며, 실행 중이 아니면 즉시 삭제돼요. 그렇지 않으면 태스크가 완료된 후 삭제돼요.
참고
태스크를 삭제한다고 해서 태스크가 관리하던 인프라가 파괴되지는 않아요.
사용법 (Usage)
consul-terraform-sync task delete [options] <task_name>
인자:
| 이름 | 필수 | 유형 | 설명 |
|---|---|---|---|
task_name |
필수 | string | 삭제할 태스크의 이름. |
옵션:
일반 옵션 외에도 이 명령은 다음을 지원해요:
| 이름 | 필수 | 유형 | 설명 |
|---|---|---|---|
-auto-approve |
선택 | boolean | 태스크 삭제의 대화형 승인을 건너뛸지 여부. |
예시 (Example)
$ consul-terraform-sync task delete task_a
==> Do you want to delete 'task_a'?
- This action cannot be undone.
- Deleting a task will not destroy the infrastructure managed by the task.
- If the task is not running, it will be deleted immediately.
- If the task is running, it will be deleted once it has completed.
Only 'yes' will be accepted to approve, enter 'no' or leave blank to reject.
Enter a value: yes
==> Marking task 'task_a' for deletion...
==> Task 'task_a' has been marked for deletion and will be deleted when not running.