dobi icon indicating copy to clipboard operation
dobi copied to clipboard

[IDEA] Use variables file

Open ruiztulio opened this issue 7 years ago • 1 comments

It would be nice to allow the use of variables files so the dobi.yml file can be reusable in other contexts (example the same application, but witn some personalizations)

As an analogy imagine an ansible playbook (have you used ansible?) I can have a certain playbook that does the same "recipe" but installs different package versions according to some variables, change the host name and so, install nginx an listen for a given domain (different for every deployec host).

Now my use case. We have a base application in python but every customer have a personalized set of modules, but the build, test and deploy steps are the same, the only thing that changes is the database name, the image, etc. I can put a dobi file in every repo, but imagine if I realize that there is a better way to do some steps (or you decide to change something in the file format) a change is needed in all the repos, but if we have a single file (or set of files) and a variables file in every repo it would be a lot better to handle and do something like:

$ dobi app -dobi-file=https://github.com/dnephin/dobi/blob/master/dobi.yaml -vars_file=this_repo_vars.yml

Or locally:

$ dobi app -dobi-file=/path/to/dobi.yaml -vars_file=this_repo_vars.yml

I can wrap it with a python script (sorry, I'm not a Go boy...yet), but I think this would be a nice feature to have. What do you think?

ruiztulio avatar Apr 05 '18 03:04 ruiztulio

I think it would be good to support something like this. --dobi-file already exists as -f (--filename).

Many fields already support variables and others can be added. The only thing that is missing is loading variables from another file.

One way to do that would be to include another dobi config (meta.include). Currently the file must exist, but there is a proposal in https://github.com/dnephin/dobi/issues/22#issuecomment-257202850 to add more fields to support optional configs.

In the included file you could have an environment resource that references a file:

env=settings:
  files: [this_repo_vars.yml]

Does that work for the use case?

Note that right now caching is not optimal when env resources are used (#74), which is a bug that needs to be fixed.

dnephin avatar Apr 09 '18 20:04 dnephin