diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b44ed2..519e166 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,6 @@ image: entrypoint: [""] variables: - PACKER_LOG: 1 # enable detailed logging - PACKER_VAR_FILE: "vars.pkrvars.hcl" PACKER_CONFIG_DIR: $CI_PROJECT_DIR cache: @@ -19,13 +17,14 @@ stages: .parallel: parallel: matrix: - - IMAGE: [ "flatcar" ] + - IMAGE: + - flatcar-stable validate: extends: .parallel stage: validate variables: - PACKER_WORKSPACE: images/$IMAGE + PACKER_WORKSPACE: images script: - packer init $PACKER_WORKSPACE - packer fmt -check $PACKER_WORKSPACE @@ -34,11 +33,7 @@ validate: build-image: extends: .parallel stage: build - variables: - PACKER_FILE: images/$IMAGE/image.pkr.hcl script: - - | - packer build \ - $PACKER_FILE + - packer build $IMAGE.pkr.hcl rules: - if: $CI_COMMIT_BRANCH == "main" diff --git a/README.md b/README.md index a55c7a4..d6e0fd6 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ A collection of custom images on my Hetzner Cloud. ## Images -| **Name** | **Version** | **Path** | -| -------- | ----------------- | ---------------- | -| Flatcar | _Rolling release_ | `images/flatcar` | +| **Name** | **Version** | **Path** | +| :------: | :---------------: | ------------------------------- | +| Flatcar | _Rolling release_ | `images/flatcar-stable.pkr.hcl` | diff --git a/images/flatcar/image.pkr.hcl b/images/flatcar-stable.pkr.hcl similarity index 74% rename from images/flatcar/image.pkr.hcl rename to images/flatcar-stable.pkr.hcl index 2165e72..d4313c8 100644 --- a/images/flatcar/image.pkr.hcl +++ b/images/flatcar-stable.pkr.hcl @@ -2,14 +2,13 @@ packer { required_plugins { hcloud = { source = "github.com/hetznercloud/hcloud" - version = ">= 1.6.0, <= 2.0.0" + version = ">= 1.6.0, < 2.0.0" } } } -variable "channel" { - type = string - default = "stable" +locals { + flatcar_channel = "stable" } variable "hcloud_token" { @@ -37,13 +36,13 @@ build { source "hcloud.flatcar" { name = "x86" server_type = "cx22" - snapshot_name = "flatcar-${var.channel}-amd64-${formatdate("YYYY-MM-DD", timestamp())}" + snapshot_name = "flatcar-${local.flatcar_channel}-amd64-${formatdate("YYYY-MM-DD", timestamp())}" } source "hcloud.flatcar" { name = "arm" server_type = "cax11" - snapshot_name = "flatcar-${var.channel}-arm64-${formatdate("YYYY-MM-DD", timestamp())}" + snapshot_name = "flatcar-${local.flatcar_channel}-arm64-${formatdate("YYYY-MM-DD", timestamp())}" } provisioner "shell" { @@ -54,7 +53,7 @@ build { "chmod +x flatcar-install", # Install flatcar - "./flatcar-install -s -o hetzner -C ${var.channel}", + "./flatcar-install -s -o hetzner -C ${local.flatcar_channel}", ] } }