Re: [Puppet Users] Issue with lookup / hiera in yaml

2018-08-16 Thread Helmut Schneider
Henrik Lindberg wrote:

> You cannot give arguments to lookup as an interpolation function
> inside of data. Use the commented out variant. Then use
> lookup_options (in your data) to configure that lookup of 'variables'
> should always be a 'deep' merge.

Great, works now, thanks a lot!

-- 
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/xn0ldrz2d1pqa2f002%40news.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Issue with lookup / hiera in yaml

2018-08-16 Thread Henrik Lindberg

On 2018-08-16 15:51, Helmut Schneider wrote:

Henrik Lindberg wrote:


If your data looks like this:


variables:
baculaWorkingDirectory: '/var/lib/bacula'


Then you do not have a variables.debug key - you can lookup
variables, or variables.baculaWorkingDirectory


common.yaml:

---
netconfig:
variables:
   debug:   0
   baculaConfPath: '/etc/bacula'
   baculaClientService:'bacula-fd'
   baculaDirectorService:  'bacula-dir'
   baculaStorageService:   'bacula-sd'
   baculaClientPackage:'bacula-client'
   baculaServerPackage:'bacula-server'
   baculaWorkingDirectory: '/var/lib/bacula'
   baculaGID:  'bacula'
   baculaUID:  'bacula'
   apachePackage:   'httpd'
   apacheService:   'httpd'
   fail2banConfPath:'/etc/fail2ban'
   fail2banPackage: 'fail2ban'
   fail2banService: 'fail2ban'
   logrotatePackage:'logrotate'
   openvpnPackage:  'openvpn'
   openvpnService:  'openvpn'
   openvpnConfPath: '/etc/openvpn'
   perlDbiPackage:  'libdbi-perl'
   perlDbdMysqlPackage: 'libdbd-mysql-perl'
   puppetService:   'puppet'
   rootUID: 'root'
   rootGID: 'root'
   rsyslogPackage:  'rsyslog'
   rsyslogService:  'rsyslog'
   snmpdConfPath:   '/etc/snmp'
   snmpdService:'snmpd'
   spamassassinPackage: 'spamassassin'
   syslogUID:   'root'
   syslogGID:   'root'
   ufwConfPath: '/etc/ufw'
   ufwPackage:  'ufw'
   ufwService:  'ufw'

I meanwhile found out that

lookup('variables.baculaWorkingDirectory', String, 'deep')

works while

lookup('variables.baculaWorkingDirectory')

does not. The problem is that in apps/bacula.yaml

WorkingDirectory: "%{lookup('variables.baculaWorkingDirectory')}"

works (but gives an emtpy string as 'variables.baculaWorkingDirectory'
is not found) while

WorkingDirectory: "%{lookup('variables.baculaWorkingDirectory', String,
'deep')}"

does not:

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Evaluation Error: Error while evaluating a
Function Call, Lookup of key 'profiles' failed: Syntax error in string:
%{lookup('variables.baculaWorkingDirectory', String, 'deep')} at
/etc/puppetlabs/code/modules/config/manifests/init.pp:43:15 on node
h2786452

apps/bacula.yaml:

---
profiles:
   backup:
 bacula:
   defaults:
[...]
 Client:
   FileDaemon:
 "%{::fqdn}-fd":
   FDport:9102
   #WorkingDirectory:
"%{lookup('variables.baculaWorkingDirectory')}"
   WorkingDirectory:
"%{lookup('variables.baculaWorkingDirectory', String, 'deep')}"
[...]



You cannot give arguments to lookup as an interpolation function inside 
of data. Use the commented out variant. Then use lookup_options (in your 
data) to configure that lookup of 'variables' should always be a 'deep' 
merge.


- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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/pl40fc%241bb%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Issue with lookup / hiera in yaml

2018-08-16 Thread Helmut Schneider
Henrik Lindberg wrote:

> If your data looks like this:
> 
> >> variables:
> >>baculaWorkingDirectory: '/var/lib/bacula'
> 
> Then you do not have a variables.debug key - you can lookup
> variables, or variables.baculaWorkingDirectory

common.yaml:

---
netconfig:
variables:
  debug:   0
  baculaConfPath: '/etc/bacula'
  baculaClientService:'bacula-fd'
  baculaDirectorService:  'bacula-dir'
  baculaStorageService:   'bacula-sd'
  baculaClientPackage:'bacula-client'
  baculaServerPackage:'bacula-server'
  baculaWorkingDirectory: '/var/lib/bacula'
  baculaGID:  'bacula'
  baculaUID:  'bacula'
  apachePackage:   'httpd'
  apacheService:   'httpd'
  fail2banConfPath:'/etc/fail2ban'
  fail2banPackage: 'fail2ban'
  fail2banService: 'fail2ban'
  logrotatePackage:'logrotate'
  openvpnPackage:  'openvpn'
  openvpnService:  'openvpn'
  openvpnConfPath: '/etc/openvpn'
  perlDbiPackage:  'libdbi-perl'
  perlDbdMysqlPackage: 'libdbd-mysql-perl'
  puppetService:   'puppet'
  rootUID: 'root'
  rootGID: 'root'
  rsyslogPackage:  'rsyslog'
  rsyslogService:  'rsyslog'
  snmpdConfPath:   '/etc/snmp'
  snmpdService:'snmpd'
  spamassassinPackage: 'spamassassin'
  syslogUID:   'root'
  syslogGID:   'root'
  ufwConfPath: '/etc/ufw'
  ufwPackage:  'ufw'
  ufwService:  'ufw'

I meanwhile found out that

lookup('variables.baculaWorkingDirectory', String, 'deep')

works while

lookup('variables.baculaWorkingDirectory')

does not. The problem is that in apps/bacula.yaml

WorkingDirectory: "%{lookup('variables.baculaWorkingDirectory')}"

works (but gives an emtpy string as 'variables.baculaWorkingDirectory'
is not found) while

WorkingDirectory: "%{lookup('variables.baculaWorkingDirectory', String,
'deep')}"

does not:

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Evaluation Error: Error while evaluating a
Function Call, Lookup of key 'profiles' failed: Syntax error in string:
%{lookup('variables.baculaWorkingDirectory', String, 'deep')} at
/etc/puppetlabs/code/modules/config/manifests/init.pp:43:15 on node
h2786452

apps/bacula.yaml:

---
profiles:
  backup:
bacula:
  defaults:
[...]
Client:
  FileDaemon:
"%{::fqdn}-fd":
  FDport:9102
  #WorkingDirectory:
"%{lookup('variables.baculaWorkingDirectory')}"
  WorkingDirectory:
"%{lookup('variables.baculaWorkingDirectory', String, 'deep')}"
[...]

-- 
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/xn0ldrwks1mf082001%40news.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Issue with lookup / hiera in yaml

2018-08-16 Thread Henrik Lindberg

On 2018-08-16 14:47, Helmut Schneider wrote:

Helmut Schneider wrote:


common.yaml:
variable:
   baculaWorkingDirectory: '/var/lib/bacula'

variables:
   baculaWorkingDirectory: '/var/lib/bacula'

config.pp:
[...]
   $variables = lookup({
 "name" => "variables",
 "merge" => {
   "strategy" => "deep",
   "knockout_prefix" => "--",
#  "sort_merged_arrays" => true,
 },
 "default_value" => [],
   })
[...]

bacula.pp:
class bacula inherits config {
   $test1 = lookup('variable.baculaWorkingDirectory')
   #$test2 = lookup('variables.baculaWorkingDirectory')
   $baculaWorkingDirectory = $variables['baculaWorkingDirectory']
   notify {"Test": message => $test1}
   #notify {"Test": message => $test2}
   notify {"baculaWorkingDirectory": message =>
$baculaWorkingDirectory} }

Notice: /var/lib/bacula
Notice: /Stage[main]/Bacula/Notify[Test]/message: defined 'message' as
'/var/lib/bacula'
Debug: /Stage[main]/Bacula/Notify[Test]: The container Class[Bacula]
will propagate my refresh event
Notice: /var/db/bacula
Notice: /Stage[main]/Bacula/Notify[baculaWorkingDirectory]/message:
defined 'message' as '/var/db/bacula'

If I uncomment #test2:

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Function lookup() did not find a value for the
name 'variables.baculaWorkingDirectory' on node
bsdhelmut1164.charlieroot.de

What am I missing?


I don't get it:

$test3 = lookup('variables')
notify {"Test3": message => $test3}

