asteris-llc / converge

A powerful and easy-to-use configuration management system.
Apache License 2.0
250 stars 31 forks source link

Add support for global variables #631

Open dmlemos opened 7 years ago

dmlemos commented 7 years ago

Motivation

I tend to use a main.hcl file and from there call all the necessary modules.

Given

main.hcl

param "cred_user" {}
param "cred_password" {}

module "<src>" "setup_x" {
  params = {
    cred_user          = "{{param `cred_user`}}"
    cred_password = "{{param `cred_password`}}"
  }
}

module "<src>" "setup_y" {
    cred_user          = "{{param `cred_user`}}"
    cred_password = "{{param `cred_password`}}"
}
...

In order for this to work as of 0.6.0 I need to pass all the parameters required by the modules every time. When there are quite a few modules it is cumbersome to keep specifying the same parameters.

Modest proposal

main.hcl

#Option 1
param "global" "cred_user" {}
param "global" "cred_password" {}
...

#Option 2
param "cred_user" {
  type = "global"
}
param "cred_password" {
  type = "global"
}
...

module "setup_x" {}
module "setup_y" {}
...