[Puppet Users] Puppet with Hiera - Custom variables

2017-05-24 Thread Stephen
Hello,

At the moment I do not use Hiera to store any config at all, but I want to.

Currently, I can use the variable "$mysettings::config::envtype" in my 
classes, as long as I put 'require mysettings::config' at the head of those 
classes.

In my environment, I use this variable to hold "PROD", "DEV", "PERFTEST", 
"QA", etc (It derives this from IP subnet).


I have this in my hiera.yaml file, which successfully pulls the data from, 
for example, the *os/RedHat.yaml* file when needed.
  - name: "OS defaults"
path: "os/%{facts.os.family}.yaml"



How do I use my variable above in the same way? I've tried the below, and a 
number of other syntaxes, and can't get it working. ie. I want to retrieve 
config from the *envtype/DEV.yaml* file, but it's not returning anything.
  - name: "Envtype data"
path: "envtype/%{'mysettings::config::envtype'}.yaml"


Apologies if this is explained in documentation, I have gone over it and 
it's just not clicking for me. Should I be doing it this way, should I be 
using custom facts, should I be doing something else?

I'm on Puppet PE v2017.1.0.

Thanks for any help.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c569bc63-69b5-481c-8f38-7e3388ea49a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Puppet with Hiera - Custom variables

2017-05-24 Thread Arnau
Hi,

I don't know if there's another (or better) way, but I use a custom fact
for the *environment*. Then you can tell hiera to use this new fact in the
hierarchy tree:

As an example:
node:

/etc/facter/facts.d/local.yaml
---
env: "prod"

puppet server:
/etc/puppet/hiera.yaml

---
:backends:
  - yaml
  - eyaml
:hierarchy:
  - "%{environment}/hieradb/%{::env}/cert/%{::clientcert}"


*Notice that %{environment} refers to puppet environemnt
. (In my case those
are the git branches that I create).*


HTH,
Arnau


2017-05-24 16:17 GMT+02:00 Stephen :

> Hello,
>
> At the moment I do not use Hiera to store any config at all, but I want to.
>
> Currently, I can use the variable "$mysettings::config::envtype" in my
> classes, as long as I put 'require mysettings::config' at the head of those
> classes.
>
> In my environment, I use this variable to hold "PROD", "DEV", "PERFTEST",
> "QA", etc (It derives this from IP subnet).
>
>
> I have this in my hiera.yaml file, which successfully pulls the data from,
> for example, the *os/RedHat.yaml* file when needed.
>   - name: "OS defaults"
> path: "os/%{facts.os.family}.yaml"
>
>
>
> How do I use my variable above in the same way? I've tried the below, and
> a number of other syntaxes, and can't get it working. ie. I want to
> retrieve config from the *envtype/DEV.yaml* file, but it's not returning
> anything.
>   - name: "Envtype data"
> path: "envtype/%{'mysettings::config::envtype'}.yaml"
>
>
> Apologies if this is explained in documentation, I have gone over it and
> it's just not clicking for me. Should I be doing it this way, should I be
> using custom facts, should I be doing something else?
>
> I'm on Puppet PE v2017.1.0.
>
> Thanks for any help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-users/c569bc63-69b5-481c-8f38-7e3388ea49a3%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAM69jx-rY2ODWcJx0mesL0-GD6qO_bebrsx%2B%2BT4fDfxi0z8a1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Puppet with Hiera - Custom variables

2017-05-25 Thread Stephen

Thank you very much for this. I have successfully tested it!

