Conversation
self.module.fail_json(msg="Error setting relative URL on repo.") | ||
|
||
def set_repo_list(self): | ||
cmd = self.pulp_command |
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.
Since that method is parsing output ( in parse_repo_list), you need to make sure that the command is run with C locales. See https://github.com/ansible/ansible-modules-core/pull/3257/files for a example.
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.
@mscherer wouldn't this be sufficient https://github.com/ansible/ansible-modules-extras/pull/1961/files#diff-6d7169a8a399575e4dfbcc7c8872ca83R232 ?
Seems check mode return a different thing that non check mode, I think it would be cleaner to get the same dict returned. |
Thanks @sysadmind for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion. [This message brought to you by your friendly Ansibull-bot.] |
description: | ||
- name of the repo to add or remove (correlates to pulp's repo-id) | ||
required: true | ||
default: null |
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.
default: null
should be omitted if required: true
Thanks @sysadmind for this PR. This PR requires revisions, either because it fails to build or by reviewer request. Please make the suggested revisions. When you are done, please comment with text 'ready_for_review' and we will put this PR back into review. [This message brought to you by your friendly Ansibull-bot.] |
''' | ||
|
||
RETURN = ''' | ||
--- |
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.
This line should not be here.
I would rather see an implementation which would call the Pulp REST API instead of the pulp-admin command. It makes the error handling and output parsing much simpler. Use the |
@sysadmind A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes. When you do address the issues, please respond with ready_for_review in your comment, so that we can notify the maintainer. [This message brought to you by your friendly Ansibull-bot.] |
I did some more tests and have found out this:
Otherwise I see your point about the
The last but not least, the module should be called |
- Whether or not to add the export distributor to new C(rpm) repositories. | ||
required: false | ||
default: false | ||
feed_url: |
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 would rename this to feed
to follow the convention given by pulp-admin
with its --feed
.
I have written my own python script to perform pulp repo creation, syncing and copying repos, which uses pulp-admin behind the scenes. But having an ansible module for pulp administration would be 👍 . Do you think there would be a place in the module to support copy tasks? What about creating the repo config files for the client side? |
@gthieleb I have a separate module that I have developed to copy content units between repositories. I think that it makes sense to keep units and repositories separate. It may also make sense to create a client side module for that task. Once the pulp_repo module is merged, I'll work on getting the other modules contributed upstream. |
I would love to use this module and it looks like you guys have put a lot of work into it - anything I can do to help get this merged? |
@dvanallen You can test the module and comment with the magic word as explained here. |
Yes @dvanallen, testing would be a HUGE help as many different users have different use cases for pulp and it's hard to test for them all. Please report back with any issues or the magic words as @jtyr links to above to help get this merged. |
shipit If someone needs code to test it, here is how i did it on Vagrant. Comment the roles as you might not have them
|
@sysadmind you could check if the importer_ssl_ca_cert parameter is multiline. If not treat it as a file path to the certs? edit: or use file lookup. Not sure what is more the "ansible way"? (Module supports paths or require file lookups) |
The |
@jtyr only importer_ssl_ca_cert needs to be a string. The other importer_ssl_* vars already have to be file paths. |
shipit @sysadmind I fully switched to your module (replaced it with my own). The only nuisance is the extra Task required for importer_ssl_ca_cert 😄. |
@Nebelwolf I'll try and get around to updating it to work with your ssl ca certs. It's hard for me to test because I don't use that setting. If I understand correctly, it can either be a file path or actual certificate content (multiline). Is that the case? If I can figure out those changes and get them pushed to a branch, would you be able to test? Or do you have a testing procedure (like with a pulp docker container) that I could use for testing this functionality so that I can confirm I fix it for you? |
@sysadmind
You see the extra task for importer_ssl_ca_cert? I just meant it would be nice if I could just give it the file path as parameter. Now it needs the multiline var with the cert. So you would need to read the cert contents from the file path in your module code and pass that to the api call. Maybe you should accept only paths for importer_ssl_ca_cert? Would be more consistent with the other importer_ssl_* params? I can test it when you change something. Sorry theres no docker container for this. You need an valid RedHat subscription to test it. |
I think I have this working as you would expect @Nebelwolf and @jtyr. I was able to curl the api and see the certs/keys by both entering the content and specifying a path to a file. Can you please test to make sure it works on your systems? |
@sysadmind sorry for the delay. Yes it works now as expected thanks! |
@Nebelwolf @Nosmoht @dvanallen @jtyr If there is no other feedback, I would appreciate your assistance in getting this merged. You can comment on this PR as stated in #1961 (comment) and that will mark this PR for merge by the maintainers. I appreciate your help and feedback in this PR. |
@sysadmind do I have to comment the "magic word" again? shipit ⛵ |
|
||
# import module snippets | ||
from ansible.module_utils.basic import * | ||
from ansible.module_utils.urls import * |
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.
It would be better to have explicit imports like this:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url
from ansible.module_utils.urls import url_argument_spec
import json | ||
from time import sleep | ||
|
||
# import module snippets |
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.
This comment is not necessary as the bellow are not snippets (it used to be in <v2.x) but regular modules.
|
||
def check_repo_exists(self, repo_id): | ||
try: | ||
repo_config = self.get_repo_config_by_id(repo_id) |
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.
The variable assignment is not necessary as you don't use the variable anywhere else. Just call the function itself:
try:
self.get_repo_config_by_id(repo_id)
def check_repo_exists(self, repo_id): | ||
try: | ||
repo_config = self.get_repo_config_by_id(repo_id) | ||
|
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.
There should be no space here.
|
||
except IndexError: | ||
return 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.
The same as above - no space here.
This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo. |
Moving to core repo. |
ISSUE TYPE
COMPONENT NAME
pulp_repo
ANSIBLE VERSION
SUMMARY
This adds a module for working with pulp repos. http://www.pulpproject.org/. I added this under packaging/os because it seemed like the most relevant location for this module although it is not explicitly an os packaging module like others in this directory.
I created a class that lines up with a pulp server and added methods for getting and setting repo properties. I chose this design because it closely resembles the actual design of pulp and keeps the code logically separated into small methods.