Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Douglas Garstang
This in insanity.

Now I have:
$ec2_config = hiera('ec2_config')

if $::ec2_instance_id {
$pvdisks = $ec2_config['instance'][$::ec2_instance_type]['pvdisks']
$pvdisk_count = inline_template('<%= @pvdisks.length %>')
$swapvol_enabled =
$ec2_config['instance'][$::ec2_instance_type]['volumes']['swap']['enabled']
$logvol_enabled =
$ec2_config['instance'][$::ec2_instance_type]['volumes']['log']['enabled']
notice ("HERE0 ($swapvol_enabled) ($logvol_enabled)")
if ($swapvol_enabled == 'true') {
$swapvol_size =
$ec2_config['instance'][$::ec2_instance_type]['volumes']['swap']['size']
notice ("HERE1")
}
if ($logvol_enabled == 'true') {
$logvol_size =
$ec2_config['instance'][$::ec2_instance_type]['volumes']['log']['size']
notice("HERE2")
}
notice ("HERE3 $swapvol_size $swapvol_size")
}

The first HERE0 correctly displays '(true) (true)' in the logs.
However, on the very next line, where the condition is if
$swapvol_enabled == 'true',it returns false. WTF???

Doug

On Wed, Aug 22, 2012 at 1:56 PM, Wolf Noble  wrote:
> I accomplished something similar awhile back.
>
> While I've not spent much time looking at your particular problem, I think 
> this'll help point you in the direction of what you need…
>
>
>
> class mymodule::params{
> $collector= hiera('mymodule_collector','')
> }
>
> class mymodule::config{
>  $collector   = $mymodule::params::collector
>  $ipstring= inline_template("<% collector.each_pair do |key, hash| 
> %><%=hash['ip']%>,<%end%>")
>  $ips = split ($ipstring,',')
> }
>
> define mymodule::add_hosts_allow () {
>   exec { "hosts_allow_$title":
> command => "/bin/echo \"myservice : $title : ALLOW\" >>/etc/hosts.allow",
> unless  => "/bin/grep -c \"myservice : $title : ALLOW\" /etc/hosts.allow",
>   } #end exec
> }
>
>
> On Aug 21, 2012, at 11:00 PM, Douglas Garstang  
> wrote:
>
>> I know I did this once before but can't find docs on how to do it again.
>>
>> I have this in a yaml file:
>>
>> pvdisks:
>>ec2_pvdisks_m1.small:
>>disks: /dev/xvdb1
>>enabled: yes
>>
>> Loading it with hiera.
>>
>> Manifest has:
>>
>>$testkey = hiera('pvdisks')
>>notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>>
>> This is printing
>> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>>
>> which obviously is the data picked into a string.
>>
>> Doug.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Puppet Users" group.
>> To post to this group, send email to puppet-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> puppet-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/puppet-users?hl=en.
>>
>
>
> 
>
> This message may contain confidential or privileged information. If you are 
> not the intended recipient, please advise us immediately and delete this 
> message. See http://www.datapipe.com/legal/email_disclaimer/ for further 
> information on confidentiality and the risks of non-secure electronic 
> communication. If you cannot access these links, please notify us by reply 
> message and we will send the contents to you.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
>



-- 
Regards,

Douglas Garstang
http://www.linkedin.com/in/garstang
Email: doug.garst...@gmail.com
Cell: +1-805-340-5627

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Douglas Garstang
On Wed, Aug 22, 2012 at 1:52 PM, Douglas Garstang
 wrote:
> On Wed, Aug 22, 2012 at 1:43 PM, Justin Stoller  wrote:
>> On Wed, Aug 22, 2012 at 1:34 PM, Douglas Garstang
>>  wrote:
>>> On Wed, Aug 22, 2012 at 11:08 AM, Douglas Garstang
>>>  wrote:
 On Tue, Aug 21, 2012 at 11:51 PM, Douglas Garstang
  wrote:
> On Tue, Aug 21, 2012 at 11:44 PM, Douglas Garstang
>  wrote:
>> On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
>>  wrote:
>>> Hi,
>>>
>>> On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
 I know I did this once before but can't find docs on how to do it 
 again.

 I have this in a yaml file:

 pvdisks:
 ec2_pvdisks_m1.small:
 disks: /dev/xvdb1
 enabled: yes

 Loading it with hiera.

 Manifest has:

 $testkey = hiera('pvdisks')
 notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")

 This is printing
 TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>>>
>>> Try inspecting it some other way than printf debugging - notice always
>>> flattens variables by calling .to_s on them, so it is not a very useful
>>> tool.  I am assuming that things are indeed fine, but this is confusing
>>> matters.
>>
>> I've since learned that I have to use hiera_array and hiera_hash,
>> which aren't documented anywhere.
>>
>> Now I've got:
>>
>> ec2_config:
>>   instance:
>>   m1.small:
>> pvdisks:
>> - /dev/xvdb1
>> swapvol_size: 2G
>> logvol_size: 64G
>>   m1.medium:
>> pvdisks:
>> - /dev/xvdb1
>> swapvol_size: 2G
>> logvol_size: 64G
>>   m1.large:
>> pvdisks:
>> - /dev/xvdb1
>> - /dev/xvdc1
>> swapvol_size: 4G
>> logvol_size: 64G
>>
>> and I've tried to access the data every witch way.
>>
>> This gives me a syntax error...
>> $pvdisks = 
>> hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>>
>> and this:
>> $pvdisks = 
>> hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>>
>> gives me:
>> err: Could not retrieve catalog from remote server: Error 400 on
>> SERVER: ec2_config is not an hash or array when accessing it with
>> instance at 
>> /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
>> on node gfs01.us1.xxx.com
>>
>> Ugh.
>>
>> Doug.
>
> Actually, apparently, no, that's not what these functions are for. :(
>
> Doug.

 :(
>>>
>>> Apparently this is difficult and/or not supported...
>>
>> Is this what you're trying to do?
>>
>> $ec2_config = hiera('ec2_config')
>> $pvdisks = $ec2_config['instance'][$::ec2_instance_type]['pvdisks']
>>
>>
>> http://docs.puppetlabs.com/puppet/2.7/reference/lang_datatypes.html#hashes
>
> No luck.
>
> With:
>
> ec2_config:
>   instance:
>   m1.small:
> pvdisks:
> - /dev/xvdb1
> swapvol_size: 2G
> logvol_size: 64G
>   m1.medium:
> pvdisks:
> - /dev/xvdb1
> swapvol_size: 2G
> logvol_size: 64G
>
> etc...
>
> and in the manifest:
>
> $foo = hiera_hash('ec2_config')
> $pvdisks = $foo['instance'][$::ec2_instance_type]['pvdisks']  #
> Line 17 from error below.
> notice ("PVDISKS = $pvdisks")
>
> puppet bails with:
>
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: $foo["instance"] is not an hash or array when accessing it
> with m1.large at
> /truth/sauce/env/prod/modules/role/manifests/base_server.pp:17 on node
> gfs01.us1.xxx.co,
>
> G.
>
> Doug.

I think I got it... yaml file was bad...

Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Wolf Noble
I accomplished something similar awhile back.

While I've not spent much time looking at your particular problem, I think 
this'll help point you in the direction of what you need…



class mymodule::params{
$collector= hiera('mymodule_collector','')
}

class mymodule::config{
 $collector   = $mymodule::params::collector
 $ipstring= inline_template("<% collector.each_pair do |key, hash| 
%><%=hash['ip']%>,<%end%>")
 $ips = split ($ipstring,',')
}

define mymodule::add_hosts_allow () {
  exec { "hosts_allow_$title":
command => "/bin/echo \"myservice : $title : ALLOW\" >>/etc/hosts.allow",
unless  => "/bin/grep -c \"myservice : $title : ALLOW\" /etc/hosts.allow",
  } #end exec
}


On Aug 21, 2012, at 11:00 PM, Douglas Garstang  wrote:

> I know I did this once before but can't find docs on how to do it again.
>
> I have this in a yaml file:
>
> pvdisks:
>ec2_pvdisks_m1.small:
>disks: /dev/xvdb1
>enabled: yes
>
> Loading it with hiera.
>
> Manifest has:
>
>$testkey = hiera('pvdisks')
>notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>
> This is printing
> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>
> which obviously is the data picked into a string.
>
> Doug.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
>




This message may contain confidential or privileged information. If you are not 
the intended recipient, please advise us immediately and delete this message. 
See http://www.datapipe.com/legal/email_disclaimer/ for further information on 
confidentiality and the risks of non-secure electronic communication. If you 
cannot access these links, please notify us by reply message and we will send 
the contents to you.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Douglas Garstang
On Wed, Aug 22, 2012 at 1:43 PM, Justin Stoller  wrote:
> On Wed, Aug 22, 2012 at 1:34 PM, Douglas Garstang
>  wrote:
>> On Wed, Aug 22, 2012 at 11:08 AM, Douglas Garstang
>>  wrote:
>>> On Tue, Aug 21, 2012 at 11:51 PM, Douglas Garstang
>>>  wrote:
 On Tue, Aug 21, 2012 at 11:44 PM, Douglas Garstang
  wrote:
> On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
>  wrote:
>> Hi,
>>
>> On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
>>> I know I did this once before but can't find docs on how to do it again.
>>>
>>> I have this in a yaml file:
>>>
>>> pvdisks:
>>> ec2_pvdisks_m1.small:
>>> disks: /dev/xvdb1
>>> enabled: yes
>>>
>>> Loading it with hiera.
>>>
>>> Manifest has:
>>>
>>> $testkey = hiera('pvdisks')
>>> notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>>>
>>> This is printing
>>> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>>
>> Try inspecting it some other way than printf debugging - notice always
>> flattens variables by calling .to_s on them, so it is not a very useful
>> tool.  I am assuming that things are indeed fine, but this is confusing
>> matters.
>
> I've since learned that I have to use hiera_array and hiera_hash,
> which aren't documented anywhere.
>
> Now I've got:
>
> ec2_config:
>   instance:
>   m1.small:
> pvdisks:
> - /dev/xvdb1
> swapvol_size: 2G
> logvol_size: 64G
>   m1.medium:
> pvdisks:
> - /dev/xvdb1
> swapvol_size: 2G
> logvol_size: 64G
>   m1.large:
> pvdisks:
> - /dev/xvdb1
> - /dev/xvdc1
> swapvol_size: 4G
> logvol_size: 64G
>
> and I've tried to access the data every witch way.
>
> This gives me a syntax error...
> $pvdisks = 
> hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>
> and this:
> $pvdisks = 
> hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>
> gives me:
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: ec2_config is not an hash or array when accessing it with
> instance at /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
> on node gfs01.us1.xxx.com
>
> Ugh.
>
> Doug.

 Actually, apparently, no, that's not what these functions are for. :(

 Doug.
>>>
>>> :(
>>
>> Apparently this is difficult and/or not supported...
>
> Is this what you're trying to do?
>
> $ec2_config = hiera('ec2_config')
> $pvdisks = $ec2_config['instance'][$::ec2_instance_type]['pvdisks']
>
>
> http://docs.puppetlabs.com/puppet/2.7/reference/lang_datatypes.html#hashes

No luck.

With:

ec2_config:
  instance:
  m1.small:
pvdisks:
- /dev/xvdb1
swapvol_size: 2G
logvol_size: 64G
  m1.medium:
pvdisks:
- /dev/xvdb1
swapvol_size: 2G
logvol_size: 64G

etc...

and in the manifest:

$foo = hiera_hash('ec2_config')
$pvdisks = $foo['instance'][$::ec2_instance_type]['pvdisks']  #
Line 17 from error below.
notice ("PVDISKS = $pvdisks")

puppet bails with:

err: Could not retrieve catalog from remote server: Error 400 on
SERVER: $foo["instance"] is not an hash or array when accessing it
with m1.large at
/truth/sauce/env/prod/modules/role/manifests/base_server.pp:17 on node
gfs01.us1.xxx.co,

G.

Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Justin Stoller
On Wed, Aug 22, 2012 at 1:34 PM, Douglas Garstang
 wrote:
> On Wed, Aug 22, 2012 at 11:08 AM, Douglas Garstang
>  wrote:
>> On Tue, Aug 21, 2012 at 11:51 PM, Douglas Garstang
>>  wrote:
>>> On Tue, Aug 21, 2012 at 11:44 PM, Douglas Garstang
>>>  wrote:
 On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
  wrote:
> Hi,
>
> On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
>> I know I did this once before but can't find docs on how to do it again.
>>
>> I have this in a yaml file:
>>
>> pvdisks:
>> ec2_pvdisks_m1.small:
>> disks: /dev/xvdb1
>> enabled: yes
>>
>> Loading it with hiera.
>>
>> Manifest has:
>>
>> $testkey = hiera('pvdisks')
>> notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>>
>> This is printing
>> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>
> Try inspecting it some other way than printf debugging - notice always
> flattens variables by calling .to_s on them, so it is not a very useful
> tool.  I am assuming that things are indeed fine, but this is confusing
> matters.

 I've since learned that I have to use hiera_array and hiera_hash,
 which aren't documented anywhere.

 Now I've got:

 ec2_config:
   instance:
   m1.small:
 pvdisks:
 - /dev/xvdb1
 swapvol_size: 2G
 logvol_size: 64G
   m1.medium:
 pvdisks:
 - /dev/xvdb1
 swapvol_size: 2G
 logvol_size: 64G
   m1.large:
 pvdisks:
 - /dev/xvdb1
 - /dev/xvdc1
 swapvol_size: 4G
 logvol_size: 64G

 and I've tried to access the data every witch way.

 This gives me a syntax error...
 $pvdisks = 
 hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])

 and this:
 $pvdisks = 
 hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])

 gives me:
 err: Could not retrieve catalog from remote server: Error 400 on
 SERVER: ec2_config is not an hash or array when accessing it with
 instance at /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
 on node gfs01.us1.xxx.com

 Ugh.

 Doug.
