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

Datum variable Interpolation #21

Open
gaelcolas opened this issue Jan 17, 2018 · 4 comments
Open

Datum variable Interpolation #21

gaelcolas opened this issue Jan 17, 2018 · 4 comments

Comments

@gaelcolas
Copy link
Owner

Similar to Redirections, it would be useful to use variable interpolation in Datum similar to Hiera:

'#{user}@#{domain}'

That would do a lookup for User and a lookup for Domain, and then aggregates them.

@SylvainMartel
Copy link

SylvainMartel commented Dec 20, 2018

Would this mean that if we enter something like:
Domain: Cosonto
then in a further yml file we would be able to reference it directly, like:
SqlInstallCredential: #{Domain}\theusername
We were looking on how we could do exactly that. So I take it it's not possible right now but eventually coming?

@gaelcolas
Copy link
Owner Author

That's the principle, yes.
Not built-in yet.

But you could do something similar by creating a Datum handler as explained here: https://github.com/gaelcolas/Datum/blob/master/docs/Datum_Redirections.md

@SylvainMartel
Copy link

Yup, tried the handler, and it works great when there is only one variable to get, and the full path to get it is static, but I wasn't able to make it work when there are also a variable in the path to follow to get the variable. I think it's what you described as a nested lookup in your document.

I'll try to describe our setup to demonstrate the problem.

Our folder structure is like this

+--+AllNodes
|      +V4Unit
|      |  +SQLSERV01.yml
|      | 
|      +V5Unit 
|
+--+Paliers 
|    +V4Unit.yml
|    |
|    +V5Unit.yml
|
+--+Roles
|     +PortailSQL.yml

First, I create SQLSERVR01.yml which goes under Allnodes/V4Unit (pardon the french in the labels :) )

NodeName: SQLSERV01
Environnement: Unitaire
Volet:  V4
Palier: V4Unit
Role: PortailSQL
Description: SQL pour Portail

Then it's in in PortailSQL.yml that I encounter the problem of a nested lookup

Configurations:
  -BASE_INSTALL_SQL

BASE_INSTALL_SQL:
  - Name: 
    <bunch of other variables>
    SqlInstallCredential: '[VAR=Paliers\$Palier\Domaine]\SrvSqlInstall'  #should be in the $Domain\username format

So, here, I need to get the Domain value which can be found in the yml file under the folder Paliers and in the yml file corresponding to the $Palier variable defined in the SQLSERV01.yml file. But I can't find how I'm supposed to be able to get it's value. Hence my research through the issues here.
It looks like the feature described in this ticket would indeed solve that problem nicely.

@HansOMartinsen
Copy link

Anyone looked into this lately? I just started using datum, and found that I have a need to concatenate data from different layers into one final string.
Example:
Role mssql yaml contains the config parameter for a user to add to local admins. But I want to fetch the domain part of the name from the environment yaml file. Is there a way to do this?

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

No branches or pull requests

3 participants