Hi

Using a global ENC - this is allocating facts like location and envornment.

in my hiera I had

  # Envornment - YB
  - "ybenv/%{::ybenv}"

so I would have say 

prod.yaml

and

  # Location - YB
  - "yblocation/%{::yblocation}"

to id location or datacentre

I setting
yblocation: alc << not sure why I am setting this again as its set by the 
ENC
yblocation::ip: 33 << this is new not defined in the ENC

but I have a common.yaml that tries to use this value and the only way I 
get to view it is with a hiera lookup..
and its not working the best.

but https://docs.puppet.com/hiera/3.2/variables.html 
Passing Variables to Hiera seciton 


   - Avoid referencing user-set local variables from Hiera. Instead, use 
   facts, built-in variables, 
   
<https://docs.puppet.com/puppet/latest/reference/lang_facts_and_builtin_vars.html>top-scope
 
   variables, node-scope variables, or variables from an ENC whenever 
   possible.

does that mean i should do it all in my ENC ??


 hiera  -d   ybenv::file    ::osfamily=RedHat environment=production   
::trusted.certname=abc ::ybenv=alex  ::yblocation=ybo
DEBUG: 2016-07-08 09:58:10 +1000: Hiera YAML backend starting
DEBUG: 2016-07-08 09:58:10 +1000: Looking up ybenv::file in YAML backend
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source ybenv/alex
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source yblocation/ybo
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source os/RedHat
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source common
DEBUG: 2016-07-08 09:58:10 +1000: Found ybenv::file in common
DEBUG: 2016-07-08 09:58:10 +1000: Looking up ybvlan in YAML backend
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source ybenv/alex
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source yblocation/ybo
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source os/RedHat
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source common
DEBUG: 2016-07-08 09:58:10 +1000: Found ybvlan in common
DEBUG: 2016-07-08 09:58:10 +1000: Looking up yblocation::ip in YAML backend
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source ybenv/alex
DEBUG: 2016-07-08 09:58:10 +1000: Looking for data source yblocation/ybo
DEBUG: 2016-07-08 09:58:10 +1000: Found yblocation::ip in yblocation/ybo
{"ybenv_file1"=>
  {"path"=>"/etc/ybenv",
   "ensure"=>"present",
   "content"=>"ybenv: alex\nyblocation: ybo\n0\n172\n",
   "group"=>"root",
   "mode"=>"0444",
   "owner"=>"root"}}

when i run this on a node it doesn't get the 172 ?? 




Let me try and explain that again ...

this is what I get from my ENC
---
environment: production
parameters:
  ybenv: alex
  yblocation: ybo


my :hierarchy looks like

:hierarchy:

  # node specific
  - "nodes/%{::trusted.certname}"

  # Applicaiton - YB
  - "ybapplication/%{::ybapplication}"

  # Envornment - YB
  - "ybenv/%{::ybenv}"

  # Location - YB
  - "yblocation/%{::yblocation}"

  # OS specific
  - "os/%{::osfamily}"

  # common to all
  - common

in yblocation

cat hieradata/yblocation/ybo.yaml
---

##
yblocation: ybo
yblocation::ip: 172



and in cat hieradata/common.yaml

#
# Save it
ybenv::file:
  ybenv_file1:
    path: /etc/ybenv
    ensure: present
    content: "ybenv: %{::ybenv}\nyblocation: 
%{::yblocation}\n%{hiera('ybvlan')}\n%{hiera('yblocation::ip')}\n"
    group: root
    mode: '0444'
    owner: root



hiera  -d   ybenv::file    ::osfamily=RedHat environment=production   
::trusted.certname=abc ::ybenv=alex  ::yblocation=ybo

gives me 
"content"=>"ybenv: alex\nyblocation: ybo\n0\n172\n",

but on the node i get this

Notice: /Stage[main]/Main/Node[default]/File[ybenv_file1]/content:
--- /etc/ybenv  2016-07-08 10:01:55.121019861 +1000
+++ /tmp/puppet-file20160708-30039-sdgvj0       2016-07-08 
10:10:24.007280395 +1000
@@ -1,4 +1,4 @@
 ybenv: alex
 yblocation: ybo
 0
-
+0

looks like the hiera() is not working properly


Thanks
A



-- 
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/59db9f38-4efb-48dd-8952-1f149da97e81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to