bastelfreak
01/09/2023, 10:08 PMrismoney
01/09/2023, 11:36 PMnatemccurdy
01/09/2023, 11:42 PMrismoney
01/09/2023, 11:43 PMrismoney
01/09/2023, 11:44 PMnatemccurdy
01/09/2023, 11:45 PM$stuff = ['host/hostabc','wsman/hostabc','termsrv/hostabc','host/bogus','host/fugazi']
$not_hostabc = $stuff.filter |String[1] $thing| {
$thing !~ /\/hostabc$/
}
notice($not_hostabc)natemccurdy
01/09/2023, 11:45 PM$ 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 secondsnatemccurdy
01/09/2023, 11:46 PMfilter() and a regex.rismoney
01/09/2023, 11:46 PMrismoney
01/09/2023, 11:48 PMrismoney
01/09/2023, 11:54 PMRegexp("${myvar}") ?Slackbot
01/09/2023, 11:59 PMnatemccurdy
01/09/2023, 11:59 PM/ and $ in the regex to anchor the start and end of it.
Like this:
$not_this = 'hostabc'
$stuff_that_is_not_this = $stuff.filter |String[1] $thing| {
$thing !~ Regexp("/${not_this}$")
}rismoney
01/09/2023, 11:59 PMrismoney
01/10/2023, 12:00 AMSlackbot
01/10/2023, 9:59 AMNeeloj
01/10/2023, 10:43 AMexec { '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 {} \;",
}Slackbot
01/10/2023, 12:22 PMralfbosz
01/10/2023, 12:25 PMBrian Schonecker
01/10/2023, 1:23 PMBrian Schonecker
01/10/2023, 1:24 PMBrian Schonecker
01/10/2023, 1:25 PMDr Bunsen Honeydew
01/10/2023, 1:25 PMghoneycutt-pam module at https://forge.puppet.com/ghoneycutt/pam?src=slack&channel=puppetvchepkov
01/10/2023, 2:22 PMnatemccurdy
01/10/2023, 2:26 PM/ 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.Dr Bunsen Honeydew
01/10/2023, 2:45 PMDr Bunsen Honeydew
01/10/2023, 3:45 PMSlackbot
01/10/2023, 5:51 PMJoel Wilson
01/10/2023, 6:50 PMnatemccurdy
01/10/2023, 6:51 PM