FAQ
I'm trying to add elements to an array with the plusingment operator.
However the following results in

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '+>'; expected '}' at /etc/puppet/modules/php/manifests/params.pp:17

(This isn't a question of whether or not php53 will be happy with php-pecl-memcache, its about extending arrays).

class php::params {
case $osmajor {
'5': {
$phpService = 'php53'
$phpModules = [
'php-pecl-memcache',
]
}
default: {
$phpService = 'php'
$phpModules = [
'php-pecl-memcached',
]
}
}
$phpVersion = 'latest'
$phpModules +> [ "${phpService}-mysql",
"${phpService}-xml",
"${phpService}-mbstring",
"${phpService}-cli",
"${phpService}-gd",
"${phpService}-soap",
]
}

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Matonb at Jul 20, 2012 at 8:33 am
    This does work though:

    class php::params {
    case $osmajor {
    '5': {
    $phpService = 'php53'
    $Modules = [
    'php-pecl-memcache',
    ]
    }
    default: {
    $phpService = 'php'
    $Modules = [
    'php-pecl-memcached',
    ]
    }
    }
    $phpVersion = 'latest'
    $phpModules = [ "${phpService}-mysql",
    "${phpService}-xml",
    "${phpService}-mbstring",
    "${phpService}-cli",
    "${phpService}-gd",
    "${phpService}-soap",
    $Modules,
    ]
    }

    On Friday, 20 July 2012 08:58:15 UTC+1, Brett Maton wrote:


    I'm trying to add elements to an array with the plusingment operator.
    However the following results in

    err: Could not retrieve catalog from remote server: Error 400 on SERVER:
    Syntax error at '+>'; expected '}' at
    /etc/puppet/modules/php/manifests/params.pp:17

    (This isn't a question of whether or not php53 will be happy with
    php-pecl-memcache, its about extending arrays).

    class php::params {
    case $osmajor {
    '5': {
    $phpService = 'php53'
    $phpModules = [
    'php-pecl-memcache',
    ]
    }
    default: {
    $phpService = 'php'
    $phpModules = [
    'php-pecl-memcached',
    ]
    }
    }
    $phpVersion = 'latest'
    $phpModules +> [ "${phpService}-mysql",
    "${phpService}-xml",
    "${phpService}-mbstring",
    "${phpService}-cli",
    "${phpService}-gd",
    "${phpService}-soap",
    ]
    }
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/rpd4rOd-DYIJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Jcbollinger at Jul 20, 2012 at 1:09 pm

    On Friday, July 20, 2012 2:58:15 AM UTC-5, Brett Maton wrote:

    I'm trying to add elements to an array with the plusingment operator.
    However the following results in

    err: Could not retrieve catalog from remote server: Error 400 on SERVER:
    Syntax error at '+>'; expected '}' at
    /etc/puppet/modules/php/manifests/params.pp:17

    (This isn't a question of whether or not php53 will be happy with
    php-pecl-memcache, its about extending arrays).

    class php::params {
    case $osmajor {
    '5': {
    $phpService = 'php53'
    $phpModules = [
    'php-pecl-memcache',
    ]
    }
    default: {
    $phpService = 'php'
    $phpModules = [
    'php-pecl-memcached',
    ]
    }
    }
    $phpVersion = 'latest'
    $phpModules +> [ "${phpService}-mysql",
    "${phpService}-xml",
    "${phpService}-mbstring",
    "${phpService}-cli",
    "${phpService}-gd",
    "${phpService}-soap",
    ]
    }
    You can never, under any circumstances, by any means, change the value of a
    Puppet variable once it is set. This is a Puppet invariant.

    The plussignment operator gives the *illusion* of appending to an array
    variable that belongs to a different scope, but would normally be visible
    in the current scope as a result of dynamic scoping. It is best to think
    of it as creating a new variable of the same name in the current scope,
    with a value derived from the original one's as directed by the
    plussignment.

    Plussignment cannot be applied to a variable that has already been declared
    in the current scope, either directly or by a different plussignment, on
    account of the prohibition against changing existing variables' values.

    Also, be aware that scoping in Puppet does not follow the same rules as it
    does in many programming languages. Most blocks (delimited in Puppet by
    curly braces, {}) do not establish new scopes. Aside from the global
    scope, only class bodies, definition bodies, and node declarations
    establish new scopes.

    Because plussignment is inherently connected to dynamic scoping, and
    dynamic scoping is deprecated, it would be best to find a different way to
    do what you're trying to do.


    John

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/dEjkXBituqIJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJul 20, '12 at 7:58a
activeJul 20, '12 at 1:09p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Matonb: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase