-
Notifications
You must be signed in to change notification settings - Fork 165
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
[WIP] Add foreman_ansible_roles module #753
base: develop
Are you sure you want to change the base?
Conversation
Is state=fetch used to list the available roles on a proxy? If so, I'd prefer if we could have one module for listing, and one for performing actions, as that's what current ansible best practice is. |
@evgeni The fetch action lists the Ansible Roles that have been placed in I don't mind making that action a separate module if that's the desired direction. I think the Would you like fetch to be its own module? |
0a38887
to
51f935a
Compare
I've renamed the module to I'll limit this PR to just the fact gathering module and open another PR to implement the I'll start working on adding test cases. |
@evgeni What is the recommended way to get files on the filesystem when running tests? I need to place a test role in |
@evgeni One other question. During the test run I'm creating the Organization and Location, but I need to assign the location to the smart proxy. I'm not finding any functionality to do that. Is there functionality to do that? |
Nope, sorry. We have #149 open, and I think there even was a PR for it, but never got merged :( |
Sadly not. We have the same issue with Puppet modules too. In the past, I've been using the following snippet foreman-ansible-modules/tests/test_playbooks/host.yml Lines 2 to 10 in 41d0a7a
and adding a foreman-ansible-modules/tests/test_playbooks/hostgroup.yml Lines 2 to 8 in 41d0a7a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid we managed to leave this PR around for too long and merged a huge refactoring since then. I'll provide suggestions how to update.
9076ee5
to
ac970aa
Compare
Thanks @branic! And once more, sorry for keeping you busy by catching up on changes we made to our helpers. I've tried your module, and it works as advertised. However, I am a bit confused about the exposed workflow(s).
So if I'd be king (I am not, lucky you), I'd name this module ¹: there has been a huge movement in Ansible to move away from the "facts" term to "info" - see https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html how all _facts modules are marked as deprecated in favor of their _info siblings |
Oh, and I didn't see any difference between list and show in my tests. What extra info should show expose? |
I haven't seen any difference in list and show in my tests either. The API has both a list and a show endpoint which was why I implemented both.
|
Yeah. I think list and show are just default methods of the api and thus exist here. Show is cheaper if you only need to see one item. But in our specific case we only need the list IMHO. |
For the workflow, I've been conflicted as well. The list/show functionality does overlap with the I agree it does make sense to split the fetch and list/show into their own modules. As for having a dedicated list/show module is that a direction you would like the project to go or should users just rely on the |
Long term I'd love to see us having separate "info" modules for the various resources, but it's far from a priority as long foreman_search_facts covers the same functionality with a slightly more complicated interface. |
Great. I'll work on splitting the module into two modules. Thanks for all the great feedback. |
- The Smart Proxy name to use for fetching Ansible Roles | ||
required: false | ||
type: str | ||
aliases: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aliases: | |
aliases: |
(the linter is unhappy)
proxy: | ||
description: | ||
- The Smart Proxy name to use for fetching Ansible Roles | ||
required: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false | |
required: true |
|
||
DOCUMENTATION = ''' | ||
--- | ||
module: foreman_ansible_roles_facts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module: foreman_ansible_roles_facts | |
module: foreman_ansible_roles_importable_info |
organization=dict(type='entity'), | ||
location=dict(type='entity'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are those two actually used for anything? I know you can pass them in the request, but I don't see any use for doing so. the data on disk (which this action lists) is not org/loc aware.
I think the API just allows to pass those, as it allows this on every request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ares is that right? 'fetch' should not be scoped?
|
||
module = ForemanAnsibleRolesImportedInfoModule( | ||
foreman_spec=dict( | ||
search=dict(default=""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
search=dict(default=""), | |
search=dict(), |
no need for a default
module = ForemanAnsibleRolesImportedInfoModule( | ||
foreman_spec=dict( | ||
search=dict(default=""), | ||
full_details=dict(type='bool', aliases=['info'], default=False), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given the API does not return more info, shall we drop that param?
|
||
DOCUMENTATION = ''' | ||
--- | ||
module: foreman_ansible_roles_facts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module: foreman_ansible_roles_facts | |
module: foreman_ansible_roles_imported_info |
This PR adds a foreman_ansible_roles module.
This module will allow working with Foreman Ansible Roles.
Marking this PR as WIP, but I wanted to get it open to get feedback on the current (although limited) functionality.