Hello,
How do you share common hiera values across multiple environments (e.g. staging, production, testing) using puppet with r10k?
And how do you deploy those defaults automatically?
I've got multiple projects defined in r10k, and each project have at least 3 environments - staging, production, testing. I would like to move common values (a lot of them) to separate file so I don't need to duplicate them.
At this moment I plan to create custom fact that returns same value for each environments, e.g. projname, add to **hiera.yaml**:
- "%{::environment}/hieradata/%{::fqdn}"
- "%{::environment}/hieradata/%{::hostname}"
- "%{::environment}/hieradata/role-%{::cluster_role}"
- "%{::environment}/hieradata/virtual-%{::is_virtual}"
- "%{::environment}/hieradata/common"
- "%{::projname}/hieradata/common"
And simply add projname as another branch in project git repository with hieradata.
**I'm not very satisfied with this solution, could you suggest anything better?**
Any help appreciated.
↧
Sharing hiera across multiple environments
↧
How to reuse varibale from hiera hash as another hiera variable?
Lets say I have
# hash
some_application::users:
some_user:
username: 'some_username'
password: 'some_password'
another_user:
username: 'another_username'
password: 'another_password'
And I want to reuse these variables in Hiera:
# hash
another_application::users:
some_user:
username: "%{hiera('some_application::users')['some_user']['username']}"
another_user:
username: "%{hiera('some_application::users')['another_user']['username']}"
This kind of definition work from console:
puppet apply -e "notice(hiera('some_application::users')['some_user']['username'])"
But not from Hiera. What is the correct syntax to reuse variable from Hiera hash?
↧
↧
Chocolatey/Nuget/Hiera
Hi,
We are planning on using ProGet, using different feeds containing certain packages for different departmental groups. We will be using Chocolatey with Puppet. We are using Hiera, so we will be setting the package url there.
We are trying to figure out the best way to configure Hiera to reflect multiple Chocolatey sources.
For example:
A Windows server needs to have all of the applications we have decided it should get as its base software.
All packages for the base software are under the feed http://servername:81/nuget/BASE' (app1, app2, app3). In this case, Hiera would reflect the http://servername:81/nuget/BASE as the Chocolatey package url source.
We then want to apply software from Puppet based upon the server's role (to simplify, I will say MSOffice)
All packages for the Office role are under the feed http://servername:81/nuget/MSOffice' (app1, app2, app3). Obviously this is a different source than the one above.
Hiera knows that packages can be found under feeds at this url: 'http://servername:81/nuget/' , but how would we use Hiera to have multiple sources for Chocolatey packages? Chocolatey does allow multiple sources for searching. For instance, here is an example from the Chocolatey documentation, where multiple sources can be utilized:
package { 'notepadplusplus':
ensure => '6.7.5',
provider => 'chocolatey',
source => 'C:\local\folder\packages;https://chocolatey.org/api/v2/',
}
Can someone show me ways to use Hiera to give Chocolatey multiple sources to find a package? I realize we can put everything under one feed, but that is not our preferred solution.
Thanks in advance for any assistance!
↧
how to run a puppet program on multiple servers..?
Hi Guys,
I am new to puppet.!
If i want to execute a specific puppet program (like say restart of some service) on 100 nodes. How can i do it with hiera..!? I mean, how can i put all my 100 server names in hiera and use the definition in manifest.
↧
Hiera data not being used by module
I've cloned a module to the forge and modified for our organization's use. I'm running into an issue now, though, where the hiera data I'm passing it is not being used by the module. I can pull the data in my manifests using hiera lookups, but for whatever reason, the module itself isn't pulling the data. I'm out of ideas and debug isn't helping any.
Any suggestions to try and track this down?
↧
↧
Hiera is not a class (TypeError)
I'm trying to setup Beaker acceptance tests in a Docker container. Regardless of distribution all tests end up with this error:
lib/hiera/scope.rb:1:in `': Hiera is not a class (TypeError)
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/puppet-4.7.0/lib/puppet/indirector/hiera.rb:2:in `require'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/puppet-4.7.0/lib/puppet/indirector/hiera.rb:2:in `'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/puppet-4.7.0/lib/puppet/indirector/data_binding/hiera.rb:1:in `require'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/puppet-4.7.0/lib/puppet/indirector/data_binding/hiera.rb:1:in `'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/puppet-4.7.0/lib/puppet/test/test_helper.rb:1:in `require'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/puppet-4.7.0/lib/puppet/test/test_helper.rb:1:in `'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/rspec-puppet-2.3.2/lib/rspec-puppet.rb:12:in `require'
from /home/travis/build/deric/puppet-accounts/vendor/bundle/ruby/2.3.0/gems/rspec-puppet-2.3.2/lib/rspec-puppet.rb:12:in `'
here's [full log](https://travis-ci.org/deric/puppet-accounts/jobs/170944580)
Any idea what that error means?
↧
no implicit conversion of Symbol into Integer : Issues with Hiera calls.
Seems im having issues with Hiera.. Every call to this function no mater what im trying to pull is giving me this syntax..
ive been pulling my hair out and im sure its simple.
File for hiera is common.yaml
ntpservers: server1Checking that hiera on the puppet master works.
[root@oc8086083754 manifests]# hiera ntpservers server1So i now try to make sure the simple script can pull the value
[root@oc8086083754 manifests]# puppet apply --debug -e '$somevar = hiera('ntpservers') notify { $somevar: }' Debug: hiera(): Hiera YAML backend starting Debug: hiera(): Looking up ntpservers in YAML backend Error: Evaluation Error: Error while evaluating a Function Call, no implicit conversion of Symbol into Integer at line 1:12 on node oc8086083754.ibm.com Error: Evaluation Error: Error while evaluating a Function Call, no implicit conversion of Symbol into Integer at line 1:12 on node oc8086083754.ibm.com
Getting this with any hiera('xxxxxx') on the normal .pp files also.
What is happening am i doing wrong :O(
Second Test... Seems i cant get any thing to work :O(
puppet-3.6.2-3.el7.noarch
hiera-1.3.4-5.el7.noarch
[root@oc8086083754 environments]# hiera test::protocol http:// [root@oc8086083754 environments]# hiera test::hostname domain.com [root@oc8086083754 environments]# hiera test::path /index.html
[root@oc8086083754 environments]# cat /tmp/test.pp class test ( $protocol, $hostname, $path, ) { notify { 'Print an URL': message => "${protocol}${hostname}${path}" } } class { 'test': }I run my test
[root@oc8086083754 environments]# puppet apply --debug /tmp/test.pp Debug: hiera(): Hiera YAML backend starting Debug: hiera(): Looking up test::protocol in YAML backend Error: Evaluation Error: Error while evaluating a Resource Statement, Error from DataBinding 'hiera' while looking up 'test::protocol': no implicit conversion of Symbol into Integer at /tmp/test.pp:11:1 on node oc8086083754.ibm.com Error: Evaluation Error: Error while evaluating a Resource Statement, Error from DataBinding 'hiera' while looking up 'test::protocol': no implicit conversion of Symbol into Integer at /tmp/test.pp:11:1 on node oc8086083754.ibm.com
↧
How to install apache on multiple servers (100 servers)?
Is there a way i can store all my servers names and that file will be used by puppet program to install apache on all the servers listed in the file.
↧
How to call hiera in a class definition?
I am facing an issue in calling a hiera key with in a class.. I am playing with hiera to learn how it works and so the idea is to create set of users and groups. My class looks like the following.
class musers
( $users = hiera("in_users", $groups = hiera("in_groups"))
{
create_resources(user, $users)
create_resources(group, $groups)
}
where in_users and in_groups are the key holding the value and my hiera data looks like the following.
---
in_users:
user1:
ensure: present
home: /home/in/user1
managehome: true
shell: /bin/bash
uid: 10001
gid: 10001
password: $1$bM0KFO/z$usCU/t3/NiaL2YBRkoSTM.
user2:
ensure: present
home: /home/in/user2
managehome: true
shell: /bin/bash
uid: 10002
gid: 10002
password: $1$bM0KFO/z$usCU/t3/NiaL2YBRkoSTM.
in_groups:
graphics:
ensure: present
gid: 601
hardwares:
ensure: present
gid: 602
coreadmin:
ensure: present
gid: 603
Issue:-
I have assigned the musers class to the agent via PE Console and did 'puppet agent --test' and it is giving out the following error.
[root@agent1 ~]# puppet agent --test
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '{' at /etc/puppetlabs/code/environments/production/modules/musers/manifests/init.pp:4:1 on node agent
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
↧
↧
Accessing Hiera variables
I have specific hiera data that I would like to reference in my modules. For example have a variable have a different value from production versus non-production.
How do I made a reference in my module to a specific value in hiera? For example if I have a value
root_pw = some_dev_pass
and
root_pw = some_prod_pass
If I need to reference this variable in my module how do I do this?
thanks,
↧
Automatic lookup for default values in module data doesn't work properly when used in sub-modules.
Hello!
I'm facing an issue with automatic lookup and module data. I've followed this [guide](https://docs.puppet.com/puppet/latest/lookup_quick_module.html) to set it up. My puppet server is running version `4.3.1`.
Let's assume I have the following hierarchy:
* Role `my_role` - simply includes `::module_a`
* Module `module_a` - parameterised module, with `"data_provider": "hiera"` line in its metadata.json. This module includes `::module_b`.
* Module `module_b` - parameterised module, with `"data_provider": "hiera"` line in its metadata.json. It expects to receive as argument `String $my_param` and has a corresponding value in `module_b::my_param` in local hiera store.
`module_a` behaves as expected and is able to load all default values that I've added to its local hiera store.
However, when I include `module_b` in `module_a`, and don't specify any parameters, I get the following error:
2016-12-11 09:18:53,682 ERROR [qtp422397815-20949] [puppet-server] Puppet Evaluation Error: Error while evaluating a Function Call, Class[Module_b]:
expects a value for parameter 'my_param'
If I move the `module_b::my_param` to `module_a` local hiera store Puppet looks it up just fine. Another workaround is to use a `function` data_provider in `module_b`.
Also, if I make the inheritance hierarchy flat, i.e. directly include both `::module_a` and `::module_b` in `my_role`, only the module that is evaluated first succeeds to load its defaults, while the other module fails with the same error. So it looks like that hiera configuration in one module is somehow overwritten by the configuration in another.
Any thoughts/suggestions/advices will be greatly appreciated.
Alex.
↧
How can I use a profile to include a class defined in hiera without getting dup class errors?
I want to use a profile to call a class that is already defined in a higher level in hiera and provide different data to that class. When I call the class in my profile puppet complains that the class is already defined. Is there anything I can do to avoid the dup definition? I want to leave the current implementation in place for other servers not included in this profile.
↧
Is it possible to use Hiera Knockout Rules for Hashes?
common.yaml:
lookup_options:
firewall::rules: { merge: {strategy: deep, merge_hash_arrays: true, knockout_prefix: "--", sort_merge_arrays: true}}
firewall::rules
http_allow: { action: 'ACCEPT', proto: 'tcp', source: 'net', dest: '$FW', port: '80', order: '50', comment: 'http access' }
ssh_all: { action: 'ACCEPT', proto: 'tcp', source: 'net', dest: '$FW', port: '22', sport: '-', original_dest: '-', order: '50', comment: 'all ssh access' }
example.com.yaml:
firewall::rules
--ssh_all:
ssh_admins: { action: 'ACCEPT', proto: 'tcp', source: 'net:123.456.768', dest: '$FW', port: '22', sport: '-', original_dest: '-', order: '50', comment: 'admin ssh access' }
should result in a merged yaml:
firewall::rules
http_allow: { action: 'ACCEPT', proto: 'tcp', source: 'net', dest: '$FW', port: '80', order: '50', comment: 'http access' }
ssh_admins: { action: 'ACCEPT', proto: 'tcp', source: 'net:123.456.768', dest: '$FW', port: '22', sport: '-', original_dest: '-', order: '50', comment: 'admin ssh access' }
↧
↧
Does Puppet provide a validation/syntax checker for Hiera?
The tool `puppet parser validate` will [check the syntax of my Puppet manifests](http://docs.puppetlabs.com/references/latest/man/parser.html#ACTIONS):
[root@puppet3 ~]# puppet parser validate /etc/puppet/manifests/site.pp
Warning: The use of 'import' is deprecated at /etc/puppet/manifests/site.pp:18. See http://links.puppetlabs.com/puppet-import-deprecation
(at grammar.ra:610:in `_reduce_190')
Error: Could not parse for environment production: No file(s) found for import of 'nodes/*.pp' at /etc/puppet/manifests/site.pp:18
[root@puppet3 ~]#
And I can check my manifests against the Puppet Style Guide using `puppet-lint`:
[root@puppet3 ~]# puppet-lint /etc/puppet/modules/hosts/manifests/init.pp
WARNING: class not documented on line 1
[root@puppet3 ~]#
Is there a Puppet validation tool for Hiera or for my YAML files?
↧
Hiera doesn't pick a key
Hi my dear puppeteers,
I am currently migrating code which used to work in a Puppet 3.8 / Hiera 1.3 setup.
After scratching my head a little regarding some Hiera lookup errors, I realized that those were due to some of the keys' names.
e.g :
Looking up for 'classes', defined like this ...
classes: ["::role::somerole"]
... is successfull
DEBUG: Found classes in common
["role::somerole"]
However, looking up for 'zbackbone-datamanager-svrtest.version' defined like this ...
zbackbone-datamanager-svrtest.version: "1.3.7"
... is NOT successfull
nil
Renaming the key to **zbackbone-datamanager-svrtestversion** ( witout the dot . ), makes hiera find the key :
DEBUG: Found zbackbone-datamanager-svrtestversion in common
1.3.7
I suppose this is a change from Hiera 1.3 to Hiera 3.2.
Is there a part of the Hiera documentation which specifies the key names limitations ?
Thanks beforehand
↧
hiera: Failed to parse inline template: no implicit conversion of String into Array
I'm trying to use hiera to customize data instead of putting everything in one manifest.
For attachmentgenie/timezone module I want to setup the time zone. Thus instead of setting the timezone in in site.pp like this:
-----------site.pp-----------
class { 'timezone': }
zone => "America/Montreal"
---------------*-----------------
I removed (zone => "America/Montreal") and created the yaml file:
-------global.yaml---------
timezone::zone:
-- ["America/Montreal"]
--------------*-----------------
But it gives me this error:
**DEBUG ssh: stderr: Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse inline template: no implicit conversion of String into Array at /tmp/vagrant-puppet/environments/production/modules/timezone/manifests/init.pp:9:16 on node server1.myworld.org**
The culprite line in the timezone's module's init.pp is : *file { '/etc/timezone': content => inline_template('<%= @zone + "\n" %>'), }*
String vs Array ... I'm not sure if I can set the type withing the yaml file?
Thank you.
↧
Hiera : correct lookup way
Hello all,
I am currently reviewing some Hiera configuration file(s) and came across some elements which I would need advices about.
Here's a Hiera configuration example :
vstest:
service_name: svc-id-tag
additional_properties:
c_url: "%{hiera('compliance_url')}"
both **svc-id-tag** and **compliance_url** are Hiera keys located in another YAML configuration file and both ways actually work to retrieve the value.
But what is the best ( recommended ) way to perform lookups ?
↧
↧
Merging Hiera files From mulitiple Environments
Hello,
I would like to merge a few puppet environments in to 2 : "production", "development".
The environments/ modules /sites aspects of this merge are fine, but i am having difficulty with the Hiera data.
We have hiera data that applies to an entire environment and i am looking for an alternate way of doing.
ex:
envs: test, preprod, prod
desired envs: prod, test
How does one merge the hiera data from preprod into the prod heira yaml file and still have it only apply to the pre prod servers?
↧
Hiera 4 and eyaml
Hi,
Is there any way to use eyaml with the new [environment-specific hiera 4 configuration](https://docs.puppet.com/puppet/latest/lookup_quick.html#hierayaml-version-4-in-a-nutshell)?
The docs say:
> Currently only yaml and json are> supported.
so I'm thinking probably not, but thought I'd check on here to see if anyone knew of a way to do it that wasn't documented?
Thanks!
↧
Puppet best practice. Class parameters vs. hiera_hash()
Hi,
I was wondering what is considered best practice when it comes to delivering hiera data to my puppet classes.
Example 1)
class os_accounts (
) {
create_resources('user', hiera_hash("os_accounts::user",{}))
create_resources('group', hiera_hash("os_accounts::group",{}))
}
Example 2)
class os_accounts (
$users,
$groups,
) {
create_resources('user', $users)
create_resources('group', $groups)
}
I tend to prefer Example 2 just because there is less code.
Thanks!
↧