theforeman / foreman_ansible_inventory

Foreman dynamic inventory script for ansible - Now merged into Ansible itself
GNU General Public License v3.0
70 stars 31 forks source link

Expand Foreman parameter support #9

Closed killsudo closed 8 years ago

killsudo commented 8 years ago

Would it be possible to include support to fetch Foreman parameters from Organizations, Locations, and global when compiling the host foreman parameter list?

I have this script successfully displaying my Foreman inventory along with host groups. I can define a parameter on the host directly or on a host group and this script will see those and print them under the host object

      "updated_at": "2016-03-21T00:33:26Z", 
      "use_image": null, 
      "uuid": null
    }, 
    "foreman_params": {
      "ntp-mode": "client", 
      "webapp": "PHP-IPAM"
    }

When I view the host via the Foreman webgui it displays parameters to override from the Organization / Location / global parameters.

It would be really useful to leverage the Organization / Location / and global parameters under foreman_params instead of needing to create lots of host groups or nested host groups.

killsudo commented 8 years ago

Looks like issue #1 is related and brought in the host / host group parameters

agx commented 8 years ago

Yes, this would make a lot of sense, I just did not get around to add it yet.

arielsalvo commented 8 years ago

I noticed the host returned by Foreman's API contains an all_parameters entry which contains Organization / Location / and global as well has host and group parameters. I implemented this in PR #15 . I added an option server_param_resolution in the section foreman of the ini file to make this change optional and backwards compatible; if missing or set to False, the original behavior is maintained.

It would be nice to have a way to query all_parameters from the API itself instead of having to use the host.

agx commented 8 years ago

Thanks @arielsalvo . I vaguely remember not using all_parameters for a reason but don't remember what it was. If I can't dig this up again we should only use all_parameters and rather remove the custom parameter resolution. Might be a couple of days though until I get to it.