Notice: /Stage[main]/Bacula/Notify[variables]/message: defined
'message' as '{"debug"=>0, "baculaConfPath"=>"/etc/bacula",
"baculaClientService"=>"bacula-fd",
"baculaDirectorService"=>"bacula-dir",
"baculaStorageService"=>"bacula-sd",
"baculaClientPackage"=>"bacula-client",
"baculaServerPackage"=>"bacula-server",
"baculaWorkingDirectory"=>"/var/lib/bacula", "baculaGID"=>"bacula",
"baculaUID"=>"bacula", "apachePackage"=>"apache2",
"apacheService"=>"apache2", "fail2banConfPath"=>"/etc/fail2ban",
"fail2banPackage"=>"fail2ban", "fail2banService"=>"fail2ban",
"logrotatePackage"=>"logrotate", "openvpnPackage"=>"openvpn",
"openvpnService"=>"openvpn", "openvpnConfPath"=>"/etc/openvpn",
"perlDbiPackage"=>"libdbi-perl",
"perlDbdMysqlPackage"=>"libdbd-mysql-perl", "puppetService"=>"puppet",
"rootUID"=>"root", "rootGID"=>"root", "rsyslogPackage"=>"rsyslog",
"rsyslogService"=>"rsyslog", "snmpdConfPath"=>"/etc/snmp",
"snmpdService"=>"snmpd", "spamassassinPackage"=>"spamassassin",
"syslogUID"=>"syslog", "syslogGID"=>"adm", "ufwConfPath"=>"/etc/ufw",
"ufwPackage"=>"ufw", "ufwService"=>"ufw", "postfixPackage"=>"postfix",
"postfixService"=>"postfix", "postfixConfPath"=>"/etc/postfix",
"amavisdPackage"=>"amavisd-new", "arjPackage"=>"arj",
"p7zipPackage"=>"p7zip-full", "amavisdConfPath"=>"/etc/amavis/conf.d",
"amavisdService"=>"amavis", "appEtcConfPath"=>"/etc",
"bindConfPath"=>"/etc/bind", "bindPackage"=>"bind9",
"bindService"=>"bind9", "clamavConfPath"=>"/etc/clamav",
"clamavPackage"=>"clamav-daemon",
"clamavService"=>"clamav-daemon-chroot",
"clamavServiceOrg"=>"clamav-daemon", "cronConfPath"=>"/etc/cron.d",
"defaultsEtcConfPath"=>"/etc/default",
"freshclamService"=>"clamav-freshclam-chroot",
"freshclamServiceOrg"=>"clamav-freshclam", "initPath"=>"/etc/init.d",
"logrotateConfPath"=>"/etc/logrotate.d",
"perlSitePath"=>"/usr/local/lib/site_perl",
"postfixLdapSearchPackages"=>["libconfig-inifiles-perl",
"libmime-lite-perl", "libnet-ldap-perl"],
"rsyslogConfPath"=>"/etc/rsyslog.d", "sasl2Service"=>"saslauthd",
"snmpdPackage"=>"snmpd",
"spamassassinConfPath"=>"/etc/mail/spamassassin",
"sudoersConfPath"=>"/etc/sudoers.d"}'

$test2 = lookup('variables.debug')
notify {"Test2": message => $test2}

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Function lookup() did not find a value for the
name 'variables.debug' on node h2786452



If your data looks like this:

>> variables:
>>baculaWorkingDirectory: '/var/lib/bacula'

Then you do not have a variables.debug key - you can lookup variables, 
or variables.baculaWorkingDirectory


Best,
- henrik
--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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/pl3t9l%2412i%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Issue with lookup / hiera in yaml

2018-08-16 Thread Helmut Schneider
Helmut Schneider wrote:

> common.yaml:
> variable:
>   baculaWorkingDirectory: '/var/lib/bacula'
> 
> variables:
>   baculaWorkingDirectory: '/var/lib/bacula'
> 
> config.pp:
> [...]
>   $variables = lookup({
> "name" => "variables",
> "merge" => {
>   "strategy" => "deep",
>   "knockout_prefix" => "--",
> #  "sort_merged_arrays" => true,
> },
> "default_value" => [],
>   })
> [...]
> 
> bacula.pp:
> class bacula inherits config {
>   $test1 = lookup('variable.baculaWorkingDirectory')
>   #$test2 = lookup('variables.baculaWorkingDirectory')
>   $baculaWorkingDirectory = $variables['baculaWorkingDirectory']
>   notify {"Test": message => $test1}
>   #notify {"Test": message => $test2}
>   notify {"baculaWorkingDirectory": message =>
> $baculaWorkingDirectory} }
> 
> Notice: /var/lib/bacula
> Notice: /Stage[main]/Bacula/Notify[Test]/message: defined 'message' as
> '/var/lib/bacula'
> Debug: /Stage[main]/Bacula/Notify[Test]: The container Class[Bacula]
> will propagate my refresh event
> Notice: /var/db/bacula
> Notice: /Stage[main]/Bacula/Notify[baculaWorkingDirectory]/message:
> defined 'message' as '/var/db/bacula'
> 
> If I uncomment #test2:
> 
> Error: Could not retrieve catalog from remote server: Error 500 on
> SERVER: Server Error: Function lookup() did not find a value for the
> name 'variables.baculaWorkingDirectory' on node
> bsdhelmut1164.charlieroot.de
> 
> What am I missing?

I don't get it:

$test3 = lookup('variables')
notify {"Test3": message => $test3}

Notice: /Stage[main]/Bacula/Notify[variables]/message: defined
'message' as '{"debug"=>0, "baculaConfPath"=>"/etc/bacula",
"baculaClientService"=>"bacula-fd",
"baculaDirectorService"=>"bacula-dir",
"baculaStorageService"=>"bacula-sd",
"baculaClientPackage"=>"bacula-client",
"baculaServerPackage"=>"bacula-server",
"baculaWorkingDirectory"=>"/var/lib/bacula", "baculaGID"=>"bacula",
"baculaUID"=>"bacula", "apachePackage"=>"apache2",
"apacheService"=>"apache2", "fail2banConfPath"=>"/etc/fail2ban",
"fail2banPackage"=>"fail2ban", "fail2banService"=>"fail2ban",
"logrotatePackage"=>"logrotate", "openvpnPackage"=>"openvpn",
"openvpnService"=>"openvpn", "openvpnConfPath"=>"/etc/openvpn",
"perlDbiPackage"=>"libdbi-perl",
"perlDbdMysqlPackage"=>"libdbd-mysql-perl", "puppetService"=>"puppet",
"rootUID"=>"root", "rootGID"=>"root", "rsyslogPackage"=>"rsyslog",
"rsyslogService"=>"rsyslog", "snmpdConfPath"=>"/etc/snmp",
"snmpdService"=>"snmpd", "spamassassinPackage"=>"spamassassin",
"syslogUID"=>"syslog", "syslogGID"=>"adm", "ufwConfPath"=>"/etc/ufw",
"ufwPackage"=>"ufw", "ufwService"=>"ufw", "postfixPackage"=>"postfix",
"postfixService"=>"postfix", "postfixConfPath"=>"/etc/postfix",
"amavisdPackage"=>"amavisd-new", "arjPackage"=>"arj",
"p7zipPackage"=>"p7zip-full", "amavisdConfPath"=>"/etc/amavis/conf.d",
"amavisdService"=>"amavis", "appEtcConfPath"=>"/etc",
"bindConfPath"=>"/etc/bind", "bindPackage"=>"bind9",
"bindService"=>"bind9", "clamavConfPath"=>"/etc/clamav",
"clamavPackage"=>"clamav-daemon",
"clamavService"=>"clamav-daemon-chroot",
"clamavServiceOrg"=>"clamav-daemon", "cronConfPath"=>"/etc/cron.d",
"defaultsEtcConfPath"=>"/etc/default",
"freshclamService"=>"clamav-freshclam-chroot",
"freshclamServiceOrg"=>"clamav-freshclam", "initPath"=>"/etc/init.d",
"logrotateConfPath"=>"/etc/logrotate.d",
"perlSitePath"=>"/usr/local/lib/site_perl",
"postfixLdapSearchPackages"=>["libconfig-inifiles-perl",
"libmime-lite-perl", "libnet-ldap-perl"],
"rsyslogConfPath"=>"/etc/rsyslog.d", "sasl2Service"=>"saslauthd",
"snmpdPackage"=>"snmpd",
"spamassassinConfPath"=>"/etc/mail/spamassassin",
"sudoersConfPath"=>"/etc/sudoers.d"}'

$test2 = lookup('variables.debug')
notify {"Test2": message => $test2}

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Function lookup() did not find a value for the
name 'variables.debug' on node h2786452

-- 
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/xn0ldruw91k4ksb000%40news.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Issue with lookup / hiera in yaml

2018-08-15 Thread Helmut Schneider
Hi,

common.yaml:
variable:
  baculaWorkingDirectory: '/var/lib/bacula'

variables:
  baculaWorkingDirectory: '/var/lib/bacula'

config.pp:
[...]
  $variables = lookup({
"name" => "variables",
"merge" => {
  "strategy" => "deep",
  "knockout_prefix" => "--",
#  "sort_merged_arrays" => true,
},
"default_value" => [],
  })
[...]

bacula.pp:
class bacula inherits config {
  $test1 = lookup('variable.baculaWorkingDirectory')
  #$test2 = lookup('variables.baculaWorkingDirectory')
  $baculaWorkingDirectory = $variables['baculaWorkingDirectory']
  notify {"Test": message => $test1}
  #notify {"Test": message => $test2}
  notify {"baculaWorkingDirectory": message => $baculaWorkingDirectory}
}

Notice: /var/lib/bacula
Notice: /Stage[main]/Bacula/Notify[Test]/message: defined 'message' as
'/var/lib/bacula'
Debug: /Stage[main]/Bacula/Notify[Test]: The container Class[Bacula]
will propagate my refresh event
Notice: /var/db/bacula
Notice: /Stage[main]/Bacula/Notify[baculaWorkingDirectory]/message:
defined 'message' as '/var/db/bacula'

If I uncomment #test2:

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Function lookup() did not find a value for the
name 'variables.baculaWorkingDirectory' on node
bsdhelmut1164.charlieroot.de

What am I missing?

Thank you.

-- 
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/xn0ldqjfd8vw7x000%40news.gmane.org.
For more options, visit https://groups.google.com/d/optout.