>>>
>>> Actually, apparently, no, that's not what these functions are for. :(
>>>
>>> Doug.
>>
>> :(
>
> Apparently this is difficult and/or not supported...

Is this what you're trying to do?

$ec2_config = hiera('ec2_config')
$pvdisks = $ec2_config['instance'][$::ec2_instance_type]['pvdisks']


http://docs.puppetlabs.com/puppet/2.7/reference/lang_datatypes.html#hashes

HTH,
Justin

>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Douglas Garstang
On Wed, Aug 22, 2012 at 11:08 AM, Douglas Garstang
 wrote:
> On Tue, Aug 21, 2012 at 11:51 PM, Douglas Garstang
>  wrote:
>> On Tue, Aug 21, 2012 at 11:44 PM, Douglas Garstang
>>  wrote:
>>> On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
>>>  wrote:
 Hi,

 On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
> I know I did this once before but can't find docs on how to do it again.
>
> I have this in a yaml file:
>
> pvdisks:
> ec2_pvdisks_m1.small:
> disks: /dev/xvdb1
> enabled: yes
>
> Loading it with hiera.
>
> Manifest has:
>
> $testkey = hiera('pvdisks')
> notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>
> This is printing
> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']

 Try inspecting it some other way than printf debugging - notice always
 flattens variables by calling .to_s on them, so it is not a very useful
 tool.  I am assuming that things are indeed fine, but this is confusing
 matters.
>>>
>>> I've since learned that I have to use hiera_array and hiera_hash,
>>> which aren't documented anywhere.
>>>
>>> Now I've got:
>>>
>>> ec2_config:
>>>   instance:
>>>   m1.small:
>>> pvdisks:
>>> - /dev/xvdb1
>>> swapvol_size: 2G
>>> logvol_size: 64G
>>>   m1.medium:
>>> pvdisks:
>>> - /dev/xvdb1
>>> swapvol_size: 2G
>>> logvol_size: 64G
>>>   m1.large:
>>> pvdisks:
>>> - /dev/xvdb1
>>> - /dev/xvdc1
>>> swapvol_size: 4G
>>> logvol_size: 64G
>>>
>>> and I've tried to access the data every witch way.
>>>
>>> This gives me a syntax error...
>>> $pvdisks = 
>>> hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>>>
>>> and this:
>>> $pvdisks = 
>>> hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>>>
>>> gives me:
>>> err: Could not retrieve catalog from remote server: Error 400 on
>>> SERVER: ec2_config is not an hash or array when accessing it with
>>> instance at /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
>>> on node gfs01.us1.xxx.com
>>>
>>> Ugh.
>>>
>>> Doug.
>>
>> Actually, apparently, no, that's not what these functions are for. :(
>>
>> Doug.
>
> :(

Apparently this is difficult and/or not supported...

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-22 Thread Douglas Garstang
On Tue, Aug 21, 2012 at 11:51 PM, Douglas Garstang
 wrote:
> On Tue, Aug 21, 2012 at 11:44 PM, Douglas Garstang
>  wrote:
>> On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
>>  wrote:
>>> Hi,
>>>
>>> On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
 I know I did this once before but can't find docs on how to do it again.

 I have this in a yaml file:

 pvdisks:
 ec2_pvdisks_m1.small:
 disks: /dev/xvdb1
 enabled: yes

 Loading it with hiera.

 Manifest has:

 $testkey = hiera('pvdisks')
 notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")

 This is printing
 TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>>>
>>> Try inspecting it some other way than printf debugging - notice always
>>> flattens variables by calling .to_s on them, so it is not a very useful
>>> tool.  I am assuming that things are indeed fine, but this is confusing
>>> matters.
>>
>> I've since learned that I have to use hiera_array and hiera_hash,
>> which aren't documented anywhere.
>>
>> Now I've got:
>>
>> ec2_config:
>>   instance:
>>   m1.small:
>> pvdisks:
>> - /dev/xvdb1
>> swapvol_size: 2G
>> logvol_size: 64G
>>   m1.medium:
>> pvdisks:
>> - /dev/xvdb1
>> swapvol_size: 2G
>> logvol_size: 64G
>>   m1.large:
>> pvdisks:
>> - /dev/xvdb1
>> - /dev/xvdc1
>> swapvol_size: 4G
>> logvol_size: 64G
>>
>> and I've tried to access the data every witch way.
>>
>> This gives me a syntax error...
>> $pvdisks = 
>> hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>>
>> and this:
>> $pvdisks = 
>> hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>>
>> gives me:
>> err: Could not retrieve catalog from remote server: Error 400 on
>> SERVER: ec2_config is not an hash or array when accessing it with
>> instance at /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
>> on node gfs01.us1.xxx.com
>>
>> Ugh.
>>
>> Doug.
>
> Actually, apparently, no, that's not what these functions are for. :(
>
> Doug.

:(

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-21 Thread Douglas Garstang
On Tue, Aug 21, 2012 at 11:44 PM, Douglas Garstang
 wrote:
> On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
>  wrote:
>> Hi,
>>
>> On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
>>> I know I did this once before but can't find docs on how to do it again.
>>>
>>> I have this in a yaml file:
>>>
>>> pvdisks:
>>> ec2_pvdisks_m1.small:
>>> disks: /dev/xvdb1
>>> enabled: yes
>>>
>>> Loading it with hiera.
>>>
>>> Manifest has:
>>>
>>> $testkey = hiera('pvdisks')
>>> notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>>>
>>> This is printing
>>> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>>
>> Try inspecting it some other way than printf debugging - notice always
>> flattens variables by calling .to_s on them, so it is not a very useful
>> tool.  I am assuming that things are indeed fine, but this is confusing
>> matters.
>
> I've since learned that I have to use hiera_array and hiera_hash,
> which aren't documented anywhere.
>
> Now I've got:
>
> ec2_config:
>   instance:
>   m1.small:
> pvdisks:
> - /dev/xvdb1
> swapvol_size: 2G
> logvol_size: 64G
>   m1.medium:
> pvdisks:
> - /dev/xvdb1
> swapvol_size: 2G
> logvol_size: 64G
>   m1.large:
> pvdisks:
> - /dev/xvdb1
> - /dev/xvdc1
> swapvol_size: 4G
> logvol_size: 64G
>
> and I've tried to access the data every witch way.
>
> This gives me a syntax error...
> $pvdisks = 
> hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>
> and this:
> $pvdisks = 
> hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])
>
> gives me:
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: ec2_config is not an hash or array when accessing it with
> instance at /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
> on node gfs01.us1.xxx.com
>
> Ugh.
>
> Doug.

Actually, apparently, no, that's not what these functions are for. :(

Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-21 Thread Douglas Garstang
On Tue, Aug 21, 2012 at 11:19 PM, Stephen Gran
 wrote:
> Hi,
>
> On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
>> I know I did this once before but can't find docs on how to do it again.
>>
>> I have this in a yaml file:
>>
>> pvdisks:
>> ec2_pvdisks_m1.small:
>> disks: /dev/xvdb1
>> enabled: yes
>>
>> Loading it with hiera.
>>
>> Manifest has:
>>
>> $testkey = hiera('pvdisks')
>> notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
>>
>> This is printing
>> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']
>
> Try inspecting it some other way than printf debugging - notice always
> flattens variables by calling .to_s on them, so it is not a very useful
> tool.  I am assuming that things are indeed fine, but this is confusing
> matters.

I've since learned that I have to use hiera_array and hiera_hash,
which aren't documented anywhere.

Now I've got:

ec2_config:
  instance:
  m1.small:
pvdisks:
- /dev/xvdb1
swapvol_size: 2G
logvol_size: 64G
  m1.medium:
pvdisks:
- /dev/xvdb1
swapvol_size: 2G
logvol_size: 64G
  m1.large:
pvdisks:
- /dev/xvdb1
- /dev/xvdc1
swapvol_size: 4G
logvol_size: 64G

and I've tried to access the data every witch way.

This gives me a syntax error...
$pvdisks = hiera_array(ec2_config['instance'][$::ec2_instance_type]['pvdisks'])

and this:
$pvdisks = hiera_array($ec2_config['instance'][$::ec2_instance_type]['pvdisks'])

gives me:
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: ec2_config is not an hash or array when accessing it with
instance at /truth/sauce/env/prod/modules/role/manifests/base_server.pp:27
on node gfs01.us1.xxx.com

Ugh.

Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Hiera to hash

2012-08-21 Thread Stephen Gran
Hi,

On Tue, 2012-08-21 at 21:00 -0700, Douglas Garstang wrote:
> I know I did this once before but can't find docs on how to do it again.
> 
> I have this in a yaml file:
> 
> pvdisks:
> ec2_pvdisks_m1.small:
> disks: /dev/xvdb1
> enabled: yes
> 
> Loading it with hiera.
> 
> Manifest has:
> 
> $testkey = hiera('pvdisks')
> notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")
> 
> This is printing
> TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']

Try inspecting it some other way than printf debugging - notice always
flattens variables by calling .to_s on them, so it is not a very useful
tool.  I am assuming that things are indeed fine, but this is confusing
matters.

Cheers,
-- 
Stephen Gran
Senior Systems Integrator - guardian.co.uk

Please consider the environment before printing this email.
--
Visit guardian.co.uk - newspaper of the year

www.guardian.co.ukwww.observer.co.uk www.guardiannews.com 

On your mobile, visit m.guardian.co.uk or download the Guardian
iPhone app www.guardian.co.uk/iphone and iPad edition www.guardian.co.uk/iPad 
 
Save up to 37% by subscribing to the Guardian and Observer - choose the papers 
you want and get full digital access. 
Visit guardian.co.uk/subscribe 

-
This e-mail and all attachments are confidential and may also
be privileged. If you are not the named recipient, please notify
the sender and delete the e-mail and all attachments immediately.
Do not disclose the contents to another person. You may not use
the information for any purpose, or store, or copy, it in any way.
 
Guardian News & Media Limited is not liable for any computer
viruses or other material transmitted with or as part of this
e-mail. You should employ virus checking software.

Guardian News & Media Limited

A member of Guardian Media Group plc
Registered Office
PO Box 68164
Kings Place
90 York Way
London
N1P 2AP

Registered in England Number 908396

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Hiera to hash

2012-08-21 Thread Douglas Garstang
I know I did this once before but can't find docs on how to do it again.

I have this in a yaml file:

pvdisks:
ec2_pvdisks_m1.small:
disks: /dev/xvdb1
enabled: yes

Loading it with hiera.

Manifest has:

$testkey = hiera('pvdisks')
notice ("TESTKEY=$testkey[ec2_pvdisks_m1.small]")

This is printing
TESTKEY=ec2_pvdisks_m1.smalldisks/dev/xvdb1enabledtrue['ec2_pvdisks_m1.small']

which obviously is the data picked into a string.

Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.