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

    bastelfreak

    01/09/2023, 10:08 PM
    always
  • r

    rismoney

    01/09/2023, 11:36 PM
    I have an array of items, all of which contain say hostabc and some bogus/fugazzi stuff. array = ['host/hostabc','wsman/hostabc','termsrv/hostabc',host/bogus','host/fugazzi'] Is there an easy way to return only the items that are NOT hostabc ?
  • n

    natemccurdy

    01/09/2023, 11:42 PM
    So in this case, just "host/bogus" and "host/fugazi"?
  • r

    rismoney

    01/09/2023, 11:43 PM
    exactly, but i don't know its bogus or fugazi. its just no hostabc.
  • r

    rismoney

    01/09/2023, 11:44 PM
    maybe lamba filter expression of sort? i can't recall how i did it for the life of me.
  • n

    natemccurdy

    01/09/2023, 11:45 PM
    Copy code
    $stuff = ['host/hostabc','wsman/hostabc','termsrv/hostabc','host/bogus','host/fugazi']
    
    $not_hostabc = $stuff.filter |String[1] $thing| {
      $thing !~ /\/hostabc$/
    }
    
    notice($not_hostabc)
  • n

    natemccurdy

    01/09/2023, 11:45 PM
    Copy code
    $ puppet apply foo.pp
    Notice: Scope(Class[main]): [host/bogus, host/fugazi]
    Notice: Compiled catalog for my.computer in environment production in 0.02 seconds
    Notice: Applied catalog in 0.01 seconds
  • n

    natemccurdy

    01/09/2023, 11:46 PM
    I'd do it using
    filter()
    and a regex.
  • r

    rismoney

    01/09/2023, 11:46 PM
    thats exactly what i needed
    🍻 1
  • r

    rismoney

    01/09/2023, 11:48 PM
    thank you for that super fast response.
  • r

    rismoney

    01/09/2023, 11:54 PM
    one more slight addtl question - if hostabc regex were myvar, would I need to use
    Copy code
    Regexp("${myvar}") ?
  • s

    Slackbot

    01/09/2023, 11:59 PM
    This message was deleted.
    c
    n
    • 3
    • 3
  • n

    natemccurdy

    01/09/2023, 11:59 PM
    Close. That'd work, but it's not as specific of a regex as my first example, so you'd get false positives. You'll want to keep the
    /
    and
    $
    in the regex to anchor the start and end of it. Like this:
    Copy code
    $not_this = 'hostabc'
    
    $stuff_that_is_not_this = $stuff.filter |String[1] $thing| {
      $thing !~ Regexp("/${not_this}$")
    }
  • r

    rismoney

    01/09/2023, 11:59 PM
    yep, was just about to type this.
  • r

    rismoney

    01/10/2023, 12:00 AM
    ty!
  • s

    Slackbot

    01/10/2023, 9:59 AM
    This message was deleted.
    v
    n
    n
    • 4
    • 6
  • n

    Neeloj

    01/10/2023, 10:43 AM
    hi all, find files in dummy folder and set permission to 755, it works so far, if there a way to do it better, I mean onlyif is not so nice! I want run exec only if there a files that are not excutable. thank you all
    Copy code
    exec { 'set permissions to 755':
                    path => '/bin:/sbin:/usr/bin:/usr/sbin',
                    command => 'find /usr/lib/dummy/ -type f -exec chmod 755 {} \;',
                    onlyif => "find /usr/lib/dummy/ -type f -exec  sh -c  'if [ -x {} ]; then echo 0; else echo 1; fi' sh {} \;",
            }
  • s

    Slackbot

    01/10/2023, 12:22 PM
    This message was deleted.
    t
    • 2
    • 1
  • r

    ralfbosz

    01/10/2023, 12:25 PM
    I think you need to upgrade to Puppet 6 for Ubuntu 20.04 support.
  • b

    Brian Schonecker

    01/10/2023, 1:23 PM
    Looking for advice on managing authselect on RHEL. I'm not finding much on the forge regarding authselect and I'd like something compatible with authconfig if possible.
  • b

    Brian Schonecker

    01/10/2023, 1:24 PM
    I have a feeling I'm going down a rabbit hole as this will [probably] affect PAM.d stuff as well.
  • b

    Brian Schonecker

    01/10/2023, 1:25 PM
    I'm testing ghoneycutt-pam but I don't know how/if it will fit in with authselect.
  • d

    Dr Bunsen Honeydew

    01/10/2023, 1:25 PM
    See the
    ghoneycutt-pam
    module at https://forge.puppet.com/ghoneycutt/pam?src=slack&channel=puppet
  • v

    vchepkov

    01/10/2023, 2:22 PM
    This is not something puppet should do, really. create a script and schedule it via systemd timer, that part can be in puppet
  • n

    natemccurdy

    01/10/2023, 2:26 PM
    Puppet doesn't use
    /
    to mean start of a line, if that's what you mean. It uses standard regex and the usual
    ^
    . I referred to that as an anchor in this case specifically because the substring I was trying to filter by was
    /hostabc
    . I was "anchoring" the search pattern at the start with a literal forward slash character, not the start of a line.
  • d

    Dr Bunsen Honeydew

    01/10/2023, 2:45 PM
    indeed 🧑‍🏫 Bolt is about to start up in #CFD8Z9A4T
  • d

    Dr Bunsen Honeydew

    01/10/2023, 3:45 PM
    the more you know _🦊Vox Pupuli monthly sync; see calendar event for info_ is about to start up in #CFD8Z9A4T
  • s

    Slackbot

    01/10/2023, 5:51 PM
    This message was deleted.
    c
    w
    • 3
    • 5
  • j

    Joel Wilson

    01/10/2023, 6:50 PM
    Is there a way to test for the presence of a class elsewhere in the catalog to make a decision?
  • n

    natemccurdy

    01/10/2023, 6:51 PM
    Do you want to check if that class exists and could be declared, or that it has already been declared?
1...263264265...428Latest