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

global BackendConfigs #15

Closed
kfix opened this issue Oct 16, 2017 · 6 comments
Closed

global BackendConfigs #15

kfix opened this issue Oct 16, 2017 · 6 comments

Comments

@kfix
Copy link

kfix commented Oct 16, 2017

Could it be possible to have a shared set of default configs for all of the backends, so they wouldn't have to be redeclared for each Resource?

This would allow a setup more like confd. but could be overridden on a per-resource basis

example config.toml:

log_level   = "debug"
log_format  = "json"
include_dir = "/etc/remco/resource.d/"
pid_file    = "/var/run/remco/remco.pid"
log_file    = "" # stdout

[backends.file]
filepath    = "/defaults.yml"
watch       = true
keys        = "/"
# any access to / will use this yml, if not overidden

[[resource]]
  name = "haproxy"
  [[resource.template]]
    src         = "/etc/remco/templates/haproxy.cfg"
    dst         = "/etc/haproxy/haproxy.cfg"
    check_cmd   = "somecommand"
    reload_cmd  = "somecommand"
    mode        = "0644"
    # will be using defaults.yml

   [[resource.template]]
    src         = "/etc/remco/templates/haproxy.cfg"
    dst         = "/etc/haproxy/haproxy-dev.cfg"
    check_cmd   = "somecommand"
    reload_cmd  = "somecommand"
    mode        = "0644"
    [resource.backend]
      [resource.backend.file]
          filepath = "/dev.yml"
          watch = true
          keys = "/"
@HeavyHorst
Copy link
Owner

Yes, that should be possible.
I think it would be best to set the default values per resource and not global for all resources.

maybe like this:

log_level   = "debug"
log_format  = "json"
include_dir = "/etc/remco/resource.d/"
pid_file    = "/var/run/remco/remco.pid"
log_file    = "" # stdout

[[resource]]
  name = "haproxy"

 [resource.default_template]
     mode = "744"
     [backends.file]
        filepath    = "/defaults.yml"
        watch       = true
        keys        = "/"
       # any access to / will use this yml, if not overidden

  [[resource.template]]
    src         = "/etc/remco/templates/haproxy.cfg"
    dst         = "/etc/haproxy/haproxy.cfg"
    check_cmd   = "somecommand"
    reload_cmd  = "somecommand"
    mode        = "0644"
    # will be using defaults.yml

   [[resource.template]]
    src         = "/etc/remco/templates/haproxy.cfg"
    dst         = "/etc/haproxy/haproxy-dev.cfg"
    check_cmd   = "somecommand"
    reload_cmd  = "somecommand"
    mode        = "0644"
    [resource.backend]
      [resource.backend.file]
          filepath = "/dev.yml"
          watch = true
          keys = "/"

what do you think ?

@kfix
Copy link
Author

kfix commented Oct 17, 2017

Thanks for reviewing!
I'm just finding the remco / confd syntax very verbose compared to salt (which I ended up using).

If all my resources use the same backends, but different keys perhaps, why should they all have to fully-address the same backend on their own?

Its worth pointing out that I'm trying to use remco to configure multiple resources on a real Ubuntu instance, not just a single microservice.
It seems that microservice setup is confd / remco's typical use case.

You can close if this doesn't interest you, I'm too clueless with Go to implement a PR myself.

@HeavyHorst
Copy link
Owner

I am definitely interested in such a possibility and see how it can be useful.

log_level   = "debug"
log_format  = "json"
include_dir = "/etc/remco/resource.d/"
pid_file    = "/var/run/remco/remco.pid"
log_file    = "" # stdout

 [default_template]
     src = "/etc/remco/templates/haproxy.cfg"
     mode = "644"
     [backends.file]
        filepath    = "/defaults.yml"
        watch       = true
        keys        = "/"
       # any access to / will use this yml, if not overidden

[[resource]]
  name = "haproxy"

  [[resource.template]]
    dst         = "/etc/haproxy/haproxy.cfg"
    check_cmd   = "somecommand"
    reload_cmd  = "somecommand"
    # will be using defaults.yml

   [[resource.template]]
    dst         = "/etc/haproxy/haproxy-dev.cfg"
    check_cmd   = "somecommand"
    reload_cmd  = "somecommand"
    [resource.backend]
      [resource.backend.file]
          filepath = "/dev.yml"
          watch = false
          keys = "/someotherkey"

what do you think about this format?

@HeavyHorst
Copy link
Owner

It is now possible to set global default backend settings:

      log_level = "debug"
      log_format = "text"
      include_dir = "/tmp/resource.d/"
      
      [default_backends]
      [default_backends.file]
          onetime  = true
          prefix   = "/bla"

@fardin01
Copy link

It is now possible to set global default backend settings:

      log_level = "debug"
      log_format = "text"
      include_dir = "/tmp/resource.d/"
      
      [default_backends]
      [default_backends.file]
          onetime  = true
          prefix   = "/bla"

@HeavyHorst So when default backend is a file, there is no filepath? It's not in the documentation, but I don't understand who remco can figure out which file to use. Then I set filepath for it, and the configuration data isn't found .

@HeavyHorst
Copy link
Owner

filepath should work fine.
The default backend configs can take the same values as the other configs.

Here is an example:

  #remco.toml                                                                                                                                                                                                   
  ################################################################                                                                                                                                              
  # Global configuration                                                                                                                                                                                        
  ################################################################                                                                                                                                              
  log_level   = "debug"                                                                                                                                                                                         
  log_format  = "text"                                                                                                                                                                                          
                                                                                                                                                                                                                
  [default_backends]                                                                                                                                                                                            
  [default_backends.file]                                                                                                                                                                                       
          filepath = "/home/rkaufmann/Downloads/test.yml"                                                                                                                                                       
          onetime  = true                                                                                                                                                                                       
          keys     = [""]                                                                                                                                                                                       
                                                                                                                                                                                                                
  ################################################################                                                                                                                                              
  # Resource configuration                                                                                                                                                                                      
  ################################################################                                                                                                                                              
  [[resource]]                                                                                                                                                                                                  
    name = "test"                                                                                                                                                                                               
    [[resource.template]]                                                                                                                                                                                       
      src         = "/home/rkaufmann/Downloads/test.tpl"                                                                                                                                                        
      dst         = "/home/rkaufmann/Downloads/test.tpl.out"                                                                                                                                                    
      mode        = "0644"                                                                                                                                                                                      
                                                                                                                                                                                                                
    #[resource.backend]                                                                                                                                                                                         
      #[resource.backend.file]                                                                                                                                                                                  
              #filepath = "/home/rkaufmann/Downloads/test.yml"                                                                                                                                                  
              #onetime    = true                                                                                                                                                                                
              #keys     = [""]      

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants