Packer Gitlab CI/CD pipelines #654
-
Hey, was wondering if you worked on a gitlab pipeline to create the templates? trying to re-work some of the code to make it work and running into a few walls. so thought i would ask. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
No, not at this time. |
Beta Was this translation helpful? Give feedback.
-
I have got something working for our internal gitlab setup. Couple of things to note:
Tried to stay inline the gomplate model used for
I run the following command line to build the
There are no changes to the |
Beta Was this translation helpful? Give feedback.
-
This is Amazing.
Thank you. Will give it a look
…On Tue, Sep 19, 2023 at 8:05 AM rcroft-work ***@***.***> wrote:
I have got something working for our internal gitlab setup.
Couple of things to note:
- I trigger builds manually when I update ISO files/checksum
- Below works for me and promises/commitments that it works for your
env.
Tried to stay inline the gomplate model used for build.sh so created a
build-ci.tmpl
##############################################################################
##
## CI/CD for building OVFs in the packer content library on Common Pool
##
##############################################################################
default:
image: "harbor.sydeng.vmware.com/library/packerplus:dev"
variables:
SCRIPT_PATH: "${CI_PROJECT_DIR}"
CONFIG_PATH: "${CI_PROJECT_DIR}/config"
INPUT_PATH: ""
EXTRA_VAR_FILES: ""
BUILD_ONLY: ""
##############################################################################
.packer-build:
stage: build
tags:
- container
before_script:
- "packer init \"$INPUT_PATH\""
# - "packer validate \"$INPUT_PATH\""
script:
- "packer build -force -on-error=ask -var-file=\"$CONFIG_PATH/vsphere.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/build.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/ansible.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/proxy.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/common.pkrvars.hcl\" ${EXTRA_VAR_FILES} ${BUILD_ONLY} \"$INPUT_PATH\""
when: manual
##############################################################################
{{ range $menu := (ds "build").menu -}}
{{ range $submenu := $menu.submenu -}}
{{ $submenu.entry | strings.ReplaceAll " (cloud-init)" "" | strings.ReplaceAll " " "-" | strings.ReplaceAll "---" "-" }}:
extends: .packer-build
variables:
INPUT_PATH: "$SCRIPT_PATH/{{ $submenu.build.path }}"
{{- if (coll.Has $submenu.build "only") }}
BUILD_ONLY: "--only {{ join $submenu.build.only "," }}"
{{- end -}}
{{- if (coll.Has $submenu.build "var_files") -}}
{{ range $submenu.build.var_files }}
EXTRA_VAR_FILES: " -var-file=$CONFIG_PATH/{{ . }}"
{{- end -}}{{- end }}
##############################################################################
{{ end }}{{ end -}}
I run the following command line to build the .gitlab-ci.yml from the
build-ci.tmpl above and the build.yml:
gomplate -c build.yaml -f build-ci.tmpl -o .gitlab-ci.yml
There are no changes to the build.yaml.
—
Reply to this email directly, view it on GitHub
<#654 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGK4OTWU3ULWCF45NAVCETDX3E72DANCNFSM6AAAAAA32GZUUM>
.
You are receiving this because you authored the thread.Message ID:
<vmware-samples/packer-examples-for-vsphere/repo-discussions/654/comments/7042484
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
@rcroft-work please feel free to contribute the example to the project if you like. |
Beta Was this translation helpful? Give feedback.
I have got something working for our internal gitlab setup.
Couple of things to note:
Tried to stay inline the gomplate model used for
build.sh
so created abuild-ci.tmpl