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

    Dr Bunsen Honeydew

    06/02/2022, 8:45 PM
    the more you know 🧑‍🏫PE Console is about to start up in #CFD8Z9A4T
  • m

    Mike Renfro

    06/03/2022, 2:01 AM
    Given a
    $vhosts
    hash we use to create Apache VirtualHosts, I’m trying to extract all the
    servername
    values to make a list of SANs for a host-wide SSL key. Testing with printing out the
    servername
    values:
    Copy code
    $vhosts.map |String $key, Hash $vhost| {
      notify { "$key":
        message => $vhost['servername']
      }
    }
    prints one message per vhost entry with the defined
    servername
    value, no problem:
    Copy code
    Notice: <http://phpappst1.tntech.edu|phpappst1.tntech.edu>
    Notice: /Stage[main]/Profile::Apache/Notify[phpapps]/message: defined 'message' as '<http://phpappst1.tntech.edu|phpappst1.tntech.edu>'
    Notice: <http://phpappst1.tntech.edu|phpappst1.tntech.edu>
    Notice: /Stage[main]/Profile::Apache/Notify[phpapps-ssl]/message: defined 'message' as '<http://phpappst1.tntech.edu|phpappst1.tntech.edu>'
    Notice: <http://ttupaapp-test.tntech.edu|ttupaapp-test.tntech.edu>
    Notice: /Stage[main]/Profile::Apache/Notify[ttupaapp]/message: defined 'message' as '<http://ttupaapp-test.tntech.edu|ttupaapp-test.tntech.edu>'
    ...
    But trying to convert that into an array of names:
    Copy code
    $servernames = $vhosts.map |String $key, Hash $vhost| {
        $vhost['servername']
    }
    notify { "servernames":
      message => $servernames
    }
    appears to only return the first value:
    Copy code
    Notice: <http://phpappst1.tntech.edu|phpappst1.tntech.edu>
    Notice: /Stage[main]/Profile::Apache/Notify[servernames]/message: defined 'message' as '<http://phpappst1.tntech.edu|phpappst1.tntech.edu>'
    Where can I narrow this down? Puppet 6.27 if that makes any difference.
  • h

    helindbe

    06/03/2022, 8:27 AM
    The Notify resource type only outputs the first value of a given array. You need to build the string yourself. You can use the
    join()
    function to join the names with commas for example.
  • h

    helindbe

    06/03/2022, 8:28 AM
    Copy code
    puppet apply -e 'notify {blah: message => [a, b, c].join(", ")}'
    Notice: Compiled catalog for localhost in environment production in 0.03 seconds
    Notice: a, b, c
    Notice: /Stage[main]/Main/Notify[blah]/message: defined 'message' as 'a, b, c'
    Notice: Applied catalog in 0.01 seconds
  • b

    bastelfreak

    06/03/2022, 8:36 AM
    that's why I often embed the array into a string:
    Copy code
    $ary = ['1', 2, 'bla']
    notify { 'foo':
      message => "${ary}",
    }
    Copy code
    Notice: [1, 2, bla]
    Notice: /Stage[main]/Main/Notify[foo]/message: defined 'message' as '[1, 2, bla]'
    Notice: Applied catalog in 0.01 seconds
  • m

    Mike Renfro

    06/03/2022, 10:32 AM
    Thanks. Makes sense in retrospect.
  • s

    Slackbot

    06/03/2022, 3:16 PM
    This message was deleted.
    c
    a
    • 3
    • 7
  • c

    csharpsteen

    06/03/2022, 3:29 PM
    lookup('<lookup value>', Hash)
    is a lookup that returns the first value found, instead of all possible values, and fails if that value is not a
    Hash
    type.
  • c

    csharpsteen

    06/03/2022, 3:29 PM
    lookup('<lookup value>', Hash)
    is a lookup that returns the first value found, instead of merging all possible values, and fails if that value is not a
    Hash
    type.
  • s

    Slackbot

    06/03/2022, 4:11 PM
    This message was deleted.
    h
    l
    r
    • 4
    • 5
  • r

    rajeshr

    06/03/2022, 4:12 PM
    i have a question related to the
    host
    resource. every time the agent runs, it updates the timestamp inside the
    /etc/hosts
    file:
    HEADER: This file was autogenerated at *2022-06-03 11:06:26 -0400*
    Is there a way to stop the timestamp being updated inside the
    /etc/hosts
    file every time the agent runs or use something other that the
    host
    resource?
  • s

    Slackbot

    06/03/2022, 7:00 PM
    This message was deleted.
    m
    h
    j
    • 4
    • 25
  • s

    Slackbot

    06/03/2022, 7:31 PM
    This message was deleted.
    t
    j
    • 3
    • 3
  • j

    Jason Grammenos

    06/03/2022, 7:31 PM
    i wish services had a
    reload
    parameter in addition to the restart one, would potential make it way cleaner
  • t

    thedonkdonk

    06/03/2022, 7:32 PM
    This works
    Copy code
    minute  => [13,28,43,58]
  • j

    Jason Grammenos

    06/03/2022, 7:32 PM
    ah, i think you put an array in an array
  • j

    Jason Grammenos

    06/03/2022, 7:33 PM
    hmm no, nm.
  • j

    Jason Grammenos

    06/03/2022, 7:33 PM
    i would double check the value of $minutes via a notify
  • s

    Slackbot

    06/03/2022, 9:51 PM
    This message was deleted.
    m
    c
    • 3
    • 5
  • m

    Mike Renfro

    06/03/2022, 10:10 PM
    The README for zypprepo isn’t great, so you may want to refer to https://github.com/voxpupuli/puppet-zypprepo/blob/master/lib/puppet/type/zypprepo.rb for what the parameters control.
  • m

    Massimiliano (Max)

    06/05/2022, 5:35 PM
    message has been deleted
  • m

    matt

    06/06/2022, 8:14 AM
    I'm doing an if statement against a version string, I want to do if equal or greater the version string has points in it - will the greater than respect the points eg: understand that 1.9.11 is less than 1.9.12, or 1.10.1 and how do I correctly 'quote' the string, as I don't want it to be literal,
  • m

    matt

    06/06/2022, 8:15 AM
    eg: currently looks like if $::sw_version >= 1.9.11 {
  • m

    matt

    06/06/2022, 8:15 AM
    I know that's wrong though
  • g

    glee

    06/06/2022, 8:25 AM
    Check
    versioncmp
    function - https://puppet.com/docs/puppet/6/function.html#versioncmp, so for your example:
    Copy code
    if versioncmp($::sw_version, '1.9.11') >= 0) {
       [...do stuff here...]
    }
    would do stuff if version was 1.9.11 or greater
  • m

    matt

    06/06/2022, 8:26 AM
    ooooh
  • m

    matt

    06/06/2022, 8:26 AM
    that's a different way. thank you
  • m

    matt

    06/06/2022, 8:26 AM
    having a look at that function now
    👍 1
  • g

    glee

    06/06/2022, 8:27 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:28 AM
    that's much better way, evaluating the return value based on the versioncmp test
1...565758...428Latest