Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all 257 articles
Browse latest View live

Facts not found from world.json

$
0
0
Hi Guys, see files etc below, but basically it can't seem to see ANY vars in world.json... ?
(File shown is subset of the full thing)
Why?

Chris
puppet.conf [master] vardir = /opt/puppetlabs/server/data/puppetserver logdir = /var/log/puppetlabs/puppetserver rundir = /var/run/puppetlabs/puppetserver pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid codedir = /etc/puppetlabs/code ca = false dns_alt_names = pm101.qa.x.x.x reports = store, foreman reportdir = $vardir/reports [main] server = pm101.qa.x.x.x ca_server = pmca.ops.x.x.x environment = qa2 hiera.yaml --- :backends: - json :hierarchy: - "%{hostname}.%{nt_environment}.%{nt_location}" - "%{nt_type}.%{nt_environment}.%{nt_location}" - "%{nt_type}.%{nt_environment}" - "%{nt_environment}.%{nt_location}" - "%{nt_environment}" - "%{nt_location}" - world - default :logger: console # debug :json: :datadir: '/etc/puppetlabs/code/environments/%{::environment}/hieradata' # this is the default anyway
/etc/puppetlabs/code/environments/qa2/hieradata
-rw-rw-r-- 1 jenkins jenkins 2398 Jan 14 00:38 world.json "env" : { "puppetusers" : [ "jjenkins", "rob", "phil", "mark", "snowpaws", "djenkins", "ikrayn", "chris", "tay", "dave", "cpl" ], }

Info: Using configured environment 'qa2' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template common/etc/profile.d/tmx_profile.sh.erb: Filepath: /etc/puppetlabs/code/environments/qa2/modules/common/templates/etc/profile.d/tmx_profile.sh.erb Line: 25 Detail: undefined method `[]' for nil:NilClass at /etc/puppetlabs/code/environments/qa2/manifests/modules/common/manifests/classes/configuration.pp:19:14 on node pm101.qa.sac.int.threatmetrix.com


Hiera Lookup Options

$
0
0
My Hiera Data is as follows: --- lookup_options: site::purge::rules: merge: strategy: hash merge_hash_arrays: true I want to be able to merge any arrays for the given hiera value site::purge::rules but if there is a conflict I want the higher tier to take priority. For example: If my Hiera router looks like this: --- :backends: - yaml :hierarchy: - "clientcert/%{::clientcert}" - "global" :yaml: :datadir: "/home/user/puppet/hieradata" Then the "Global" values should take priority over clientcert data if they conflict. if I have data like in **GLOBAL.yaml** --- site::purge::rules: - 'tmp.conf': directory: '/tmp' daystokeep: '365' wildcardExp: '{*,.*}' options: 'R' Then in a **CLIENTCERT.yaml** I have: anfsite::purge::rules: - 'tmp.conf': directory: '/tmp' daystokeep: '150' wildcardExp: '{*,.*}' options: 'R' - 'var-log.conf': directory: '/var/log' daystokeep: '365' wildcardExp: '*.log' options: '' the resulted array should be: --- site::purge::rules: - 'tmp.conf': directory: '/tmp' daystokeep: '365' wildcardExp: '{*,.*}' options: 'R' - 'var-log.conf': directory: '/var/log' daystokeep: '365' wildcardExp: '*.log' options: '' Note the daystokeep is 365 from the higher priority global.yaml yet the var-log was still included. What lookup options do I need to make this work? thanks,

Processing over hash with array - puppet 3.8

$
0
0
We're using puppet 3.8 (unfortunately can't move to puppet 4 yet) I've got a hash in hiera that looks something like this: hash_data: item1: field1: 'some data' array_data: - data1 - data2 item2: field1: 'other data' array_data: - data3 - data4 I've put together a module with code something like: class processor { $data = hiera_hash('hash_data', {}) create_resources(processor::hash_entry, $data) } define processor::hash_entry ($field1, $array_data) { # .. do_something .. # process array items processor::process_array { ${array_data} : datavar = 'somevalue' } } define processor::process_array($element, $datavar) { # do something } this works fine as long at the array_data fields in the hash all contain unique fields. However, if I need to put non-unique data something like: hash_data: item1: field1: 'some data' array_data: - data1 - data2 item2: field1: 'other data' array_data: - data3 - data2 ( **non-unique value **) then we hit a duplicate resource. Can anyone suggest how I could process that hash if I wanted to be able to handle the items in array_data as unique items? Thanks

hiera.yaml and connection refused strange error

$
0
0
I am setting up a new master in RHEL 7. I am facing a strange error, wherein, the sudo puppet agent -t in the puppet server (it runs puppet agent as production environment) returns the following error when i execute it with a valid /etc/puppetlabs/code/hiera.yaml file. If i remove that file and restart puppet server and try sudo puppet agent -t the run works without any issues. Any idea why having the /etc/puppetlabs/code/hiera.yaml file causes issues? Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Internal Server Error: org.jruby.exceptions.RaiseException: (Exception) Connection refused - Connection refused My /etc/puppetlabs/code/hiera.yaml looks like this: I use puppet/hiera to manage it. # managed by puppet --- :backends: - eyaml - consul - yaml :logger: console :hierarchy: - secure - common :eyaml: :datadir: "/etc/puppetlabs/code/hieradata" :pkcs7_private_key: "/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem" :pkcs7_public_key: "/etc/puppetlabs/puppet/keys/public_key.pkcs7.pem" :consul: :host: 127.0.0.1 :port: '8500' :paths: - "/v1/catalog/service" - "/v1/catalog/node" - "/v1/kv/application/%{deploy_path}" :yaml: :datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata"

what is hiera backend 'facter'?

$
0
0
I know hiera can be extended to other than yaml and json. But in one of the puppet setup I can see 'facter' as hiera backend. What does this mean? Is there any doc available for this? !ruby/sym backends: - facter

Hiera lookup truncates value

$
0
0
Hello, I have defined a value in my hierarchy that contains the version number for a GPU driver. In this particular case, the driver number ends in a 0 (375.20). When I lookup the hiera value, hiera is truncating the value (reports 375.2). Here is the entry in my yaml hierarchy: gpu_driver: 375.20 And here it the output from hiera: # hiera gpu_driver 375.2 Is there anyway to force hiera to not truncate the number? Other prior driver numbers never showed any truncation issue. I don't believe this is a locale display issue either as my puppet code that uses this value (using a hiera() lookup in the code) is also receiving the truncated value. Thank you -Mike

Arrays and hiera data

$
0
0
Hi, I am trying to reorganize a large monolithic hiera data file. What I have been doing is this: controller_node_ips: &CONTROLLER_NODE_IPS - 10.29.103.28 - 10.29.103.29 - 10.29.103.30 . . . galera::bind_address: "%{::ipaddress}" galera::status_password: 'status_password' galera::galera_servers: *CONTROLLER_NODE_IPS galera::configure_repo: false galera::galera_master: "%{hiera('galera_master')}" galera::root_password: 'XXXX123' galera::vendor_type: 'IT' galera::override_options: mysqld: 'max_connections': 9000 galera::validate::host: 'localhost' I tried to move the galera parameters to their own file, galera.yaml, so I couldn't use the reference `*CONTROLLER_NODE_IPS`. My galera.yaml looks like this: --- galera::bind_address: "%{::ipaddress}" galera::status_password: 'status_password' galera::galera_servers: "%{hiera('controller_node_ips')}" galera::configure_repo: false galera::galera_master: "%{hiera('galera_master')}" galera::root_password: 'XXXX123' galera::vendor_type: 'IT' galera::override_options: mysqld: 'max_connections': 9000 galera::validate::host: 'localhost' I can run this on the puppet master. # hiera galera::galera_servers "::prefix=svl-ost-kilo" ["10.29.103.28", "10.29.103.29", "10.29.103.30"] but on my puppet agent node I get this error: Error while evaluating a Function Call, join(): Requires array to work with at /etc/puppetlabs/code/environments/production/modules/galera/manifests/params.pp:6:17 on node

Hiera lookup : wrong behavior

$
0
0
Hello dear puppeteers ! ( running puppet 4.8.1 here ) Let's say I have two YAML files build as per the following specs **file1.yaml** entry: version: "%{hiera('package-version')}" **file2.yaml** package-version: "1.2.1" Nothing fancy here, but when puppet tries to build the catalog, the following message pops-up : [...] Could not find data item 1.2.1 in any Hiera data file and no default supplied at [...] So, apparently hiera retrieves the value but then tries to lookup it up elsewhere using it as key ... what am doing wrong here ? Thanks beforehand for any answer

puppet apply -e ' notify { "test": } " ' --environment production

$
0
0
how can i pass value for the environment from puppet apply so that it can be used in hiera lookup (hiera config file)? currently its not working and hiera throwing error saying, it couldn't find any key. command i tried, puppet apply -e ' notify { "test": } " ' --environment production

::fqdn no longer valid for vhost name in hiera file for puppetlabs-apache module?

$
0
0
Until today, the hiera .yaml file for our CentOS 7.3-based apache server hosts were able to use "%{::fqdn}: to name a vhost (see below). However, after upgrading from puppet-agent-1.8.2-1.el7.x86_64 to puppet-agent-1.9.0-1.el7.x86_64 I found I had to hard-code the vhost name. All other uses of variables like ::fqdn and ::hostname continue to work. (I note that puppetserver has been 2.7.2 since 22 DEC, 2016.) After the error started I updated the puppetlabs-apache module from 1.8.1 to 1.11.0 just in case that was the problem. It did not resolve the error. (All references to 'redacted' below equate to the fully qualified hostname of the host in question.) Runs with the vhost defined with the variable result in: > Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Invalid tag '25-%{__fqdn}.conf' at /etc/puppetlabs/code/environments/development/modules/concat/manifests/init.pp:123 at /etc/puppetlabs/code/environments/development/modules/apache/manifests/vhost.pp:623 on node redacted The difference between the old and new .yaml file: diff -c redacted.yaml redacted.yaml.old *** redacted.yaml 2017-02-10 09:36:22.540150497 -0800 --- redacted.yaml.old 2017-02-10 09:55:48.127742173 -0800 *************** *** 12,24 **** # ## configure apache for vhost apache::vhosts: ! "redacted": docroot: "/var/www/%{::hostname}" port: "80" redirect_dest: https://%{::fqdn} redirect_status: 'permanent' vhost_name: "%{::fqdn}" ! "redacted": docroot: "/var/www/%{::hostname}" port: "443" vhost_name: "%{::fqdn}" --- 12,24 ---- # ## configure apache for vhost apache::vhosts: ! "%{::fqdn}": docroot: "/var/www/%{::hostname}" port: "80" redirect_dest: https://%{::fqdn} redirect_status: 'permanent' vhost_name: "%{::fqdn}" ! "%{::fqdn}_ssl": docroot: "/var/www/%{::hostname}" port: "443" vhost_name: "%{::fqdn}" Any hints on how I can once-again make these files generic enough that I don't have to edit the vhost stanzas for new hosts that are created? Edit: I just obtained and installed puppet-agent-1.9.1-1.el7.x86_64 on a test host. This problem is still present. ; rpm -qa puppet-agent puppet-agent-1.9.1-1.el7.x86_64 ; bin/run_puppet Info: Using configured environment 'development' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Invalid tag '25-%{__fqdn}.conf' at /etc/puppetlabs/code/environments/development/modules/concat/manifests/init.pp:123 at /etc/puppetlabs/code/environments/development/modules/apache/manifests/vhost.pp:623 on node redacted Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

Hiera parameter value is not received by Puppet

$
0
0
I'm trying to configure kerberos (using pfmooney/mit_krb5 module) and set some parameters from Hiera. The parameter is declared in Hiera as follows: mit_krb5: 'default_realm': 'DOMAIN.COM' I ran the debug against the node and the correct value is return puppet lookup --debug mit_krb5 --node server.domain.com default_realm: DOMAIN.COM The puppet agent fails with this error > Error: Could not retrieve catalog from> remote server: Error 400 on SERVER:> Evaluation Error: Error while> evaluating a Function Call,> default_realm must be set manually or> via Hiera at> /etc/puppetlabs/code/environments/production/modules/mit_krb5/manifests/init.pp:264:5> on node server.domain.com This is the code from init.pp if $default_realm == '' { fail('default_realm must be set manually or via Hiera') } # END Parameter validation } Would you please let me know why the return value for default_realm is null but when I run the debug comes back with the correct value? Thank you

hiera automatic parameter lookup does not appear to work

$
0
0
I'm trying to convert my manifests to use automatic lookups instead of hiera-function lookups and it does not appear to be working. Here are my hiera yaml and profile manifests: my.yaml: profile::gogs::port: 8081 gogs.pp: class profile::gogs { $myport = hiera('profile::gogs::port') $myport2 = $profile::gogs::port $myport3 = $port notify {"myport: $myport, myport2: $myport2, myport3: $myport3":} I then run my puppet agent and get the following notify output: $ sudo -i puppet agent -vt --environment gitserver . . Notice: /Stage[main]/Profile::Gogs/Notify[myport: 8081, myport2: , myport3: ]/message: defined 'message' as 'myport: 8081, myport2: , myport3: ' So hiera can obviously see the value just fine, but the syntax I tried for the automatic parameter lookup (myport2 & myport3) seem to both fail. Perhaps I'm doing something wrong? NOTE: I'm using Puppet 4.3.2 with the standard roles/profiles patterns and r10k.

Puppet 4 not using custom facts

$
0
0
We are currently running a Puppet 3 system and looking to build out a new system with puppet 4. Currently it is not using our hiera because it is not reading the custom facts that we created. Our hiera.yaml:
---
:backends:
    - yaml
 :yaml:
    :datadir: "/etc/puppet/hiera/%{::zone}"
:hierarchy:
    - "%{::subdom4}"
    - "%{::subdom3}"
    - "%{::subdom2}"
    - "%{::subdom1}"
    - "%{::subdom0}"
    - common
If we run `/opt/puppetlabs/bin/facter` you will not see the "zone" or "subdom" facts. if we run `/opt/puppetlabs/bin/facter -p` they will show up. But running `/opt/puppetlabs/bin/hiera -d messages`, we get this:
DEBUG: 2017-03-09 16:12:26 -0500: Hiera YAML backend starting
DEBUG: 2017-03-09 16:12:26 -0500: Looking up messages in YAML backend
DEBUG: 2017-03-09 16:12:26 -0500: Ignoring bad definition in :hierarchy: ''
DEBUG: 2017-03-09 16:12:26 -0500: Ignoring bad definition in :hierarchy: ''
DEBUG: 2017-03-09 16:12:26 -0500: Ignoring bad definition in :hierarchy: ''
DEBUG: 2017-03-09 16:12:26 -0500: Ignoring bad definition in :hierarchy: ''
DEBUG: 2017-03-09 16:12:26 -0500: Ignoring bad definition in :hierarchy: ''
DEBUG: 2017-03-09 16:12:26 -0500: Ignoring bad definition in :hierarchy: ''
DEBUG: 2017-03-09 16:12:26 -0500: Looking for data source common
DEBUG: 2017-03-09 16:12:26 -0500: Cannot find datafile /etc/puppet/hiera/common.yaml, skipping
nil
We can also see the facts in `puppet facts --debug` This is on a CentOS 7 setup with PuppetDB using postgresql 9.6 Any ideas what else to try or look into?

update hash in puppet manifest

$
0
0
Hello, I am using a puppet agent 3.7.1 as part of our deployment process. We also use hiera to store our configuration data. Somewhere in one of my manifest I call hiera_hash to merge my configuration dictionary. My problem is that I need to "enrich" the returned hash and add some data to it. I understand that variables are immutable in puppet, so I can't just go my_hash[new_key] = new_value What options do I have if I want to update my hash ?(stdlib is not an option for me...the redtape in the place I work makes it very hard to install anything that does not come out of the box) Thanks,

hiera.yaml doubts about config files

$
0
0
My /etc/puppetlabs/puppet/hiera.yaml on master host looks like: --- :backends: - yaml :hierarchy: - "fussion/common" - "nodes/%{::trusted.certname}" - common :yaml: # datadir is empty here, so hiera uses its defaults: # - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix # - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows # When specifying a datadir, make sure the directory exists. :datadir: The master runs on vm-lab-linux-1 host and the agent on puppet-pil00 The file /etc/puppetlabs/code/environments/production/hieradata/fussion/common.yaml on master host looks like: --- mdw_os_user: &mdw_os_user bea mdw_os_group: &mdw_os_group bea mdw_os_uid: &mdw_os_uid 1001 mdw_os_gid: &mdw_os_gid 1001 software_vol_name: app/software software_vol_quota: 10G software_vol_mountpoint: /software software_vol_mountpoint_owner: root software_vol_mountpoint_group: root software_vol_mountpoint_mode: '0555' domains_vol_name: app/domains domains_vol_quota: 10G domains_vol_mountpoint: /domains domains_vol_mountpoint_owner: *mdw_os_user domains_vol_mountpoint_group: *mdw_os_group domains_vol_mountpoint_mode: '0755' domain_os_user: *mdw_os_user domain_os_group: *mdw_os_group mdw_vol_name: app/middleware mdw_vol_quota: 10G mdw_vol_mountpoint: /middleware mdw_vol_mountpoint_owner: &mdw_os_user mdw_vol_mountpoint_group: &mdw_os_group mdw_vol_mountpoint_mode: '0755' When I do a lookup from the master host I can find the key mdw_os_group: [root@vm-lab-linux-1 puppetlabs]# hiera -d mdw_os_group environment=production DEBUG: 2017-03-17 11:17:12 +0100: Hiera YAML backend starting DEBUG: 2017-03-17 11:17:12 +0100: Looking up mdw_os_group in YAML backend DEBUG: 2017-03-17 11:17:12 +0100: Looking for data source fussion/common DEBUG: 2017-03-17 11:17:12 +0100: Found mdw_os_group in fussion/common bea However, the agent can't find the key properly: root@puppet-pil00:/usr/jdk# /opt/puppetlabs/bin/puppet agent -t Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Function lookup() did not find a value for the name 'mdw_os_group' on node puppet-pil00.msc.es Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run I'm new on puppet and I am not sure if I am configuring hiera properly. Why the agent can't find the mdw_os_group key?

calling_class_path and inheritance of classes

$
0
0
In an scenario with 2 classes: pk1::claseA and pk::1claseB with claseA like: pk1::claseA { $somevariable = hiera('myvariable') notify{$variable:} } and claseB like: pk1::claseB inherits pk1::claseA {} with the tree dir for the module pk1: pk1 pk1/manifests pk1/manifests/claseA.pp pk1/manifests/claseB.pp and a node like: node 'pilot' { include claseB } and a hiera.yaml like: :backends: - yaml :hierarchy: - "domains/%{calling_class_path}" - common :yaml: # datadir is empty here, so hiera uses its defaults: # - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix # - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows # When specifying a datadir, make sure the directory exists. :datadir: and a file /etc/puppetlabs/code/environments/production/hieradata/domains/pk1/claseA.yaml with the content: myvariable = 'A' and a file /etc/puppetlabs/code/environments/production/hieradata/domains/pk1/claseB.yaml with the content: myvariable = 'B' $somevariable should be resolved to 'A' or to 'B' ? In the tests I've ran the answer is A but I don't really know if I'm doing something wrong or it is the expected behaviour. Thanks in advance!

several hiera data files and resource type with many parameters

$
0
0
Lets say that I have a resource type with have many parameters (many could means hundred or even more). Having one resource_config.yaml file for all the resource instances of this resource type is not wished because the file would be huge and very diffcult to maintain. I'd like to have one yaml config file for each instance. However, I don't really know how to achieve this. I've thought of different strategies without success. Any help would be appreciated.

Handle Empty Arrays

$
0
0
I am completely stumped on this one.. I have a module like: class test ( $file, $list, ){ file { $file: ensure => 'file', content => epp('module/list.epp', {'list' => $list}), mode => '0644', owner => '0', group => '0', } } $list and $file are coming in from hiera. $file is a string that is set and $list is a deep merged array. Basically I want to handle the file's contents based on the list parameter. However not every server is going to get data. For those that do it works fine, for those that do not I am getting an error saying the parameter $list is expecting a value. Ok fine, How about... class test ( $file, $list = [''], ){ No dice, it won't take empty strings either... How can I do the following:
1. create the file on **every** server (even if blank)
2. have the file be empty for servers without data
3. get the data across for servers with data.

How to get hiera to output the literal string '%{::fqdn}'?

$
0
0
I would like to know what I would need to have in my yaml file to have hiera output the literal string `%{::fqdn}` instead of outputting the value of the puppet fact `fqdn`. Here is what I have tried. # grep foo::p4 /etc/puppetlabs/code/environments/production/hieradata/bar.yaml foo::p4: 'http://%{hiera(''p1'')}/%{::fqdn}' And this is the result: # hiera foo::p4 '::prefix_fact=bar' '::fqdn=thing.com' environment=production http://test/thing.com What I actually want the output to be is: http://%{hiera('p1')}/%{::fqdn} I guess I could do something goofy like this: p1: 'test' pa: '%{hiera' pb: '("p1")}' pc: '%{::fq' pd: 'dn}' foo::p4: "%{hiera('pa')}%{hiera('pb')}%{hiera('pc')}%{hiera('pd')}" Then the output is what I want: # hiera foo::p4 '::prefix=bar' '::fqdn=thing.com' environment=production %{hiera("p1")}%{::fqdn}

module data hiera: Function lookup() did not find a value for the name

$
0
0
Given a module like: mymodule/ |-- data | `-- data.yaml |-- hiera.yaml |-- manifests | `-- init.pp `-- metadata.json mymodule/hiera.yaml --- version: 4 datadir: data #data_hash: yaml_data hierarchy: - name: "data" backend: yaml path: "data/data.yaml" - name: "common" backend: yaml mymodule/manifests/init.pp class mymodule { $var = lookup('mymodule::var') notify {"var: ${var}":} } mymodule/data/data.yaml --- mymodule::var: 'var value from mymodule/data/data.yaml' mymodule/metadata.json { "name": "example-mymodule", "version": "0.0.1", "author": "Pat", "license": "Apache-2.0", "summary": "A module for a thing", "source": "https://github.com/examplecorp/examplecorp-mymodule", "project_page": "https://forge.puppetlabs.com/examplecorp/mymodule", "issues_url": "https://github.com/examplecorp/examplecorp-mymodule/issues", "tags": ["things", "stuff"], "operatingsystem_support": [ { "operatingsystem":"RedHat", "operatingsystemrelease":[ "5.0", "6.0" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "12.04", "10.04" ] } ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.0 < 5.0.0" } ], "data_provider": "hiera" } ---------- root@puppet-pil00:/etc/puppetlabs# /opt/puppetlabs/bin/puppet agent -t Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Function lookup() did not find a value for the name 'mymodule::var' on node puppet-pil00.msc.es Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run why lookup() can't find mymodule::var variable in data.yaml?
Viewing all 257 articles
Browse latest View live