breakpoint 프로비저너

breakpoint 프로비저너

breakpoint 프로비저너는 Enter 키를 눌러 빌드를 재개할 때까지 빌드 작업을 일시 중지시켜 주는 공식 프로비저너예요. 오류를 디버깅할 때 유용하게 사용할 수 있어요.

출처: Packer 공식 문서

본문

대신 빌드를 실행할 때 -debug 플래그를 추가하면, 모든 단계와 모든 프로비저너 사이에서 작업을 멈추게 할 수도 있어요.

기본 예시 (Basic Example)

HCL2와 JSON:

source "null" "example" {
  communicator = "none"
}

build {
  sources = ["source.null.example"]

  provisioner "shell-local" {
    inline = ["echo hi"]
  }
  provisioner "breakpoint" {
    disable = false
    note    = "this is a breakpoint"
  }
  provisioner "shell-local" {
    inline = ["echo hi 2"]
  }
}
{
  "builders": [
    {
      "type": "null",
      "communicator": "none"
    }
  ],
  "provisioners": [
    {
      "type": "shell-local",
      "inline": "echo hi"
    },
    {
      "type": "breakpoint",
      "disable": false,
      "note": "this is a breakpoint"
    },
    {
      "type": "shell-local",
      "inline": "echo hi 2"
    }
  ]
}

구성 참조 (Configuration Reference)

선택 (Optional)

  • disable (boolean) - true면 브레이크포인트를 건너뛰어요. 여러 브레이크포인트를 설정해두고 켜고 끌 때 유용해요. 기본값: false
  • note (string) - 브레이크포인트의 목적이나 위치를 설명하는 문자열이에요. 예를 들어 브레이크포인트에 번호를 매기거나 빌드 중 어디서 발생하는지 정보를 라벨로 붙이는 것이 유용할 수 있어요.

모든 프로비저너에 공통인 파라미터:

  • pause_before (duration) - 실행 전에 해당 시간만큼 대기해요.
  • max_retries (int) - 실패 시 프로비저너가 재시도할 최대 횟수. 기본값은 0. 0이면 오류를 재시도하지 않아요.
  • only (array of string) - 나열된 빌더에 대해서만 이름으로 프로비저너를 실행해요.
  • override (object) - 특정 빌더에 다른 설정으로 빌더를 오버라이드해요. 예:

HCL2에서:

source "null" "example1" {
  communicator = "none"
}

source "null" "example2" {
  communicator = "none"
}

build {
  sources = ["source.null.example1", "source.null.example2"]
  provisioner "shell-local" {
    inline = ["echo not overridden"]
    override = {
      example1 = {
        inline = ["echo yes overridden"]
      }
    }
  }
}

JSON에서:

{
  "builders": [
    {
      "type": "null",
      "name": "example1",
      "communicator": "none"
    },
    {
      "type": "null",
      "name": "example2",
      "communicator": "none"
    }
  ],
  "provisioners": [
    {
      "type": "shell-local",
      "inline": ["echo not overridden"],
      "override": {
        "example1": {
          "inline": ["echo yes overridden"]
        }
      }
    }
  ]
}
  • timeout (duration) - 프로비저너가 예를 들어 1h10m1s나 10m보다 오래 걸리면 타임아웃되어 실패해요.

사용법 (Usage)

빌드를 일시 중지하고 싶은 곳 어디든 이 프로비저너를 넣으면 돼요. 준비가 되면 "enter"를 눌러 빌드를 계속하라고 안내하는 ui 출력이 보일 거예요.

예를 들어:

==> docker: Pausing at breakpoint provisioner with note "foo bar baz".
==> docker: Press enter to continue.

Enter를 누르면 빌드가 재개되어 완료되거나 오류가 날 때까지 정상적으로 실행돼요.