hiera variable and "if statements" in manifest not working

399 views
Skip to first unread message

Kenton Brede

unread,
Feb 26, 2014, 9:18:21 AM2/26/14
to puppet...@googlegroups.com
So I've got a variable set in Hiera:

---
vmw_tools_purge:
    - 'PURGE'

In the manifest, the following works fine:

$vmw_tools_purge = hiera('vmw_tools_purge')
notify { $vmw_tools_purge: }

But this does not work.  The "if statement" is just ignored and notify isn't triggered.  What am I doing wrong? 

if $vmw_tools_purge == 'PURGE' {
    notify { $vmw_tools_purge: }
}

Thanks,

--
Kent Brede




Felix Frank

unread,
Feb 26, 2014, 9:26:21 AM2/26/14
to puppet...@googlegroups.com
Hi,

On 02/26/2014 03:18 PM, Kenton Brede wrote:
> vmw_tools_purge:
> - 'PURGE'

not that you are defining an array here, not a string. That would look like

vm_tools_purge: 'PURGE'

> $vmw_tools_purge = hiera('vmw_tools_purge')
> notify { $vmw_tools_purge: }

This works because puppet helpfully converts the array to a string by
concatenating all elements.

> if $vmw_tools_purge == 'PURGE' {

This would not work the same way, though. You may verify whether

if $vmw_tools_purge == [ 'PURGE' ]

does in fact work, but it would be a funny construct anyway. It should
be fixed in YAML.

Regards,
Felix

Kenton Brede

unread,
Feb 26, 2014, 9:39:12 AM2/26/14
to puppet...@googlegroups.com
Doh!  That was it, thanks.

--
Kent Brede




Reply all
Reply to author
Forward
0 new messages