The Puppet Labs Issue Tracker has Moved:

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using See the following page for information on filing tickets with JIRA:

Bug #5860

arrays do not work in selectors

Added by Adam Crews over 5 years ago. Updated over 2 years ago.

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


Target version:-
Affected Puppet version: Branch:

We've Moved!

Ticket tracking is now hosted in JIRA:

This ticket is now tracked at:


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


#1 Updated by Nigel Kersten over 5 years ago

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

#2 Updated by Peter Meier about 5 years ago

Also the following does not work:

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

notice $real_foo

#3 Updated by Adam Crews over 4 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 about 4 years ago

The same goes for returning hashes from a selector:

$foo = "test"
$real_foo = $foo ? {
  default => { test => "foo" },

throws this:

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

#5 Updated by Anonymous over 3 years ago

  • Target version deleted (2.7.x)

#6 Updated by Anonymous over 3 years 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 over 2 years ago

Redmine Issue #5860 has been migrated to JIRA:

Also available in: Atom PDF