The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #5860

arrays do not work in selectors

Added by Adam Crews over 3 years ago. Updated 4 months ago.

Status:AcceptedStart date:01/12/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Affected Puppet version: Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket is now tracked at: https://tickets.puppetlabs.com/browse/PUP-1216


Description

Using an array in a selector does not work:

$info = [ "acrews", "Adam", "/bin/bash" ] 
$shell = $info[2] ? { 
    /bin/ => $info[2], 
    default => "/sbin/nologin", 
} 

I get: Syntax error at ‘?’; expected ‘}

If I do this it works:

$info = [ "acrews", "Adam", "/bin/bash" ] 
$AA = $info[2] 
$shell => $AA ? { 
   /bin/ => $info[2], 
   default => "/sbin/nologin", 
}

An array element should be able to be used exactly like any normal variable.

I see this on 2.6.4.


Related issues

Related to Puppet - Bug #5516: Hashes can't be used in selectors Closed 12/12/2010

History

#1 Updated by Nigel Kersten about 3 years ago

  • Status changed from Unreviewed to Accepted
  • Target version set to 2.7.x

#2 Updated by Peter Meier almost 3 years ago

Also the following does not work:

$foo = []
$real_foo = $foo ? {
  [] => [ 960010 ],
  default => $foo
}

notice $real_foo

#3 Updated by Adam Crews over 2 years ago

The original code reported in this ticket now works on pe-1.2.1. The code in the comments still doesn’t work.

#4 Updated by Dominic Cleal almost 2 years ago

The same goes for returning hashes from a selector:

$foo = "test"
$real_foo = $foo ? {
  default => { test => "foo" },
}
notice($foo[test])

throws this:

err: Could not parse for environment production: Syntax error at '{'; expected '}' at /home/dcleal/tmp/5860.pp:3 ...

#5 Updated by Andrew Parker over 1 year ago

  • Target version deleted (2.7.x)

#6 Updated by Andrew Parker over 1 year ago

As the 2.7.x line is winding down, I am removing the target at 2.7.x from tickets in the system. The 2.7 line should only receive fixes for major problems (crashes, for instance) or security problems.

#7 Updated by Anonymous 4 months ago

Redmine Issue #5860 has been migrated to JIRA:

https://tickets.puppetlabs.com/browse/PUP-1216

Also available in: Atom PDF