https://www.puppet.com/community logo
Join Slack
Powered by
# puppet-dev
  • g

    genebean

    02/25/2025, 9:39 PM
    guess I will take the guts of chunk a and make a method out of it and use it in both chunks a and b
  • c

    csharpsteen

    02/25/2025, 9:40 PM
    Looks like you can add one
    aggregate
    block that can execute logic over all the values returned by the
    chunk
    blocks: https://www.puppet.com/docs/puppet/8/fact_overview#building-structured-fact-progressively
  • g

    genebean

    02/25/2025, 9:40 PM
    that matches the old docs too https://github.com/puppetlabs/puppet-docs/blob/master/source/facter/2.4/custom_facts.markdown#structured-facts
  • g

    genebean

    02/25/2025, 9:40 PM
    https://github.com/puppetlabs/puppet-docs/blob/master/source/facter/2.4/fact_overview.markdown
  • c

    csharpsteen

    02/25/2025, 9:41 PM
    But, with
    aggregate
    you also have to handle merging the chunks together in addition to generation of any new values.
  • c

    CVQuesty

    02/25/2025, 9:43 PM
    (structured data) đź§Ś
  • g

    genebean

    02/25/2025, 9:43 PM
    Looks like breaking the content of a into a function and using it in both places should work... guess I will see shortly
  • c

    csharpsteen

    02/25/2025, 9:45 PM
    Fetching the data twice is probably just fine --- unless it is expensive to fetch and/or changes rapidly.
  • t

    tuxmea

    02/26/2025, 8:13 AM
    https://dev.to/betadots/the-ruby-side-of-puppet-part-1-custom-facts-3hb7 my posting on facter development
    👍 1
    thankyou 1
  • b

    Brian Schonecker

    03/07/2025, 12:15 PM
    Good 07:11 EST. I'm writing a custom fact that returns the Oracle Cloud region that the servers are in based upon their IP address. The fact seems to be working ok but I'm having trouble with the tests. I need to specify the IP address in the test (or do I?) and I haven't been able to figure out how to set the fact. I've got the tests set up to loop around a hash, set the IP fact and then compare the IP to the region that should be returned. I can't figure out how to set 'networking.ip' or how to specify the IP address as a variable. Should I change the design from a loop to a set of single lines? Any pointers are appreciated!
    y
    n
    • 3
    • 34
  • j

    Jerry Way

    03/13/2025, 10:02 PM
    Hi, trying to get a couple files from /files folder in a module to Windows nodes. In the code below it gets past the first file and then complains that: "Could not get metadata for puppet:///modules/tools_installer/register-c4bendpoint.ps1" (I guess I'm presuming it got past the first one. I had it misspelled the first time and it errored with the same message. Fixed the misspelling and it went past. Then I get the error here for the second file. I thought it might be a case issue since the file is like this on the PE Master -rw-r-----. 1 pe-puppet pe-puppet 921 Mar 13 14:38 Register-C4bEndpoint.ps1. I lowered the case in the code and renamed the file with lowercase. I deleted it from the directory on the PE Master and reran the commit to get the lowercase file. But I still get that error. Case was the only difference I can find. Thoughts on where to look next?
    file { 'choco_endpoint_ps':
    ensure => file,
    path   => "${host_location}/choco_endpoint.ps1",
    source => 'puppet:///modules/tools_installer/choco_endpoint.ps1',
    }
    file { 'choco_endpoint_script':
    ensure => file,
    path   => "${host_location}/register-c4bendpoint.ps1",
    source => 'puppet:///modules/tools_installer/register-c4bendpoint.ps1,',
    }
    Then in the PE log I see the following right after the metadata error: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb292in `block in inline_metadata' org/jruby/RubyArray.java1981in `each' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb215in `inline_metadata' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb364in `block in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb59in `profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb53in `profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb363in `block in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb190in `block in benchmark' uriclassloader/META-INF/jruby.home/lib/ruby/stdlib/benchmark.rb311in `realtime' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb189in `benchmark' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb362in `block in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb59in `profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb53in `profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb338in `block in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb190in `block in benchmark' uriclassloader/META-INF/jruby.home/lib/ruby/stdlib/benchmark.rb311in `realtime' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb189in `benchmark' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb336in `compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb81in `block in find' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node/environment.rb490in `with_text_domain' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb77in `find' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb230in `find' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/api/indirected_routes.rb116in `do_find' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/api/indirected_routes.rb54in `block in call' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb64in `override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb292in `override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/api/indirected_routes.rb53in `call' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/api/server/v3.rb18in `block in wrap' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/route.rb85in `block in process' org/jruby/RubyArray.java1981in `each' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/route.rb84in `process' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/route.rb91in `process' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/route.rb91in `process' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/handler.rb88in `block in process' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/handler.rb71in `block in with_request_profiling' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb59in `profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb53in `profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/handler.rb67in `with_request_profiling' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/handler.rb87in `block in process' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/handler.rb94in `respond_to_errors' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/network/http/handler.rb86in `process' uriclassloader/puppetserver-lib/puppet/server/master.rb69in `block in handleRequest' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb64in `override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb292in `override' uriclassloader/puppetserver-lib/puppet/server/master.rb68in `handleRequest'
  • j

    josh

    03/14/2025, 12:43 AM
    There’s an extra comma inside the second
    source
    parameter
    🦅 1
  • j

    josh

    03/14/2025, 12:44 AM
    ps1,’,
  • j

    Jerry Way

    03/14/2025, 2:24 PM
    Oh wow, the number of times I stared and glared at that line. Thanks so much.
  • b

    bastelfreak

    03/18/2025, 4:04 PM
    @josh does puppet core windows depend on minitar 1.x / could that be updated if that didn't happen already?
  • b

    bastelfreak

    03/18/2025, 4:09 PM
    mostly because of https://github.com/puppetlabs/puppet-modulebuilder/pull/108
  • j

    josh

    03/18/2025, 4:57 PM
    @bastelfreak I started working on that in https://github.com/puppetlabs/puppet/pull/9449 last year. One way to fix this is to add a runtime/hard dependency on
    minitar
    so that we guarantee minitar > 1 is installed. However, the presence of the
    minitar
    gem will cause that to be preferred when running
    puppet module install
    https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/module_tool/tar.rb#L11-L18 Using minitar is slower than native
    tar
    and we have to be aware of security issues (that may be handled in native tar, but not minitar) like zipslip. Alternatively, we could add the runtime/hard dependency, but only use
    minitar
    if
    tar
    is unavailable. A third option it to leave
    minitar
    is a soft/feature and raise if the installed version isn't 1.0 or greater. I definitely don't want to support both the old and new minitar interfaces.
  • b

    bastelfreak

    03/18/2025, 4:58 PM
    I think the windows builds already have a hard dependency on minitar? Can't that just be bumped to 1.x?
  • j

    josh

    03/18/2025, 5:00 PM
    since some people install puppet as a gem, I think we still need to verify at runtime that minitar > 1 is present on windows and raise if it's not.
  • b

    bastelfreak

    03/18/2025, 5:03 PM
    It's a bit weird. In the puppet-modulebuilder CI it looks like the windows specific puppet gem isn't installed, but the generic one
  • b

    bastelfreak

    03/18/2025, 5:05 PM
    Or is there maybe some cygwin/whatever layer in between that confuses bundler? I didn't invest too much time
  • b

    bastelfreak

    03/18/2025, 5:06 PM
    And the windows specific gem already has the hard dependency, so you don't need additional checks
  • j

    josh

    03/18/2025, 5:11 PM
    ah right. There's no cygwin there. It's just gem/bundle dependency resolution can take into account the ruby platform and select the most appropriate version. For puppet/minitar, it's the non-windows case where someone just happens to have
    minitar
    installed, so we need to verify the minitar version and not assume > 1
  • b

    bastelfreak

    03/18/2025, 5:15 PM
    Yeah
  • j

    Jerry Way

    03/20/2025, 10:22 PM
    Hi, on Windows trying to add a root cert provided by our internal issuing authority. I'm using the 'puppetlabs-sslcertificate', '5.0.0' module. Trying to get the cert into Trusted Root Certification Authorities This works, but it put it in the Intermediate Certification Authorities store. I need it in the Trusted Root Certification Authorities store. NOTE: Should anyone come upon this the only solution I found was to use PowerShell directly using the following:
    Copy code
    $store = New-Object System.Security.Cryptography.X509Certificates.X509Store(
            [System.Security.Cryptography.X509Certificates.StoreName]::Root,
            [System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine
        )
    This is different from the sslcertificate module only in that the module tries to take both of these values in an array. I split them up here designating the StoreName and StoreLocation. This is how the sslcertificate module does it and it sticks it into the intermediate store.
    Copy code
    $store = new-object System.Security.Cryptography.X509Certificates.X509Store("<%= @store_dir %>","<%= @root_store %>")
    sslcertificate { 'Root Certificate':
    name       => '<certname>-2021.cer',
    location   => 'D:/Certificates',
    store_dir  => 'Root',
    root_store => 'LocalMachine',
    require    => File['D:/Certificates/<certname>-2021.cer'],
    thumbprint => 'ce1b9f2f5d2fc0c88d3b7d52b773cd<truncated>',
    Thoughts? Thanks, Jerry
  • d

    Dr Bunsen Honeydew

    03/20/2025, 10:22 PM
    See the
    puppetlabs-sslcertificate
    module at https://forge.puppet.com/puppetlabs/sslcertificate?src=slack&amp;channel=puppet-dev
  • j

    Jerry Way

    04/21/2025, 4:49 PM
    Hi, I have used these two option to limit application of a class to certain OS. if $facts['os']['family'] == 'windows' and if $facts['kernel'] == 'windows' is one preferred over the other?
    b
    • 2
    • 8
  • d

    Danny Tung

    04/24/2025, 2:11 AM
    Hi, I just got back to using Puppet with work. I recently task to organized my programs puppet codes.... We have multiple sites, and each site has multiple environments (dev / test / prod). So I see that we could have multiple folders inside the environment folder to separate them. If I want to have an extra layer on top for various sites (Asia, Europe, America), is there a way to do that?
  • y

    Yury Bushmelev

    04/24/2025, 2:16 AM
    I’d recommend to read about Hiera and “Roles and Profiles” first.
    d
    e
    • 3
    • 7
  • d

    Danny Tung

    04/24/2025, 2:17 AM
    Another question: for the puppet agent certificate. If it is expired, there isn't a way to leverage to puppet master to push it to the node again right? I have to physically go onto the server to update the cert. I could bite the bullet for that. But for the one that is not expired, is it wise to leverage puppet to push out new cert when it it about to expired? It is talking about the cert that the agent to communicate with the master.
    y
    • 2
    • 1