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

    vchepkov

    07/26/2022, 4:39 PM
    that's a string, it will mean true
  • y

    Yorokobi

    07/26/2022, 4:39 PM
    var: null
    is valid YAML for null/nil
  • y

    Yorokobi

    07/26/2022, 4:39 PM
    The same as
    var:
    or
    var: ~
  • n

    natemccurdy

    07/26/2022, 4:40 PM
    How are you pulling that data from Hiera? “if $var is defined in Hiera” doesn’t really mean much until that data is pulled into Puppet.
  • s

    spin

    07/26/2022, 4:41 PM
    APL, so my_class::var
  • y

    Yorokobi

    07/26/2022, 4:42 PM
    What does
    puppet lookup my_class::var
    say about it?
  • n

    natemccurdy

    07/26/2022, 4:42 PM
    Try changing to
    ~
    instead of
    null
    . I recall hitting something where
    null
    was being cast to a string, butI can’t remember if that was just in spec tests or in real Puppet runs.
  • n

    natemccurdy

    07/26/2022, 4:42 PM
    Try changing to
    ~
    instead of
    null
    . I recall hitting something where
    null
    was being cast to a string, butI can’t remember if that was just in spec tests or in real Puppet runs.
  • y

    Yorokobi

    07/26/2022, 4:45 PM
    Puppet 7 treats
    var: null
    as null (not a string) ... ¯\_(ツ)_/¯
  • s

    spin

    07/26/2022, 4:48 PM
    found the key right where expected value: nil
  • n

    natemccurdy

    07/26/2022, 4:50 PM
    What does the parameter definition look like? Also, maybe trying `notify`’ing the variable just as a quick sanity check of what it is.
  • b

    bastelfreak

    07/26/2022, 4:51 PM
    should puppet lookup find the value when its undef? I thought it says "didnt find value X"
  • s

    spin

    07/26/2022, 4:51 PM
    so seems it is evaluating the hiera yaml as documented but the conditional is treating nil as true on an if... should i convert to bool..
  • g

    Greg Bristol

    07/26/2022, 4:51 PM
    null values that are converted to strings get converted as
    ''
    which is true iirc
  • g

    Greg Bristol

    07/26/2022, 4:51 PM
    or i guess more accurately
    undef
    values
  • n

    natemccurdy

    07/26/2022, 4:58 PM
    Is there a default value or something that’s getting pulled in? I just did a test, and on both puppet 6.17.0 and 7.17.0, both
    ~
    and
    null
    are correctly pulled in as
    undef
    via APL.
  • n

    natemccurdy

    07/26/2022, 5:01 PM
    Copy code
    # test/manifests/init.pp
    class test (
      $param1,
      $param2,
    ) {
      notify { 'param1':
        message => "type: ${type($param1)}: ${param1}",
      }
      notify { 'param2':
        message => "type: ${type($param2)}: ${param2}",
      }
    }
    Copy code
    ---
    # common.yaml
    test::param1: ~
    test::param2: null
    Puppet 6.17.0 and 7.17.0 both produce this:
    Copy code
    Notice: type: Undef:
    Notice: /Stage[main]/Test/Notify[param1]/message: defined 'message' as 'type: Undef: '
    Notice: type: Undef:
    Notice: /Stage[main]/Test/Notify[param2]/message: defined 'message' as 'type: Undef: '
  • d

    Dr Bunsen Honeydew

    07/26/2022, 5:01 PM
    ```- took a hit! Ouch. (Karma: -71)
  • n

    natemccurdy

    07/26/2022, 5:07 PM
    @spin Check for a default value in the parameter’s definition, and also make sure you’re not quoting the variable in the
    if
    conditional.
  • s

    spin

    07/26/2022, 5:13 PM
    so yea did essentially the same test as you and got the same result.. in an if the code doesnt execute the if on a null/nil value. validated with lookup cli and code review the only value defined is null.. going to take another look at debug output as to why it looks to be executing the wrong code block..
  • s

    spin

    07/26/2022, 5:14 PM
    thanks for everyones input, will report back once i nail down.. whats going wrong
  • s

    spin

    07/26/2022, 5:35 PM
    bah it was a pick i spaced on adding a couple weeks ago in control repo... pick($_package_url, null),
    🍻 1
  • s

    Slackbot

    07/26/2022, 5:46 PM
    This message was deleted.
    c
    • 2
    • 2
  • d

    Dr Bunsen Honeydew

    07/26/2022, 5:46 PM
    See the
    puppetlabs-firewall
    module at https://forge.puppet.com/puppetlabs/firewall?src=slack&channel=puppet
  • c

    Corporate Gadfly

    07/26/2022, 5:47 PM
    To make
    puppetlabs-firewall
    useful on SLES 15, I had to make the following changes: • added code to persist firewall rules, when they change, pseudo-code as follows:
    Copy code
    Firewall {
      notify => Exec['persist-firewall-rules'],
    }
    • disable
    firewalld
    in
    systemd
    • added
    systemd
    service for
    iptables
    ◦ stop will flush the
    iptables
    rules ◦ start will load the
    iptables
    rules from the persisted location
  • c

    Corporate Gadfly

    07/26/2022, 5:50 PM
    I've created https://github.com/puppetlabs/puppetlabs-firewall/pull/1061 This will allow me to remove the firewall persistence code, which is peppered all over the code base (essentially in any class which has a firewall rule applicable on the Suse platform). Any eyes on the pull request or feedback/comments are welcome.
  • c

    Corporate Gadfly

    07/26/2022, 5:50 PM
    I've created https://github.com/puppetlabs/puppetlabs-firewall/pull/1061 This will allow me to remove the firewall persistence code, which is peppered all over the code base (essentially in any class which has a firewall rule applicable on the Suse platform). Any eyes on the pull request or feedback/comments are welcome.
  • s

    spin

    07/26/2022, 6:28 PM
    so i am not loving the solution i came up with to touch 4 or 5 modules and change data type from optional String to variant string,undef, boolean.. and i dont get why this is necessary... if you have a module that has hiera default of null for an optional param. why wouldnt specifying $var => null when declaring the class be exactly the same
  • s

    smortex

    07/26/2022, 6:29 PM
    You mean
    ~
    in common.yaml? Looks like a smell: better default to
    undef
    in the manifest.
  • s

    spin

    07/26/2022, 6:30 PM
    well i want to define all defaults in module hiera and learned that i need null in hiera.. which then parses to undef in puppet
1...106107108...428Latest