https://www.puppet.com/community logo
Join Slack
Powered by
# puppet
  • m

    matt

    06/06/2022, 8:28 AM
    the price of inexperience
  • m

    matt

    06/06/2022, 8:28 AM
    thank you
    👍 1
  • g

    glee

    06/06/2022, 8:30 AM
    the function is useful for comparing versions in the format you've mentioned - otherwise you'd have to split the version string into components to check 1.9.12 < 1.10.1 etc (if you just did >= on the strings directly from memory that's a string comparison, which most of the time isn't what you want)
  • m

    matt

    06/06/2022, 8:34 AM
    that works much better already, thank you for correcting the approach, rather than just answering the question
    🙂 1
  • m

    matt

    06/06/2022, 9:04 AM
    could someone validate this for me please, I've just made a simple change to an existing module to put in a version check so version check and then 'elseif' if the condition is not met, looks good to me https://gist.github.com/ikonia/15f9c15ac554a1e23d64461fa570c03f - however the parser complains "Error: Could not parse for environment production: Syntax error at '}' (file: /home/mattd/git/puppet-consul/manifests/params.pp, line: 32, column: 5)" line 32 is the final closing brace - which I don't see why it's a problem as it closes the elseif
  • g

    glee

    06/06/2022, 9:18 AM
    It should be
    elsif
    , plus the comparison operator should be
    ==
    not
    =
    ie:
    } elsif versioncmp ($::version, '1.9.11') == -1
  • m

    matt

    06/06/2022, 9:26 AM
    great spot, I'd not seen the else typo
  • m

    matt

    06/06/2022, 9:26 AM
    I did just spot the == though as I posted, thank you
  • m

    matt

    06/06/2022, 9:26 AM
    thought the validator would have been more helpful
  • m

    matt

    06/06/2022, 9:27 AM
    that fixed it, thank you
  • s

    Slackbot

    06/06/2022, 10:35 AM
    This message was deleted.
    c
    s
    • 3
    • 3
  • s

    Stefan Hristovski

    06/06/2022, 10:35 AM
    My question is, will the command creates => find the newly created command and not repeat it ? I would like it to run only once when typing the command
  • s

    Stefan Hristovski

    06/06/2022, 10:36 AM
    the "brand.txt" is a long command code put into one doc
  • c

    chadh

    06/06/2022, 12:06 PM
    The way the
    creates
    parameter works is that puppet checks for the existence of the argument of that parameter before running the command. If that file exists, nothing happens. So the expectation is that the command “creates” the file, and thus the existence of the file means that the command has already run and does not need to be run again. In your example it appears that the file you are specifying to
    creates
    has to already exist since it is referenced in the command. So what you have won’t work.
  • v

    vchepkov

    06/06/2022, 12:09 PM
    whampi1 command should be accessible via path. so either provide full path to the command or fix path argument, so it has the directory in it, which has that command
  • v

    vchepkov

    06/06/2022, 12:10 PM
    think of it as setting PATH variable
  • s

    Slackbot

    06/06/2022, 2:14 PM
    This message was deleted.
    s
    • 2
    • 1
  • m

    Micah

    06/06/2022, 2:16 PM
    do I need to explicitly say this is running with a shell?
  • v

    vchepkov

    06/06/2022, 2:16 PM
    I would change it an use a fact
    👍🏼 1
  • v

    vchepkov

    06/06/2022, 2:17 PM
    Copy code
    unless $facts['Timezone'] == 'UTC' {
  • m

    Micah

    06/06/2022, 2:17 PM
    there already is a Timezone fact?
  • v

    vchepkov

    06/06/2022, 2:17 PM
    I think so
  • y

    Yorokobi

    06/06/2022, 2:18 PM
    It is all lowercase
  • m

    Micah

    06/06/2022, 2:18 PM
    indeed there is
  • m

    Micah

    06/06/2022, 2:19 PM
    but I can put that into an exec like this?
    Copy code
    exec { 'set UTC time':
        command => '/usr/bin/timedatectl set-timezone UTC',
        unless  => $facts['timezone'] == 'UTC'
      }
  • v

    vchepkov

    06/06/2022, 2:20 PM
    nope
  • v

    vchepkov

    06/06/2022, 2:21 PM
    this would work too
  • v

    vchepkov

    06/06/2022, 2:21 PM
    Copy code
    file { '/etc/localtime':
                ensure => link,
                target => "/usr/share/zoneinfo/${timezone}",
              }
  • m

    Micah

    06/06/2022, 2:21 PM
    unfortunately, that doesn't work across OS releases
  • v

    vchepkov

    06/06/2022, 2:22 PM
    timedatectl either 🙂
1...575859...428Latest