Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template - byTag doesn't work for nomadServices #13459

Closed
heapdavid opened this issue Jun 22, 2022 · 3 comments
Closed

Template - byTag doesn't work for nomadServices #13459

heapdavid opened this issue Jun 22, 2022 · 3 comments
Assignees
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/consul-template type/bug
Milestone

Comments

@heapdavid
Copy link

heapdavid commented Jun 22, 2022

Nomad version

Nomad v1.3.1 (2b054e38e91af964d1235faa98c286ca3f527e56)

Operating system and Environment details

Debian 11

Issue

Firstly, thank you so much for Nomad Service Discovery. I'm trying to create a few small, simple clusters for different projects and it felt like Consul etc was overkill.

I'm looking to create a config file which only includes services which have a specific tag. This was working with Consul using the byTag function. I've tried converting my template stanza from

{{ range $tag, $services := services | byTag }}

to

{{ range $tag, $services := nomadServices | byTag }}

Expected Result

Iteration through services and tags as with Consul services

Actual Result

Template failed: (dynamic): execute: template: :4:42:  executing "" at <byTag>: error calling byTag: byTag: wrong  argument type []*dependency.NomadServicesSnippet

Job file (if appropriate)

The full template section:

      template {
        data = <<EOH
{{ range $tag, $services := nomadServices | byTag }}{{ if eq $tag "caddy.enable=true" }}
{{ range $services }}
http://{{ .Name }}-nomad-test.domain.tld {
  reverse_proxy {{ range nomadService .Name }}{{ .Address }}:{{ .Port }} {{ end }}
}
{{ end }}
{{ end }}
{{ end }}
EOH
        destination = "configs/Caddyfile"
        change_mode = "restart"
      }
@shoenig
Copy link
Member

shoenig commented Jun 23, 2022

Thanks for reporting @heapdavid! We may have just overlooked this feature when adding Nomad support to consul-template.

@shoenig shoenig added theme/consul-template stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Jun 23, 2022
@shoenig shoenig added this to the 1.4.0 milestone Jun 23, 2022
@jrasell jrasell modified the milestones: 1.4.0, 1.4.x Sep 22, 2022
@jrasell
Copy link
Member

jrasell commented Feb 27, 2023

Hi @heapdavid and apologies on the delay in getting this information out. The consul-template dependency was updated as part of the Nomad 1.3.0 release and included the feature that allows this to work. I'll therefore close this issue as complete. If you continue to have problems, please let us know by opening a new issue, or re-opening this one.

Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/consul-template type/bug
Projects
Development

No branches or pull requests

3 participants