I perfer the idea of Puppet 'knowing' which yaml file to use by way of a 
passed variable, rather than having to read from disk for it (and if there 
is a way to do this, I'd like to hear it).

But your solution works and it's not complicated, so thank you :)

Kind regards,
Stephen


On Wednesday, 24 May 2017 15:51:38 UTC+1, Arnau wrote:
>
> Hi,
>
> I don't know if there's another (or better) way, but I use a custom fact 
> for the *environment*. Then you can tell hiera to use this new fact in 
> the hierarchy tree:
>
> As an example:
> node:
>
> /etc/facter/facts.d/local.yaml
> ---
> env: "prod"
>
> puppet server:
> /etc/puppet/hiera.yaml
>
> ---
> :backends:
>   - yaml
>   - eyaml
> :hierarchy:
>   - "%{environment}/hieradb/%{::env}/cert/%{::clientcert}"
>
>
> *Notice that %{environment} refers to puppet environemnt 
> . (In my case those 
> are the git branches that I create).*
>
>
> HTH,
> Arnau
>
>
> 2017-05-24 16:17 GMT+02:00 Stephen >:
>
>> Hello,
>>
>> At the moment I do not use Hiera to store any config at all, but I want 
>> to.
>>
>> Currently, I can use the variable "$mysettings::config::envtype" in my 
>> classes, as long as I put 'require mysettings::config' at the head of those 
>> classes.
>>
>> In my environment, I use this variable to hold "PROD", "DEV", "PERFTEST", 
>> "QA", etc (It derives this from IP subnet).
>>
>>
>> I have this in my hiera.yaml file, which successfully pulls the data 
>> from, for example, the *os/RedHat.yaml* file when needed.
>>   - name: "OS defaults"
>> path: "os/%{facts.os.family}.yaml"
>> 
>>
>> 
>> How do I use my variable above in the same way? I've tried the below, and 
>> a number of other syntaxes, and can't get it working. ie. I want to 
>> retrieve config from the *envtype/DEV.yaml* file, but it's not returning 
>> anything.
>>   - name: "Envtype data"
>> path: "envtype/%{'mysettings::config::envtype'}.yaml"
>> 
>>
>> Apologies if this is explained in documentation, I have gone over it and 
>> it's just not clicking for me. Should I be doing it this way, should I be 
>> using custom facts, should I be doing something else?
>>
>> I'm on Puppet PE v2017.1.0.
>>
>> Thanks for any help.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to puppet-users...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/puppet-users/c569bc63-69b5-481c-8f38-7e3388ea49a3%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/48209bb7-1c96-4a51-abc1-7ca7ccc1bb95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Puppet with Hiera - Custom variables

2017-05-25 Thread Arnau
Hi,

the typical scenario for running nodes in differnet environments is to use
r10k.
https://docs.puppet.com/pe/latest/r10k_run.html

git + r10k . It's a well known combo that works perefctly.

Best,
Arnau


2017-05-25 12:15 GMT+02:00 Stephen :

>
> Thank you very much for this. I have successfully tested it!
>
> I perfer the idea of Puppet 'knowing' which yaml file to use by way of a
> passed variable, rather than having to read from disk for it (and if there
> is a way to do this, I'd like to hear it).
>
> But your solution works and it's not complicated, so thank you :)
>
> Kind regards,
> Stephen
>
>
> On Wednesday, 24 May 2017 15:51:38 UTC+1, Arnau wrote:
>>
>> Hi,
>>
>> I don't know if there's another (or better) way, but I use a custom fact
>> for the *environment*. Then you can tell hiera to use this new fact in
>> the hierarchy tree:
>>
>> As an example:
>> node:
>>
>> /etc/facter/facts.d/local.yaml
>> ---
>> env: "prod"
>>
>> puppet server:
>> /etc/puppet/hiera.yaml
>>
>> ---
>> :backends:
>>   - yaml
>>   - eyaml
>> :hierarchy:
>>   - "%{environment}/hieradb/%{::env}/cert/%{::clientcert}"
>>
>>
>> *Notice that %{environment} refers to puppet environemnt
>> . (In my case those
>> are the git branches that I create).*
>>
>>
>> HTH,
>> Arnau
>>
>>
>> 2017-05-24 16:17 GMT+02:00 Stephen :
>>
>>> Hello,
>>>
>>> At the moment I do not use Hiera to store any config at all, but I want
>>> to.
>>>
>>> Currently, I can use the variable "$mysettings::config::envtype" in my
>>> classes, as long as I put 'require mysettings::config' at the head of those
>>> classes.
>>>
>>> In my environment, I use this variable to hold "PROD", "DEV",
>>> "PERFTEST", "QA", etc (It derives this from IP subnet).
>>>
>>>
>>> I have this in my hiera.yaml file, which successfully pulls the data
>>> from, for example, the *os/RedHat.yaml* file when needed.
>>>   - name: "OS defaults"
>>> path: "os/%{facts.os.family}.yaml"
>>>
>>>
>>>
>>> How do I use my variable above in the same way? I've tried the below,
>>> and a number of other syntaxes, and can't get it working. ie. I want to
>>> retrieve config from the *envtype/DEV.yaml* file, but it's not
>>> returning anything.
>>>   - name: "Envtype data"
>>> path: "envtype/%{'mysettings::config::envtype'}.yaml"
>>>
>>>
>>> Apologies if this is explained in documentation, I have gone over it and
>>> it's just not clicking for me. Should I be doing it this way, should I be
>>> using custom facts, should I be doing something else?
>>>
>>> I'm on Puppet PE v2017.1.0.
>>>
>>> Thanks for any help.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Puppet Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to puppet-users...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/puppet-users/c569bc63-69b5-481c-8f38-7e3388ea49a3%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-users/48209bb7-1c96-4a51-abc1-7ca7ccc1bb95%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAM69jx_FvJSZuMM0xEFjh-uzD22hiV6vEeyoTHmuSVhXGf3QrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.