theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
147 stars 163 forks source link

Combine connection parameters like url and user togeteher #519

Closed nesanton closed 4 years ago

nesanton commented 4 years ago
SUMMARY

When many foreman and katello modules are used in a play one might find it frustrating having to scecify the very same server_url, username, password, validate_certs all the time. And it's not really possible to use module_defaults, because one can't seem to wildcard them like foreman*.

Idea is to add an extra variable to all the modules and nest these underneath:

connection:
  server_url:
  username:
  password:
  validate_certs:

This way it's only one var to feed to any module. I guess it can coexist with the current way.

ISSUE TYPE
sean797 commented 4 years ago

Linking to https://github.com/theforeman/foreman-ansible-modules/pull/178

mdellweg commented 4 years ago

Also linking: https://github.com/ansible/ansible/pull/58070

evgeni commented 4 years ago

@mdellweg didn't I once saw a playbook of yours where you used some YaML reference or so to pass the connection parameters? It's not the same but still makes life easier.

mdellweg commented 4 years ago

Like here: https://github.com/mdellweg/pulp_ansible_modules/blob/master/tests/playbooks/file_distribution.yaml#L55 Yes, but its scope is limited to one file.

nesanton commented 4 years ago

I learnt to live with either yaml references like @mdellweg's or this:

vars:
  foreman_api:
     server_url: https://blah.blah.com
     username: blah
     password: blahblah
     validate_certs: no
module_defaults:
  foreman_this: "{{ foreman_api }}"
  foreman_that: "{{ foreman_api }}"
  katello_here: "{{ foreman_api }}"

or the combination of two.

Anyway, closing this, because it seems to be (or going to be) sort of solvable by module grouping.