FAQ
Hi all,

I have a manifest that look like this

case $provider {
'package' : {
package {'mypackage' :
ensure => latest,
}
}
'source' : {
exec {'install procedure' :
}
}

$test = get_test_path()

file {'myconf' :
content => templates('mod/myconf'),
}

Within mycon template I have a variable 'test' that depending if the
package was installed from source of from the package will have a different
path.
Issue is that the function get_test_path() seems to be done at compile
time, so the first time I run it will always result in an erroneous answer.
After a second run it will be fine.

Does any one can provide guidance on how I could make it work at the first
run ?

Thank you,

--
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/-/t-tAovcULSoJ.
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

  • Yanis Guenane at Nov 27, 2012 at 10:58 pm
    *Specification* : my manifest look more like this

    class myclass ($provider = 'package') {
    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }
    }

    define myclass::mydefine() {
    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }
    }

    On Tuesday, November 27, 2012 11:23:50 PM UTC+1, Yanis Guenane wrote:

    Hi all,

    I have a manifest that look like this

    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }

    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }

    Within mycon template I have a variable 'test' that depending if the
    package was installed from source of from the package will have a different
    path.
    Issue is that the function get_test_path() seems to be done at compile
    time, so the first time I run it will always result in an erroneous answer.
    After a second run it will be fine.

    Does any one can provide guidance on how I could make it work at the first
    run ?

    Thank you,
    --
    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/-/IvLocvAcfkAJ.
    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.
  • Joe at Nov 28, 2012 at 12:17 am
    What you should do instead is set the path based on the value of
    $myclass::provider.

    if $myclass::provider == 'package' {

    On Tuesday, November 27, 2012 3:58:05 PM UTC-7, Yanis Guenane wrote:

    *Specification* : my manifest look more like this

    class myclass ($provider = 'package') {
    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }
    }

    define myclass::mydefine() {
    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }
    }

    On Tuesday, November 27, 2012 11:23:50 PM UTC+1, Yanis Guenane wrote:

    Hi all,

    I have a manifest that look like this

    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }

    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }

    Within mycon template I have a variable 'test' that depending if the
    package was installed from source of from the package will have a different
    path.
    Issue is that the function get_test_path() seems to be done at compile
    time, so the first time I run it will always result in an erroneous answer.
    After a second run it will be fine.

    Does any one can provide guidance on how I could make it work at the
    first run ?

    Thank you,
    --
    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/-/ne0VVEvq-VMJ.
    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.
  • Joe at Nov 28, 2012 at 12:19 am
    You should set the path based on the value of $myclass::provider:

    if $myclass::provider == 'package' {
    test = '/path/a'
    }
    else {
    test = '/path/b'
    }
    On Tuesday, November 27, 2012 3:58:05 PM UTC-7, Yanis Guenane wrote:

    *Specification* : my manifest look more like this

    class myclass ($provider = 'package') {
    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }
    }

    define myclass::mydefine() {
    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }
    }

    On Tuesday, November 27, 2012 11:23:50 PM UTC+1, Yanis Guenane wrote:

    Hi all,

    I have a manifest that look like this

    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }

    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }

    Within mycon template I have a variable 'test' that depending if the
    package was installed from source of from the package will have a different
    path.
    Issue is that the function get_test_path() seems to be done at compile
    time, so the first time I run it will always result in an erroneous answer.
    After a second run it will be fine.

    Does any one can provide guidance on how I could make it work at the
    first run ?

    Thank you,
    --
    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/-/hMQYjwpofeIJ.
    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.
  • Yanis Guenane at Nov 28, 2012 at 7:54 am
    Thanks, I don't know why I tried to make it hard when it could be simple.
    On Wednesday, November 28, 2012 1:19:14 AM UTC+1, joe wrote:

    You should set the path based on the value of $myclass::provider:

    if $myclass::provider == 'package' {
    test = '/path/a'
    }
    else {
    test = '/path/b'
    }
    On Tuesday, November 27, 2012 3:58:05 PM UTC-7, Yanis Guenane wrote:

    *Specification* : my manifest look more like this

    class myclass ($provider = 'package') {
    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }
    }

    define myclass::mydefine() {
    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }
    }

    On Tuesday, November 27, 2012 11:23:50 PM UTC+1, Yanis Guenane wrote:

    Hi all,

    I have a manifest that look like this

    case $provider {
    'package' : {
    package {'mypackage' :
    ensure => latest,
    }
    }
    'source' : {
    exec {'install procedure' :
    }
    }

    $test = get_test_path()

    file {'myconf' :
    content => templates('mod/myconf'),
    }

    Within mycon template I have a variable 'test' that depending if the
    package was installed from source of from the package will have a different
    path.
    Issue is that the function get_test_path() seems to be done at compile
    time, so the first time I run it will always result in an erroneous answer.
    After a second run it will be fine.

    Does any one can provide guidance on how I could make it work at the
    first run ?

    Thank you,
    --
    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/-/2GJ3Q90QfKAJ.
    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 Nov 28, 2012 at 2:50 pm

    On Tuesday, November 27, 2012 4:23:50 PM UTC-6, Yanis Guenane wrote:
    Within mycon template I have a variable 'test' that depending if the
    package was installed from source of from the package will have a different
    path.
    Issue is that the function get_test_path() seems to be done at compile
    time, so the first time I run it will always result in an erroneous answer.
    After a second run it will be fine.
    To answer the question posed by the thread subject, no, it is not possible
    to make puppet functions be evaluated by the puppet agent during catalog
    application. They are always evaluated by the master during catalog
    compilation.

    Any dynamic behavior you want to happen on the agent side must be performed
    by your resources. Often you don't actually need agent-side dynamism
    beyond what Puppet already provides, but when you do, you generally need
    either to use an Exec resource, or to write a custom provider for an
    existing resource type, or to write a whole custom type / provider pair.


    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/-/7FI9BFD4LB0J.
    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.
  • Yanis Guenane at Dec 1, 2012 at 12:55 pm
    Thank you John for the answer, it clarified some doubts I had.
    On Wednesday, November 28, 2012 3:50:01 PM UTC+1, jcbollinger wrote:


    On Tuesday, November 27, 2012 4:23:50 PM UTC-6, Yanis Guenane wrote:

    Within mycon template I have a variable 'test' that depending if the
    package was installed from source of from the package will have a different
    path.
    Issue is that the function get_test_path() seems to be done at compile
    time, so the first time I run it will always result in an erroneous answer.
    After a second run it will be fine.
    To answer the question posed by the thread subject, no, it is not possible
    to make puppet functions be evaluated by the puppet agent during catalog
    application. They are always evaluated by the master during catalog
    compilation.

    Any dynamic behavior you want to happen on the agent side must be
    performed by your resources. Often you don't actually need agent-side
    dynamism beyond what Puppet already provides, but when you do, you
    generally need either to use an Exec resource, or to write a custom
    provider for an existing resource type, or to write a whole custom type /
    provider pair.


    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/-/KdHb0O_4OhgJ.
    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
postedNov 27, '12 at 10:23p
activeDec 1, '12 at 12:55p
posts7
users3
websitepuppetlabs.com

3 users in discussion

Yanis Guenane: 4 posts Joe: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase