Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given the following puppet manifest, how can I merge / concatenate the two arrays such that the command will execute with both a=b and b=c ?

  environment => ["a=b"]

class a{
    command     => "/usr/bin/true",
    user        => "francois",
    environment => ["b=c"],

include a

My crontab entry ends up like this:

# Puppet Name: test
* * * * * /usr/bin/true
share|improve this question
up vote 1 down vote accepted

As I recall you can't do it directly. Something like this might work though:

$default_env = ["a=b"]

Cron {
  environment => $default_env

class a {
  $additional_env = split(inline_template("<%= (default_env).join(',') %>"),',')

  cron {"test":
    command => "true",
    user => "me",
    environment => $additional_env

include a

(the split/inline_template is based off of something from )

share|improve this answer
In this case, you don't need to go through all those machinations -- most Puppet providers/types will collapse nested arrays by themselves if nested arrays don't make sense in context. All you should need is something like: $additional_env = [$default_env, 'b=c']. – jgoldschrafe Feb 20 '12 at 6:39
@jgoldschrafe Doesn't seem to be working on puppet 3.1 using cron itself. – François Beausoleil Apr 17 '13 at 15:47
If this is causing issues, the Puppet Labs stdlib does contain a flatten() function that's probably the simplest way to approach this. – jgoldschrafe Apr 21 '13 at 18:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.