Ask Your Question
0

Why does this array variable not expand in package?

asked 2015-01-12 14:14:07 -0500

david.arnold gravatar image

I have been trying to get this to work today and I don't understand why it wont work. Can someone give me a hint please?

class omd {
  $prereqs = [
    "debconf-2.0",
    "libapache2-mod-python",
    "libapache2-mod-php5",
    "php5-sqlite",
    "php5-mcrypt",
    "libgd2-xpm",
    "libdbi0",
    "libapache2-mod-proxy-html",
    "xinetd",
    "mysql-server",
    "graphviz",
    "dnsutils",
    "snmp",
    "fping",
    "smbclient",
    "unzip",
    "libnet-snmp-perl",
    "libxml-simple-perl",
  ]
  package { ${prereqs} :
    ensure  => installed,
  }

The error I get is: Could not parse for environment production: Could not match ${prereqs} at modules/omd/manifests/init.pp:25

Many thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-01-12 15:12:13 -0500

cbarbour gravatar image

Bare variables should not be surrounded by curly braces. Try this instead:

package { $prereqs:
  ensure  => installed,
}
edit flag offensive delete link more

Comments

Excellent. I thought I had tried that but obviously I had made an error somewhere. Your answer worked. Thank you for the help.

david.arnold gravatar imagedavid.arnold ( 2015-01-13 02:24:04 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-01-12 14:14:07 -0500

Seen: 191 times

Last updated: Jan 12 '15