[10:16:17] puppet question: I have an array of Stdlib::Host which is actually a variant of hostname and ip address, when using said array in a template I need to check whether I have an hostname or an address and change the apache config (require ip vs require host) accordingly, what's the prescribed way to do that ? [10:17:02] "go cry in a corner, and rethink your life" [10:17:32] * godog chuckles [10:18:26] <_joe_> godog: you can check the specific data type of a variable [10:19:46] <_joe_> so something like $myarray.each |$element| { if is_a($element, Stdlib::Ipaddress) {... } else {...} } [10:20:07] <_joe_> I don't remember if there is a better way in puppet 5.x to check for the type of a variable [10:20:21] <_joe_> is_a is part of stdlib [10:20:57] _joe_: thank you, I'll try that [10:20:58] <_joe_> I think you can do if $element =~ Stdlib::Ipaddress [10:21:06] <_joe_> lemme test that [10:21:20] nerdsnipe achievement unlocked [10:23:36] heheh I'm going for is_a for now but good to know =~ might work [10:23:38] <_joe_> $ puppet apply --modulepath modules -e '$a = "192.168.1.1"; notice($a =~ Stdlib::IP::Address)' returns true [10:23:45] <_joe_> godog: it works [10:24:04] <_joe_> is_a was needed in 4.x but now the language should do it natively [10:25:31] I'm looking to do this in a erb template ATM though [10:29:02] kormat: I'm at the 'acceptance' stage of grief with puppet btw, as evidenced by the session yesterday, took a while but I think I got there [10:29:44] 🥀 [10:30:34] hahaha! [10:30:52] would an ipv6 address work with IP::Address? [10:31:47] jynus: "Matches any IP address, including both IPv4 and IPv6 addresses." [10:31:56] thanks, kormat [10:32:25] there's Stdlib::IP::Address::V4 and Stdlib::IP::Address::V6 for being more specific [10:36:45] unsurprisingly the obvious thing of <% if h.is_a?(Stdlib::Fqdn) -%> fails tragically with Detail: uninitialized constant Puppet::Parser::TemplateWrapper::Stdlib [10:37:52] I'll do the matching from the manifest instead [10:49:23] I was reading rfc952 but later rfc1123 says a dns can start with a number? So 1.1.1.1 would be a valid dns name? [10:51:48] ah, no, it clarifies later: ""since at least the highest-level component label will be alphabetic." [11:13:13] <_joe_> godog: yeah you'd need to properly call the puppet stdlib function [11:14:08] <_joe_> if scope.function_is_a([h, 'Stdlib::Fqdn']) or something [11:16:16] yeah I opted for the manifest because other examples of is_a? in templates work fine with e.g. foo.is_a?(Hash) [11:16:35] maybe the difference is the :: ? no idea but didn't want to find out [11:21:07] <_joe_> no the difference is that Object.is_a? is a ruby language function [11:21:15] <_joe_> in your case you'd need to do [11:21:46] <_joe_> $el = '192.168.1.1'; $t = Stdlib::IP::Address; and then in the template [11:22:10] <_joe_> scope.call_function('is_a', [@el, @t]) [11:22:27] when getting lost in the relevant standards, keep in mind that the rules for a "dns name" and a "hostname" are distinct. the space of legal "dns name" that can be a lookup key in the DNS is much looser, while the requirements for a "hostname" in the *nix sense are more-restrictive. Not all dns names that you could look up the address of are legitimate "hostnames". [11:23:24] (you can even put binary bytes in DNS labels and it works in the protocol, although user-facing tooling may make it difficult to work with them) [11:23:31] _joe_: we're already using "bare" is_a? in templates, how's that different? modules/profile/templates/idp/client/httpd-icinga.erb: <%- if setting.is_a?(Array) -%> [11:23:47] <_joe_> godog: that's all ruby [11:23:54] <_joe_> Array is a ruby class [11:24:24] <_joe_> https://ruby-doc.org/core-2.7.0/Array.html [11:24:39] <_joe_> and in ruby "is_a?" is a special reflection method [11:26:16] ah ok, so yeah definitely better to operate in the manifest instead [11:26:33] and conversely, do as few as possible in templates (?) [11:27:09] s/few/little/ [11:29:26] <_joe_> I prefer that approach, yes [11:43:42] godog: for the record this is how i have done it in pure ruby https://github.com/wikimedia/puppet/blob/production/modules/puppetmaster/templates/web-frontend.conf.erb#L3 [11:44:47] and an in manefest example here https://github.com/wikimedia/puppet/blob/production/modules/cfssl/manifests/cert.pp#L81-L89 [11:48:01] jbond42: thank you for the pointer! [11:48:45] the ? matching with types is interesting [12:09:36] headsup: we'll shortly move the active IDP to CAS 6.2 [12:20:02] the update is complete and everything seems just fine. if you notice anything to the contrary, please let jbond and myself know [12:21:19] anything exciting in the changelog? [12:35:03] nothing immediately user visible, but a ton of library upgrades, bugfixe and new features, which will be useful for further exploration (and to revisit old bugs that have bitten us). most notably they now have much more pervasive test coverage, which should hopefully make people update their installations with greater trust [12:35:44] looking at the cas-user list a ton of people still use 5.x and older since updates were more risky in the past [12:36:48] I'll add some more followup items/new features to investigate to https://phabricator.wikimedia.org/T265857 later, for this update step the immediate goal was to not regress :-) [12:40:30] thx! [14:15:22] XioNoX: https://labs.ripe.net/Members/alun_davies/join-us-for-a-ripe-ncc-open-house-on-10-years-of-ripe-atlas might be interesting [14:16:28] indeed [14:17:17] the issue is that we don't lack of ideas on how to use it, but time to implement the ideas [14:18:02] indeed [14:18:36] I did manage to make some good use of their CLI tool in the latest rounds of gathering debugging information, at least [14:20:12] --renderer traceroute_aspath is quite nice [14:20:13] I also guess they would be happy to have someone from Wikipedia telling them how we use their tool :)