Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10324

Forward http client requests to puppetserver

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.15.0
    • None
    • Hide

      It should be possible to write a custom function or report processor that makes POST and GET requests using the HTTP client when running in puppetserver. Add the following report processor to lib/puppet/reports/myreport.rb.

      Puppet::Reports.register_report(:myreport) do
        def process
          client = Puppet.runtime['http']
          client.get(URI("https://<puppetserver>.delivery.puppetlabs.net:8140/status/v1/simple"))
          client.post(URI("https://<puppetserver>.delivery.puppetlabs.net:8140/puppet/v3/catalog/#{Puppet[:certname]}?environment=production"), content_type: 'text/plain', body: '')
        end
      end
      

      Register the processor in puppet.conf:

      [main]
      reports = myreport
      

      Run puppet agent -t and verify puppetserver successfully gets & posts.

      Show
      It should be possible to write a custom function or report processor that makes POST and GET requests using the HTTP client when running in puppetserver. Add the following report processor to lib/puppet/reports/myreport.rb . Puppet::Reports.register_report( :myreport ) do def process client = Puppet.runtime[ 'http' ] client.get( URI ( "https://<puppetserver>.delivery.puppetlabs.net:8140/status/v1/simple" )) client.post( URI ( "https://<puppetserver>.delivery.puppetlabs.net:8140/puppet/v3/catalog/#{Puppet[:certname]}?environment=production" ), content_type: 'text/plain' , body: '' ) end end Register the processor in puppet.conf : [main] reports = myreport Run puppet agent -t and verify puppetserver successfully gets & posts.
    • Coremunity
    • Platform Core KANBAN
    • Needs Assessment
    • Not Needed
    • Calls to the new HTTP client will be routed to the existing puppetserver implementation. I put not needed because there shouldn't be any user visible change.
    • Needs Assessment

    Description

      In order to switch the http report processor and other server-side termini to using the new HTTP Client API, we need to provide a puppetserver implementation of the API. However, we don't want to introduce an incompatibility in puppet 6.x such that it requires a specific version of puppetserver 6.x to work.

      So the idea is to create an implementation of the HTTP Client API which adapts the legacy
      Puppet::Network::HttpPool.http_client_class that puppetserver currently registers.

      For this ticket:

      1. Create Puppet::HTTP::ExternalClient which implements a subset of the Puppet::HTTP::Client API, get and post, as those are the only methods implemented in puppetserver.
      2. All other public methods should raise NotImplementedError, like create_session, put, etc.
      3. When get or post are called, the external client should create an instance of Puppet::Network::HttpPool.http_client_class and adapt the Client API to the legacy Connection API. So raise instances of Puppet::HTTP::HTTPError or subclasses, return Puppet::HTTP::Response objects, etc.
      4. Register the Puppet::HTTP::ExternalClient in the puppet runtime when the HttpPool.http_client_class= method is called.

      Attachments

        Issue Links

          Activity

            People

              josh Josh Cooper
              josh Josh Cooper
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support