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

    natemccurdy

    08/04/2022, 9:46 PM
    The
    type()
    function: https://puppet.com/docs/puppet/7/function.html#type e.g.
    Copy code
    $foo = ["bar"]
    notify { 'what is it':
      message => "foo is a ${type($foo)}",
    }
    ❤️ 1
  • p

    Patrick Rynhart

    08/04/2022, 9:47 PM
    Sorry for the simple question - thank you for the help
  • n

    natemccurdy

    08/04/2022, 9:47 PM
    The
    type()
    function: https://puppet.com/docs/puppet/7/function.html#type e.g.
    Copy code
    $foo = ["bar"]
    notify { 'what is it':
      message => "foo is a ${type($foo)}",
    }
  • p

    Patrick Rynhart

    08/04/2022, 9:54 PM
    Hmmm - Not sure if that helps too much, I’m guessing this must be an array of Hashes ?
  • p

    Patrick Rynhart

    08/04/2022, 9:55 PM
    Copy code
    Notice: The dumped variable is Struct[{'developmentb' => Struct[{'someattribute' => String, 'anotherattribute' => String}], 'developmentc' => Struct[{'someattribute' => String, 'anotherattribute' => String}]}]
  • n

    natemccurdy

    08/04/2022, 9:55 PM
    It’s a hash of hashes.
    ✅ 1
  • n

    natemccurdy

    08/04/2022, 9:56 PM
    Try
    message => "The dumped variable is ${type($foo, 'generalized')}",
    🙌 1
  • p

    Patrick Rynhart

    08/04/2022, 10:02 PM
    Great - that’s a bit more human readable for me 🙂
  • j

    Joost

    08/04/2022, 10:04 PM
    message has been deleted
  • k

    kenyon

    08/04/2022, 10:23 PM
    docker image seems kind of pointless, when you can just
    gem install r10k
    , or better, use the puppet-r10k module to install it
  • b

    Brian Schonecker

    08/04/2022, 10:27 PM
    I had to use a fork of the abrader-gms module to get R10k to work properly on RHEL7/RHEL8. The merge request has been pending for quite a long time.
    mod 'abrader-gms',
    :git => '<https://github.com/bjvrielink/abrader-gms.git>',
    :ref => 'fixup'
  • b

    Brian Schonecker

    08/04/2022, 10:27 PM
    I had to use a fork of the abrader-gms module to get R10k to work properly on RHEL7/RHEL8. The merge request has been pending for quite a long time.
    mod 'abrader-gms',
    :git => '<https://github.com/bjvrielink/abrader-gms.git>',
    :ref => 'fixup'
  • p

    Patrick Rynhart

    08/04/2022, 10:31 PM
    In my case, I’m wanting an array of hashes, so I think the correct way for me to define this in Hiera is:
  • p

    Patrick Rynhart

    08/04/2022, 10:31 PM
    Copy code
    profile::stream_web::config:
      muc:
        - 'developmentb':
           someattribute: 'here'
           anotherattribute: 'here'
        - 'developmentc':
           someattribute: 'here'
           anotherattribute: 'here'
  • n

    natemccurdy

    08/04/2022, 10:32 PM
    Incorrect. That’s a hash which contains one key which contains an array of hashes.
  • n

    natemccurdy

    08/04/2022, 10:32 PM
    $profile::stream_web::config
    would be a hash, to clarify.
  • n

    natemccurdy

    08/04/2022, 10:33 PM
    $profile::stream_web::config
    would be a hash, to clarify.
  • p

    Patrick Rynhart

    08/04/2022, 10:33 PM
    Ah sorry - at the top of my manifest I’m doing this:
  • p

    Patrick Rynhart

    08/04/2022, 10:33 PM
    $muc = $config[‘muc’]
  • n

    natemccurdy

    08/04/2022, 10:33 PM
    Ah, gotcha. Then yeah,
    $muc
    is an array of hashes.
  • p

    Patrick Rynhart

    08/04/2022, 10:33 PM
    When attempting to iterate via this:
  • p

    Patrick Rynhart

    08/04/2022, 10:33 PM
    each ($muc) |$value| { $d1 = $value[‘someattribute’] notify{“$d1”:} }
  • p

    Patrick Rynhart

    08/04/2022, 10:34 PM
    I’m getting “Empty string title at 0. Title strings must have a length greater than zero.”
  • n

    natemccurdy

    08/04/2022, 10:35 PM
    You indentation is wrong in the YAML, so it’s throwing off the data type. Try:
    Copy code
    profile::stream_web::config:
      muc:
        - developmentb:
            someattribute: 'here'
            anotherattribute: 'here'
        - developmentc:
            someattribute: 'here'
            anotherattribute: 'here'
  • s

    Slackbot

    08/04/2022, 10:38 PM
    This message was deleted.
    Untitled.pp
    ✅ 1
    v
    n
    • 3
    • 2
  • p

    Patrick Rynhart

    08/04/2022, 10:43 PM
    Yeah - unfortunately get a Duplicate declaration: Notify[d1]
  • p

    Patrick Rynhart

    08/04/2022, 10:44 PM
    Have changed to this, but am unfortunately still getting $d1 empty with this code:
  • p

    Patrick Rynhart

    08/04/2022, 10:44 PM
    Copy code
    class profile::stream_web (
      $config = [],
    ) {
    
      $muc = $config['muc']
      $muc.each |Hash $value| {
        $d1 = $value['someattribute']
        notify { "$d1": }
      }
  • p

    Patrick Rynhart

    08/04/2022, 10:46 PM
    If I just dump out $value instead like this:
  • p

    Patrick Rynhart

    08/04/2022, 10:46 PM
    Copy code
    class profile::stream_web (
      $config = [],
    ) {
    
      $muc = $config['muc']
      $muc.each |Hash $value| {
        notify {"$value":}
        #$d1 = $value['someattribute']
        #notify { "$d1": }
      }
1...121122123...428Latest