FAQ
All-

I've been working through our local manifests with puppet-lint, trying
to make certain we're as prepared as possible for puppet 3.x. I would
like for our manifests to be warning-free. The class of warnings
related to long lines has me questioning what the best practice is to
avoid lines longer than 80 characters.

The two big offenders are URLs:

class foo {
yumrepo { 'some-repo':
baseurl => 'http://some-relatively-long-domain.com/some-path/centos$releasever/$basearch',
gpgcheck => '1',
descr => 'Some Yum Repository',
}
}

and obviously file resources:

class bar {
file {'/path/to/some/convenience/symlink':
ensure => file,
target => '/path/to/some/unfortunately/extremely/deep/file/that/we/want/to/manage/with/puppet',
}
}

but even "content" can at times exceed 80 columns.

I know I could be creating variables to help with line length, a la:

class foo {

$url_base = 'http://some-relatively-long-domain.com'
$url_path = '/some/url/path'

yumrepo { 'some-repo':
baseurl => "${base_url}${url_path}",
gpgcheck => '1',
descr => 'Some Yum Repository',
}
}

But that seems suboptimal, especially if there are things in the URL
(like $releasever/$basearch) that need to be preserved verbatim (they're
not puppet variables, they're for yum).

Is there a better way to break up long lines, perhaps a "join" function
I've missed that would allow me to do something like

class foo {
yumrepo { 'some-repo':
baseurl => join(
'',
'http://some-relatively-long-url.com',
'/some-path/centos$releasever/$basearch'
),
gpgcheck => '1',
descr => 'Some Yum Repository',
}
}

Thanks,

Tim
--
Tim Mooney Tim.Mooney@ndsu.edu
Enterprise Computing & Infrastructure 701-231-1076 (Voice)
Room 242-J6, IACC Building 701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

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

  • Nan Liu at May 21, 2012 at 7:13 pm

    On Mon, May 21, 2012 at 11:55 AM, Tim Mooney wrote:
    All-

    I've been working through our local manifests with puppet-lint, trying
    to make certain we're as prepared as possible for puppet 3.x.  I would
    like for our manifests to be warning-free.  The class of warnings
    related to long lines has me questioning what the best practice is to
    avoid lines longer than 80 characters.
    You can use a variable to shorten it, but I don't know if that
    actually improves code clarity.

    There's some discussion about removing it from the recommendation:
    https://github.com/puppetlabs/puppet-docs/pull/68

    Personally, I will not be sad if it gets dropped from docs and puppet-lint.

    Thanks,

    Nan

    --
    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.
  • Jo Rhett at May 22, 2012 at 10:07 am

    On May 21, 2012, at 12:13 PM, Nan Liu wrote:
    like for our manifests to be warning-free. The class of warnings
    related to long lines has me questioning what the best practice is to
    avoid lines longer than 80 characters.
    You can use a variable to shorten it, but I don't know if that
    actually improves code clarity.

    Ah, see, it's Very Important that code written today be easy to read and review on CRT terminals that nobody actually uses any more. No valid or logical reasoning need apply.

    * Personally, I reject any code commits where someone has broken up a perfectly legible line of code into multiple confusing lines of code avoid hitting some arbitrary limit.

    --
    Jo Rhett
    Net Consonance : net philanthropy to improve open source and internet projects.



    --
    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.
  • Tim Mooney at May 24, 2012 at 5:02 pm

    In regard to: Re: [Puppet Users] linting manifests with long lines, Nan Liu...:
    On Mon, May 21, 2012 at 11:55 AM, Tim Mooney wrote:

    All-

    I've been working through our local manifests with puppet-lint, trying
    to make certain we're as prepared as possible for puppet 3.x. I would
    like for our manifests to be warning-free. The class of warnings
    related to long lines has me questioning what the best practice is to
    avoid lines longer than 80 characters.
    You can use a variable to shorten it, but I don't know if that
    actually improves code clarity.
    As I suggested in my original email, in some cases it would be OK, but
    in many cases it wouldn't improve clarity and would cause other problems.
    There's some discussion about removing it from the recommendation:
    https://github.com/puppetlabs/puppet-docs/pull/68
    Thanks for pointing that out.

    What I've ended up doing is just adding

    --no-80chars-check

    to my ~/.puppet-lintrc, to silence the warning.

    Tim
    --
    Tim Mooney Tim.Mooney@ndsu.edu
    Enterprise Computing & Infrastructure 701-231-1076 (Voice)
    Room 242-J6, IACC Building 701-231-8541 (Fax)
    North Dakota State University, Fargo, ND 58105-5164

    --
    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
postedMay 21, '12 at 6:56p
activeMay 24, '12 at 5:02p
posts4
users3
websitepuppetlabs.com

3 users in discussion

Tim Mooney: 2 posts Nan Liu: 1 post Jo Rhett: 1 post

People

Translate

site design / logo © 2022 Grokbase