FAQ
I am trying to write a define type which will use an array but in the
meantime have an argument pass to it that sets a case. See for example :

define link_files ($linkcase) {

case $linkcase {
"var" : {
file { "${name}_exelink" :
path => "/var/log/puppet/${name}_log",
ensure => link,
target => "/var/log/puppet/${name}_lastlog",
}
}

"data" : {
file { "${name}_exelink" :
path => "/var/log/puppet/${name}_log",
ensure => link,
target => "/var/data/log/puppet/${name}_lastlog",
}
}
}
}

I would like to use array of names inside manifests.

I tried to call it like this :

$mynamevar = range("node01", "node05")

link_files { '$mynamevar' :
$linkcase => "var",
}

but it doesn't like it and complains this :
Error 400 on SERVER: Syntax error at 'linkcase'; expected '}'

What should be the correct syntax for this ?

In principle, without the case $linkcase argument one could run the define
type for an array by using just like,
link_files {$mynamevar :}

Thanks for any suggestion.





--
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/-/C3bU_P7MPcYJ.
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

  • Jakov Sosic at Dec 5, 2012 at 11:21 pm

    On 12/04/2012 09:48 PM, iamauser wrote:

    link_files { '$mynamevar' :
    When you pass the argument within the single quotes, variables are not
    parsed AFAIK. Maybe that's your issue. Remove the quotes?

    --
    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.
  • Iamauser at Dec 5, 2012 at 11:24 pm
    Thanks, but I have tried that already, it doesn't help.

    -Tapas
    On Wednesday, December 5, 2012 5:21:46 PM UTC-6, Jakov Sosic wrote:
    On 12/04/2012 09:48 PM, iamauser wrote:

    link_files { '$mynamevar' :
    When you pass the argument within the single quotes, variables are not
    parsed AFAIK. Maybe that's your issue. Remove the quotes?
    --
    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/-/K5cjLPi8zWIJ.
    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.
  • Jakov Sosic at Dec 5, 2012 at 11:50 pm

    On 12/06/2012 12:24 AM, iamauser wrote:
    Thanks, but I have tried that already, it doesn't help.
    You have another syntax problem that escaped me first time I reviewed
    your code...

    This is the problem:

    link_files { '$mynamevar' :
    $linkcase => "var",
    }

    You should remove quotes around array, dollar sign in front of linkcase,
    and replace doublequotes around simple string with singleqoutes:

    link_files { $mynamevar :
    linkcase => 'var',
    }



    Really, your code is a mess... You have doublequote where singlequotes
    would be enough, singleqoutes where they should not be at all, dollar
    sign in front of param in resource, you don't use two-space as
    identation, you don't have default: {} in your case conditional, you
    have blanks after the end of line, etc, etc...

    I urge you to use 'puppet parser validate' and 'puppet-lint' to review
    your code. It would be even better if you would use it in your
    pre-commit hooks, so that you cannot commit code that is written bellow
    certain standards.

    --
    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.
  • Iamauser at Dec 5, 2012 at 11:58 pm

    On Wednesday, December 5, 2012 5:50:30 PM UTC-6, Jakov Sosic wrote:
    On 12/06/2012 12:24 AM, iamauser wrote:
    Thanks, but I have tried that already, it doesn't help.
    You have another syntax problem that escaped me first time I reviewed
    your code...

    This is the problem:

    link_files { '$mynamevar' :
    $linkcase => "var",
    }

    You should remove quotes around array, dollar sign in front of linkcase,
    and replace doublequotes around simple string with singleqoutes:

    link_files { $mynamevar :
    linkcase => 'var',
    }

    First of all, I didn't copy paste my code, rather typed it here, so
    indentation should be ignored.
    You are right, dollar sign shouldn't be there, and I think it was a typo on
    my part that I failed to notice. I disagree with your comment about
    singlequote or doublequote for "var". That shouldn't be an issue here as it
    will consider this as string of characters.

    Really, your code is a mess... You have doublequote where singlequotes
    would be enough, singleqoutes where they should not be at all, dollar
    sign in front of param in resource, you don't use two-space as
    identation, you don't have default: {} in your case conditional, you
    have blanks after the end of line, etc, etc...

    I urge you to use 'puppet parser validate' and 'puppet-lint' to review
    your code. It would be even better if you would use it in your
    pre-commit hooks, so that you cannot commit code that is written bellow
    certain standards.
    Thanks and I am aware of all these in practice.




    --
    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/-/ciTqE41wW38J.
    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.
  • Jakov Sosic at Dec 6, 2012 at 12:17 am

    On 12/06/2012 12:58 AM, iamauser wrote:
    First of all, I didn't copy paste my code, rather typed it here, so
    indentation should be ignored.
    You are right, dollar sign shouldn't be there, and I think it was a typo
    on my part that I failed to notice. I disagree with your comment about
    singlequote or doublequote for "var". That shouldn't be an issue here as
    it will consider this as string of characters.
    Sorry if my comments sounded harsh, I didn't mean to offend you. Just
    urge you to incorporate those tools into your daily practice, which
    would save you a lot of time and nerves ;)

    --
    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.
  • Iamauser at Dec 6, 2012 at 12:19 am
    No worries. Your comment helped me to notice the dollar sign in front of
    the linkcase. That actually solved the issue. Now it works and yes, I have
    added a default case as well :)

    Thanks

    On Wednesday, December 5, 2012 6:16:55 PM UTC-6, Jakov Sosic wrote:
    On 12/06/2012 12:58 AM, iamauser wrote:
    First of all, I didn't copy paste my code, rather typed it here, so
    indentation should be ignored.
    You are right, dollar sign shouldn't be there, and I think it was a typo
    on my part that I failed to notice. I disagree with your comment about
    singlequote or doublequote for "var". That shouldn't be an issue here as
    it will consider this as string of characters.
    Sorry if my comments sounded harsh, I didn't mean to offend you. Just
    urge you to incorporate those tools into your daily practice, which
    would save you a lot of time and nerves ;)
    --
    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/-/I07DoBUDI_gJ.
    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.
  • Nikola Petrov at Dec 6, 2012 at 3:11 pm
    You should consider using a good editor which will show those error for
    you. You can incorporate puppet-lint for example and it will spot most
    of the problems and warn you about the double quotes for performance and
    clarity reasons.

    Hope that helps :-)

    Best, Nikola
    On Wed, Dec 05, 2012 at 04:19:35PM -0800, iamauser wrote:
    No worries. Your comment helped me to notice the dollar sign in front of
    the linkcase. That actually solved the issue. Now it works and yes, I have
    added a default case as well :)

    Thanks

    On Wednesday, December 5, 2012 6:16:55 PM UTC-6, Jakov Sosic wrote:
    On 12/06/2012 12:58 AM, iamauser wrote:
    First of all, I didn't copy paste my code, rather typed it here, so
    indentation should be ignored.
    You are right, dollar sign shouldn't be there, and I think it was a typo
    on my part that I failed to notice. I disagree with your comment about
    singlequote or doublequote for "var". That shouldn't be an issue here as
    it will consider this as string of characters.
    Sorry if my comments sounded harsh, I didn't mean to offend you. Just
    urge you to incorporate those tools into your daily practice, which
    would save you a lot of time and nerves ;)
    --
    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/-/I07DoBUDI_gJ.
    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.
    --
    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.
  • Iamauser at Dec 6, 2012 at 4:51 pm
    Hi,

    I had tried installing puppet-lint sometime ago, and tried this again as
    you wrote, but I get a bunch of buffer overflow (see below). I have
    reported an issue with rodjek's github and let's see if I get an answer.
    Any suggestion from this forum will certainly help.

    ]# gem install puppet-lint
    *** buffer overflow detected ***: /usr/bin/ruby terminated
    ======= Backtrace: =========
    /lib64/libc.so.6(__chk_fail+0x2f)[0x2af4423bffaf]
    /usr/lib64/ruby/1.8/x86_64-linux/syck.so(rb_syck_mktime+0x48e)[0x2af44284149e]
    /usr/lib64/ruby/1.8/x86_64-linux/syck.so(yaml_org_handler+0x860)[0x2af442841db0]
    /usr/lib64/ruby/1.8/x86_64-linux/syck.so(syck_defaultresolver_node_import+0x39)[0x2af442841fb9]
    /usr/lib64/libruby.so.1.8[0x2af441737a9e]
    /usr/lib64/libruby.so.1.8[0x2af441737fb8]
    /usr/lib64/libruby.so.1.8[0x2af441738562]
    .....
    .....
    and goes on...

    am I missing something trivial in here ?

    ]# gem --version
    1.3.1
    ]# ruby --version
    ruby 1.8.5 (2006-08-25) [x86_64-linux]

    #####


    On Thursday, December 6, 2012 9:11:17 AM UTC-6, nikolavp wrote:

    You should consider using a good editor which will show those error for
    you. You can incorporate puppet-lint for example and it will spot most
    of the problems and warn you about the double quotes for performance and
    clarity reasons.

    Hope that helps :-)

    Best, Nikola
    On Wed, Dec 05, 2012 at 04:19:35PM -0800, iamauser wrote:
    No worries. Your comment helped me to notice the dollar sign in front of
    the linkcase. That actually solved the issue. Now it works and yes, I have
    added a default case as well :)

    Thanks

    On Wednesday, December 5, 2012 6:16:55 PM UTC-6, Jakov Sosic wrote:
    On 12/06/2012 12:58 AM, iamauser wrote:
    First of all, I didn't copy paste my code, rather typed it here, so
    indentation should be ignored.
    You are right, dollar sign shouldn't be there, and I think it was a
    typo
    on my part that I failed to notice. I disagree with your comment
    about
    singlequote or doublequote for "var". That shouldn't be an issue
    here as
    it will consider this as string of characters.
    Sorry if my comments sounded harsh, I didn't mean to offend you. Just
    urge you to incorporate those tools into your daily practice, which
    would save you a lot of time and nerves ;)
    --
    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/-/I07DoBUDI_gJ.
    To post to this group, send email to puppet...@googlegroups.com<javascript:>.
    To unsubscribe from this group, send email to
    puppet-users...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.
    --
    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/-/-HUe5ZaJeB4J.
    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.
  • Jakov Sosic at Dec 6, 2012 at 5:20 pm

    On 12/06/2012 05:51 PM, iamauser wrote:
    Hi,

    I had tried installing puppet-lint sometime ago, and tried this again as
    you wrote, but I get a bunch of buffer overflow (see below). I have
    reported an issue with rodjek's github and let's see if I get an answer.
    Any suggestion from this forum will certainly help.
    Are you using RHEL od RHEL derivative? If yes, I can provide you RPM.

    --
    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.
  • Iamauser at Dec 6, 2012 at 7:00 pm

    On Thursday, December 6, 2012 11:20:08 AM UTC-6, Jakov Sosic wrote:
    On 12/06/2012 05:51 PM, iamauser wrote:
    Hi,

    I had tried installing puppet-lint sometime ago, and tried this again as
    you wrote, but I get a bunch of buffer overflow (see below). I have
    reported an issue with rodjek's github and let's see if I get an answer.
    Any suggestion from this forum will certainly help.
    Are you using RHEL od RHEL derivative? If yes, I can provide you RPM.
    Yes, I am. That will be a lot helpful. Thanks a lot.




    --
    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/-/zBVtiSmWvHYJ.
    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.
  • Jakov Sosic at Dec 6, 2012 at 11:12 pm

    On 12/06/2012 08:00 PM, iamauser wrote:

    Are you using RHEL od RHEL derivative? If yes, I can provide you RPM.
    Yes, I am. That will be a lot helpful. Thanks a lot.
    http://ftp.srce.hr/srce-redhat/base/el6/x86_64/rubygem-puppet-lint-0.1.13-1.el6.srce.noarch.rpm



    --
    Jakov Sosic
    www.srce.unizg.hr

    --
    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.
  • Iamauser at Dec 6, 2012 at 11:20 pm
    Thanks, but we are still running EL5. Do you have rpm available for this ?


    On Thursday, December 6, 2012 5:12:33 PM UTC-6, Jakov Sosic wrote:
    On 12/06/2012 08:00 PM, iamauser wrote:

    Are you using RHEL od RHEL derivative? If yes, I can provide you RPM.
    Yes, I am. That will be a lot helpful. Thanks a lot.

    http://ftp.srce.hr/srce-redhat/base/el6/x86_64/rubygem-puppet-lint-0.1.13-1.el6.srce.noarch.rpm



    --
    Jakov Sosic
    www.srce.unizg.hr
    --
    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/-/iCGkEYWrghcJ.
    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.
  • Jakov Sosic at Dec 6, 2012 at 11:23 pm

    On 12/07/2012 12:20 AM, iamauser wrote:
    Thanks, but we are still running EL5. Do you have rpm available for this ?
    Yeah it's easy just replace el6 with el5 ;)

    http://ftp.srce.hr/srce-redhat/base/el5/x86_64/rubygem-puppet-lint-0.1.13-1.el5.srce.noarch.rpm


    Although I don't have all packages build for both versions (el5 & el6)
    and all architectures (x86_64 & i386), I sure try my best. When I get
    Koji up and working it should be easier to provide all the packages...

    --
    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.
  • Jakov Sosic at Dec 10, 2012 at 10:27 pm

    On 12/07/2012 12:23 AM, Jakov Sosic wrote:
    On 12/07/2012 12:20 AM, iamauser wrote:
    Thanks, but we are still running EL5. Do you have rpm available for
    this ?
    Yeah it's easy just replace el6 with el5 ;)

    http://ftp.srce.hr/srce-redhat/base/el5/x86_64/rubygem-puppet-lint-0.1.13-1.el5.srce.noarch.rpm



    Although I don't have all packages build for both versions (el5 & el6)
    and all architectures (x86_64 & i386), I sure try my best. When I get
    Koji up and working it should be easier to provide all the packages...

    OK, here are the new versions:

    el6:

    http://ftp.srce.hr/srce-redhat/base/el6/x86_64/rubygem-puppet-lint-0.3.2-1.el6.srce.noarch.rpm

    el5:

    http://ftp.srce.hr/srce-redhat/base/el5/x86_64/rubygem-puppet-lint-0.3.2-1.el5.srce.noarch.rpm


    Note: You also need rubygem-rcov & rubygem-rspec from EPEL

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedDec 4, '12 at 8:55p
activeDec 10, '12 at 10:27p
posts15
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase