Open seanhinde opened 5 years ago
what is the gist of the diff between host1
and host2
? maybe you overlay variables instead of multiple configs
There are a bunch of variables in the template that are deployment host specific, and we include all the generated configurations for all hosts in our release RPM.
When the system is started on the target host the start script picks the right sys.config based on the local hostname. They are things like which mnesia node to pair with etc.
It allows us to have a single RPM across all environments.
I do want to use overlay variables at build release time, but it seems that there can only be one overlay vars file per release.
Adding this clause to rlx_prv_overlay:do_individual_overlay/4 does what I need:
do_individual_overlay(State, _Files, OverlayVars0, {template, From, To, OverlayFilename}) ->
OverlayVars = read_overlay_vars(State, OverlayVars0, [OverlayFilename]),
file_render_do(OverlayVars, From,
fun(FromFile) ->
file_render_do(OverlayVars, To,
fun(ToFile) ->
write_template(OverlayVars,
absolute_path_from(State, FromFile),
absolute_path_to(State, ToFile))
end)
end).
I do want to use overlay variables at build release time, but it seems that there can only be one overlay vars file per release.
you can use rebar3 profiles for this, for each of them you can specify a different overlay file
I was looking at profiles. How do I generate one release that uses multiple profiles at the same time?
rebar3 as profile1,profile2,profile3 <command>
Yep, that works. It's a bit messy when there are 20 profiles. It's no longer just rebar3 release
, it's rebar3 as prod,host1,host2,host3,.......hostN release
. The profile list can be retrieved by a script, but this all pushes us towards a Makefile.
I still like the option to have a per template vars file - the rebar.config is cleaner, and the build process is as simple as can be.
I will probably keep my small patch locally - it works well enough for my uses. There is some template releated code in tar creation I didn't investigate, but aside from that it's a small change and maybe you will consider the idea for future release.
Thanks for all the help. Happy to close.
@seanhinde you have a patch for this? Have you sent a PR? It might be worth including.
I'm back on the project that found this change very useful. PR here https://github.com/erlware/relx/pull/933
One thing in there I'm not sure about. Feedback welcome.
I need to generate multiple config files in a single release from a single template. Something like:
where host1/sys.config has configuration specific to host1 etc.
I can't see a way to achieve this today. Am I missing something or would this be a feature worth adding?
Maybe something along the lines of a specific overlay file per template instantiation like: