From 7d7117281ce6f65c8ccf312e186325b9c33ba407 Mon Sep 17 00:00:00 2001 From: ramonskie Date: Thu, 24 Sep 2026 14:25:54 +0200 Subject: [PATCH 1/2] Add generic tags ops file Adds misc/tags.yml, a reusable ops file that applies a map of tags to every instance in a deployment through the top-level tags key. The BOSH director forwards deployment tags to the CPI as instance metadata. On GCP the google CPI surfaces them as resource labels (visible in cost/billing reports); other CPIs map them onto their own resource metadata (for example AWS EC2 tags). The file takes a single tags map variable so it is not tied to a particular key schema and can be shared by any deployment. Usage: bosh deploy ... -o misc/tags.yml --vars-file tags.yml --- README.md | 1 + misc/tags.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 misc/tags.yml diff --git a/README.md b/README.md index 381518590..f3d7c8a72 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ Other releases such as [UAA](https://github.com/cloudfoundry/uaa-release), [Cred - `misc/proxy.yml`: Configure HTTP proxy for Director and CPI - `misc/dns.yml`: Configure your upstream DNS (NOTE: by default bosh-deployment uses Google DNS: 8.8.8.8) - `misc/ntp.yml`: Configure your NTP Servers (NOTE: by default bosh-deployment uses Google NTP servers: time{1-4}.google.com +- `misc/tags.yml`: Apply metadata tags to every instance in a deployment (on GCP these are surfaced as resource labels) - `runtime-configs/syslog.yml`: Runtime config to enable syslog forwarding See [tests/run-checks.sh](tests/run-checks.sh) for example usage of different ops files. diff --git a/misc/tags.yml b/misc/tags.yml new file mode 100644 index 000000000..55f81caca --- /dev/null +++ b/misc/tags.yml @@ -0,0 +1,26 @@ +--- + +# Apply metadata tags to every instance in the deployment. +# +# The BOSH Director forwards deployment tags to the CPI as instance metadata. +# On GCP the google CPI surfaces them as resource labels, which makes them +# visible in billing/cost reports; other CPIs map them onto their own resource +# metadata (for example AWS EC2 tags). +# +# Usage: +# +# bosh deploy ... -o misc/tags.yml --vars-file tags.yml +# +# where tags.yml defines a map, for example: +# +# tags: +# pipeline: bosh-deployment +# environment: my-env +# +# `tags` is a map, so it must be supplied with --vars-file (a --var/-v value is +# always a string). Any tags defined directly in the deployment manifest are +# replaced by this ops file. + +- type: replace + path: /tags? + value: ((tags)) From e3402f847cffad03bed2372c5d101f19764f03d8 Mon Sep 17 00:00:00 2001 From: ramonskie Date: Thu, 24 Sep 2026 16:32:28 +0200 Subject: [PATCH 2/2] Rename the tags ops file variable to deployment_tags `tags` is already used by the CPI ops files (gcp/cpi.yml, gcp/cloud-config.yml) for VM network tags, which are a list. Reusing the same name for the deployment tag map collides: when a single `tags` value is supplied, both interpolations cannot be satisfied (list vs map). Rename the variable to `deployment_tags` and correct the usage docs: a JSON map can be passed with `-v`, not only with `--vars-file`. Also note the variable choice in the README entry. --- README.md | 2 +- misc/tags.yml | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f3d7c8a72..6163d71e0 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Other releases such as [UAA](https://github.com/cloudfoundry/uaa-release), [Cred - `misc/proxy.yml`: Configure HTTP proxy for Director and CPI - `misc/dns.yml`: Configure your upstream DNS (NOTE: by default bosh-deployment uses Google DNS: 8.8.8.8) - `misc/ntp.yml`: Configure your NTP Servers (NOTE: by default bosh-deployment uses Google NTP servers: time{1-4}.google.com -- `misc/tags.yml`: Apply metadata tags to every instance in a deployment (on GCP these are surfaced as resource labels) +- `misc/tags.yml`: Apply deployment tags to every instance in a deployment (var: `deployment_tags`; on GCP these are surfaced as resource labels) - `runtime-configs/syslog.yml`: Runtime config to enable syslog forwarding See [tests/run-checks.sh](tests/run-checks.sh) for example usage of different ops files. diff --git a/misc/tags.yml b/misc/tags.yml index 55f81caca..da4e3662f 100644 --- a/misc/tags.yml +++ b/misc/tags.yml @@ -1,6 +1,6 @@ --- -# Apply metadata tags to every instance in the deployment. +# Apply deployment tags to every instance in the deployment. # # The BOSH Director forwards deployment tags to the CPI as instance metadata. # On GCP the google CPI surfaces them as resource labels, which makes them @@ -9,18 +9,23 @@ # # Usage: # -# bosh deploy ... -o misc/tags.yml --vars-file tags.yml +# bosh deploy ... -o misc/tags.yml \ +# -v 'deployment_tags={"pipeline":"bosh-deployment","environment":"my-env"}' # -# where tags.yml defines a map, for example: +# or supply a vars file: # -# tags: +# # tags.yml +# deployment_tags: # pipeline: bosh-deployment # environment: my-env # -# `tags` is a map, so it must be supplied with --vars-file (a --var/-v value is -# always a string). Any tags defined directly in the deployment manifest are -# replaced by this ops file. +# bosh deploy ... -o misc/tags.yml --vars-file tags.yml +# +# The variable is named `deployment_tags` rather than `tags` because `tags` is +# already used by the CPI ops files (for example gcp/cpi.yml) for VM network +# tags. Any tags defined directly in the deployment manifest are replaced by +# this ops file. - type: replace path: /tags? - value: ((tags)) + value: ((deployment_tags))