Hi Peter,
It all depends wher you use variables.
In manifests, it is best practice to scope facts @ top scope (::), if
you really want to use the fact
you can do something like this :
ipaddress => 192.168.10.0 (the fact)
class { 'x':
$ipaddress = '10.0.0.0'
notify { "fact = ${::ipaddress}, local is ${ipaddress} }
}
If you always scope your facts, you are sure that you use the fact variable.
And it is true that you don't use the scoping in the hiera.yaml file for
facts. I didn't noticed it
Glad it works now.
On 01/10/2014 12:32 PM, Peter wrote:
Hi Johan,
Thanks for the suggestion, unfortunately it did not work.
It seems that using a scope file
(http://docs.puppetlabs.com/hiera/1/command_line.html#json-and-yaml-scopes)
doesn't load the facts into the global scope. Could this be a hiera
command line bug?
If I change the hiera.yaml hierarchy from "node/%{::fqdn}" to
"node/%{fqdn}" it works.
Reading http://docs.puppetlabs.com/learning/variables.html#aside-why-do-everyones-manifests-seem-to-use-ipaddress
seems to suggest that you don't need to use :: for facts.
Am I missing something?
Peter.
On Friday, 10 January 2014 03:19:23 UTC+11, Johan De Wit wrote:
Hi,
Could it be something stupid like
---
fqdn: puppet.koewacht.net <http://puppet.koewacht.net>
in your facts.yaml ?
I generated my facts.yaml from facter -y
Grts
Jo
On 01/09/2014 12:29 PM, Peter wrote:
Hi List,
I am experimenting with different hiera hierarchy's through the
hiera command line. I am passing in different facts to simulate
different nodes. In the beginning I would manually pass them in
as parameters on the command line after a while when I wanted to
pass in more and more facts I decided to use the YAML scope file
option.
This does not seem to work when I use the :: notation in the
hieral.yaml under the hierarchy. I have simplified my hierarchy
to demonstrate the issue. The relevant files look like:
**********************************************
$ ls -R
.:
facts.yaml hiera.yaml hieradata
./hieradata:
common.yaml node
./hieradata/node:
creator.mgnt.local.yaml
**********************************************
$ cat hiera.yaml
---
:backends:
- yaml
:yaml:
:datadir: ./hieradata
:hierarchy:
- "node/%{::fqdn}"
- common
**********************************************
$ cat hieradata/common.yaml
---
ip: '192.168.0.1'
**********************************************
$ cat hieradata/node/creator.mgnt.local.yaml
---
ip: '10.0.0.1'
**********************************************
$ cat facts.yaml
---
fqdn: "creator.mgnt.local"
If I manually pass the facts on the command line it works
$ hiera -c hiera.yaml ip ::fqdn=creator.mgnt.local -d
DEBUG: 2014-01-09 22:19:48 +1100: Hiera YAML backend starting
DEBUG: 2014-01-09 22:19:48 +1100: Looking up ip in YAML backend
DEBUG: 2014-01-09 22:19:48 +1100: Looking for data source
node/creator.mgnt.local
DEBUG: 2014-01-09 22:19:48 +1100: Found ip in node/creator.mgnt.local
10.0.0.1
However if I use a file which contains the facts it doesn't work
$ hiera -c hiera.yaml ip -y facts.yaml -d
DEBUG: 2014-01-09 22:26:31 +1100: Hiera YAML backend starting
DEBUG: 2014-01-09 22:26:31 +1100: Looking up ip in YAML backend
DEBUG: 2014-01-09 22:26:31 +1100: Looking for data source common
DEBUG: 2014-01-09 22:26:31 +1100: Found ip in common
192.168.0.1
In the facts file I have have tried it also declaring it like
"::fqdn" but that also does not work. Is there an option to
bring the factor variables into the global scope?
Thanks,
Peter
--
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 [email protected] <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/420abd32-c607-4374-ad34-64c999487ed7%40googlegroups.com
<https://groups.google.com/d/msgid/puppet-users/420abd32-c607-4374-ad34-64c999487ed7%40googlegroups.com>.
For more options, visit https://groups.google.com/groups/opt_out
<https://groups.google.com/groups/opt_out>.
--
Johan De Wit
Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________
Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUMhttp://www.open-future.be
_________________________________________________________
Upcoming Events:
Puppet Fundamentals Training |
http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february
<http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february>
Puppet Introduction Course |
http://www.open-future.be/puppet-introduction-course-7th-february
<http://www.open-future.be/puppet-introduction-course-7th-february>
Zabbix Certified Training |
http://www.open-future.be/zabbix-certified-training-10-till-12th-february
<http://www.open-future.be/zabbix-certified-training-10-till-12th-february>
Zabbix for Large Environments Training |
http://www.open-future.be/zabbix-large-environments-training-13-till-14th-february
<http://www.open-future.be/zabbix-large-environments-training-13-till-14th-february>
Subscribe to our newsletter: http://eepurl.com/BUG8H
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/c5380703-dab6-41c7-b6a7-40080b376f4e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Johan De Wit
Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________
Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________
Next Events:
Puppet Fundamentals Training |
http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february
Puppet Intruction Course |
http://www.open-future.be/puppet-introduction-course-7th-february
Zabbix Certified Training |
http://www.open-future.be/zabbix-certified-training-10-till-12th-february
Zabbix for Large Environments Training |
http://www.open-future.be/zabbix-large-environments-training-13-till-14th-february
Subscribe to our newsletter | http://eepurl.com/BUG8H
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/52D04000.4070905%40open-future.be.
For more options, visit https://groups.google.com/groups/opt_out.