HeavyHorst / remco

remco is a lightweight configuration management tool

Home Page:https://heavyhorst.github.io/remco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getv from consul-service

freeseacher opened this issue · comments

Hi, I want to get a consul service from the consul.
my config

log_level = "debug"
log_file = ""
filter_dir = "/etc/remco/filters.d"

[[resource]]
  name = "test"

  [[resource.template]]
    src = "templates/aaa.tmpl"
    dst = "/tmp/out.txt"
    mode = "0644"

  [resource.backend]
    [[resource.backend.plugin]]
      path = "/etc/remco/plugins/consul-service"
      interval = 60
      keys = ["consul",]
      onetime = false
      [resource.backend.plugin.config]
	 addr = "127.0.0.1:8500"

my template

{{ getallkvs() | toPrettyJSON }}
{{ getv("service-name") }}

But I only get service defined in keys, not service-name. Some debug shows me that getv args is not propagated to pie and did not pass to plugin code
My target template should be something like

{% set all_svc = ?? get_all_svc_with_tag ?? %}
{% for svc in all_svc %}
location /{{svc.name}}/ {
 proxy_pass {{svc.addr}
}
{% endfor %}

ok. is find a solution :)
i've switched to

{% set prefix = "/_consul/service/service-name" %}
{% set shard_map = createMap() %}
{% for key in ls(prefix) %}

that works for me