theforeman / foreman_host_rundeck

API for Rundeck to pull host data from Foreman
GNU General Public License v3.0
12 stars 11 forks source link

pass url params into formatter #7

Open nathanielc opened 9 years ago

nathanielc commented 9 years ago

Not sure if this is the best solution to the problem but it does work (I am not a ruby rails guy).

Basically the rundeckuser and rundeckfacts parameters didn't work because the params field was not the url parameters, but something else not sure what. Passing the url param variable into the formatter fixes the issues.

If this patch is completely off base please point me in the right direction.

I am invoking this plugin like so:

curl -k -u "user:$pass" -X GET 'https://foreman/hosts/?rundeck=true&format=yaml&rundeckuser=jim&rundeckfacts=domain'

And getting output like:

host.example.com:
  description: ''
  hostname: host.example.com
  nodename: host.example.com
  Environment: production
  osArch: x86_64
  osFamily: Redhat
  osName: CentOS
  osVersion: '6.6'
  tags:
    - domain=example.com
  username: jim
nathanielc commented 9 years ago

OK so I changed this up a bit. The original params are from the 'Parameters' that foreman adds to hosts not query_params. Since my use case needs to change which tags and user are returned based on caller I just added the option to have query_params override any Foreman parameters.

orrabin commented 9 years ago

@nvcook42 rundeck=true doesn't need to be passed to the url anymore, if you use the plugin once you use format=yaml it will use rundeck. Can you please add a test? if that's a problem send me an example of the output you expected to get with the example you wrote and I'll add it