Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot work with HTTP code 307 (redirect) #31

Open
krulls opened this issue Jul 15, 2015 · 1 comment
Open

Cannot work with HTTP code 307 (redirect) #31

krulls opened this issue Jul 15, 2015 · 1 comment

Comments

@krulls
Copy link

krulls commented Jul 15, 2015

Use case

We are using the Hiera backend (version 1.4.0) to download YAML files for our Puppet deployment manifests.

Environment

Internally we are working with Maven (https://maven.apache.org/) and Nexus OSS (http://www.sonatype.org/nexus/go/) to develop our packages that shall be deployed by Puppet.

In Nexus, artifacts that are developed have a name suffix "-SNAPSHOT", Nexus itself uses a redirect to deliver the latest SNAPSHOT version. A URL to a SNAPSHOT artifact looks like this:
http://internal.nexus.host:8080/service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml

We are running Puppet (Version 3.6.2 with Ruby 1.9) apply command with Hiera configuration file to read values from a YAML file from our Nexus. This is the command line (Windows / Batch File)

puppet apply --modulepath=\\host.intern\modules -l %LogDir%\puppetizer.log --hiera_config=yaml\our_hiera_config.yaml .\manifests\doit.pp

Our Hiera configuration file (yaml\our_hiera_config.yaml) has this configuration:

:http:
  :host: internal.nexus.host
  :port: 8080
  :output: yaml
  :failure: graceful
  :paths:
    - /service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml

Error

We are getting the following log output from Puppet:

2015-07-14 13:25:12 +0200 Puppet (debug): hiera(): [hiera-http]: Lookup url_authentication from internal.nexus.host:8080/service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml
2015-07-14 13:25:12 +0200 Puppet (debug): hiera(): [hiera-http]: bad http response from internal.nexus.host:8080/service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml
2015-07-14 13:25:12 +0200 Puppet (debug): hiera(): HTTP response code was 307

I am able to reproduce that by running Hiera alone, command:

C:\work\hiera-3.0.1\bin>hiera some_variable --debug --config C:\users\krulls\test.yaml

setting
set RUBYLIB=C:\work\hiera-http-1.4.0\lib
to include the Hiera http backend, of course

and result:

DEBUG: 2015-07-15 13:49:17 +0200: [hiera-http]: Lookup maven_artifact_full_id_authentication from internal.nexus.host:8080/service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml
DEBUG: 2015-07-15 13:49:17 +0200: [hiera-http]: bad http response from internal.nexus.host:8080/service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml
DEBUG: 2015-07-15 13:49:17 +0200: HTTP response code was 307
nil

Guesses

Quoting the 'paths' entry

like

  :paths:
    - "/service/local/artifact/maven/redirect?r=snapshots&g=ecg&a=our.artifact&v=1.0.0-SNAPSHOT&e=yaml"

--> Did not succeed

Unhandled http response code

This could be a problem with the underlying handler for http request. Maybe it is not able to work correctly with the certain HTTP code 307, see :
Nexus REST redirect reference?
Issue on an ANT task
SO question regarding Nexus REST API and WGET

@crayfishx
Copy link
Owner

As discussed over email - the Net::HTTP library won't follow redirects by default - this is a feature that would need to be implemented in hiera-http

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants